o |nh @s8dZddlmZmZddlmZdZGdddeZdS)zRADIUS methods module.) exceptionsutils) VaultApiBaseradiusc@speZdZdZddddefddZefddZdefddZefd d Zefd d Z efd dZ defddZ dS)Radiusz`RADIUS Auth Method (API). Reference: https://www.vaultproject.io/docs/auth/radius.html Nc Csz||d}|t|||d|dur.t|ts'djt|d} t| d ||d<tj d|d } |j j | |d S) aT Configure the RADIUS auth method. Supported methods: POST: /auth/{mount_point}/config. Produces: 204 (empty body) :param host: The RADIUS server to connect to. Examples: radius.myorg.com, 127.0.0.1 :type host: str | unicode :param secret: The RADIUS shared secret. :type secret: str | unicode :param port: The UDP port where the RADIUS server is listening on. Defaults is 1812. :type port: int :param unregistered_user_policies: A comma-separated list of policies to be granted to unregistered users. :type unregistered_user_policies: list :param dial_timeout: Number of second to wait for a backend connection before timing out. Default is 10. :type dial_timeout: int :param nas_port: The NAS-Port attribute of the RADIUS request. Defaults is 10. :type nas_port: int :param mount_point: The "path" the method/backend was mounted on. :type mount_point: str | unicode :return: The response of the configure request. :rtype: requests.Response )hostsecret)port dial_timeoutnas_portNzs"unregistered_user_policies" argument must be an instance of list or None, "{unregistered_user_policies}" provided.)unregistered_user_policies,r /v1/auth/{mount_point}/config mount_pointurljson) updater remove_nones isinstancelistformattyperParamValidationErrorjoin format_url_adapterpost) selfrrr r r r rparams error_msgapi_pathr#G/usr/local/lib/python3.10/dist-packages/hvac/api/auth_methods/radius.py configures2"  zRadius.configurecCtjd|d}|jj|dS)a Retrieve the RADIUS configuration for the auth method. Supported methods: GET: /auth/{mount_point}/config. Produces: 200 application/json :param mount_point: The "path" the method/backend was mounted on. :type mount_point: str | unicode :return: The JSON response of the read_configuration request. :rtype: dict rrrrrrgetrrr"r#r#r$read_configurationPs  zRadius.read_configurationcCsf|durt|tsdjt|d}t|i}|dur#d||d<tjd||d}|j j ||dS) a Create or update RADIUS user with a set of policies. Supported methods: POST: /auth/{mount_point}/users/{username}. Produces: 204 (empty body) :param username: Username for this RADIUS user. :type username: str | unicode :param policies: List of policies associated with the user. This parameter is transformed to a comma-delimited string before being passed to Vault. :type policies: list :param mount_point: The "path" the method/backend was mounted on. :type mount_point: str | unicode :return: The response of the register_user request. :rtype: requests.Response NzT"policies" argument must be an instance of list or None, "{policies_type}" provided.) policies_typer policiesz#/v1/auth/{mount_point}/users/{name})rnamer) rrrrrrrrrrr)rusernamer-rr!r r"r#r#r$ register_usercs" zRadius.register_usercCr&)ad List existing users in the method. Supported methods: LIST: /auth/{mount_point}/users. Produces: 200 application/json :param mount_point: The "path" the method/backend was mounted on. :type mount_point: str | unicode :return: The JSON response of the list_users request. :rtype: dict z/v1/auth/{mount_point}/usersrr')rrrrr*r#r#r$ list_userss  zRadius.list_userscCtjd||d}|jj|dS)a Read policies associated with a RADIUS user. Supported methods: GET: /auth/{mount_point}/users/{username}. Produces: 200 application/json :param username: The username of the RADIUS user :type username: str | unicode :param mount_point: The "path" the method/backend was mounted on. :type mount_point: str | unicode :return: The JSON response of the read_user request. :rtype: dict '/v1/auth/{mount_point}/users/{username}rr/r'r(rr/rr"r#r#r$ read_userzRadius.read_usercCr2)a Delete a RADIUS user and policy association. Supported methods: DELETE: /auth/{mount_point}/users/{username}. Produces: 204 (empty body) :param username: The username of the RADIUS user :type username: str | unicode :param mount_point: The "path" the method/backend was mounted on. :type mount_point: str | unicode :return: The response of the delete_user request. :rtype: requests.Response r3r4r')rrrdeleter5r#r#r$ delete_userr7zRadius.delete_userTcCs*d|i}tjd||d}|jj|||dS)a: Log in with RADIUS credentials. Supported methods: POST: /auth/{mount_point}/login/{username}. Produces: 200 application/json :param username: The username of the RADIUS user :type username: str | unicode :param password: The password for the RADIUS user :type password: str | unicode :param use_token: if True, uses the token in the response received from the auth request to set the "token" attribute on the the :py:meth:`hvac.adapters.Adapter` instance under the _adapter Client attribute. :type use_token: bool :param mount_point: The "path" the method/backend was mounted on. :type mount_point: str | unicode :return: The response of the login_with_user request. :rtype: requests.Response passwordz'/v1/auth/{mount_point}/login/{username}r4)r use_tokenr)rrrlogin)rr/r:r;rr r"r#r#r$r<sz Radius.login) __name__ __module__ __qualname____doc__DEFAULT_MOUNT_POINTr%r+r0r1r6r9r<r#r#r#r$r s  A $  rN)r@hvacrrhvac.api.vault_api_baserrArr#r#r#r$s