o |nh@sLdZddlZddlmZmZddlmZddlmZdZ GdddeZ dS) z#Azure secret engine methods module.N) exceptionsutils) VaultApiBase)VALID_ENVIRONMENTSazurec@sbeZdZdZdddefddZefddZefddZddefd d Zefd d Z efd dZ dS)AzurezhAzure Secrets Engine (API). Reference: https://www.vaultproject.io/api/secret/azure/index.html Nc Csn|dur|tvrd}t|j|dtd||d}|t|||dtjd|d} |j j | |d S) aConfigure the credentials required for the plugin to perform API calls to Azure. These credentials will be used to query roles and create/delete service principals. Environment variables will override any parameters set in the config. Supported methods: POST: /{mount_point}/config. Produces: 204 (empty body) :param subscription_id: The subscription id for the Azure Active Directory :type subscription_id: str | unicode :param tenant_id: The tenant id for the Azure Active Directory. :type tenant_id: str | unicode :param client_id: The OAuth2 client id to connect to Azure. :type client_id: str | unicode :param client_secret: The OAuth2 client secret to connect to Azure. :type client_secret: str | unicode :param environment: The Azure environment. If not specified, Vault will use Azure Public Cloud. :type environment: str | unicode :param mount_point: The OAuth2 client secret to connect to Azure. :type mount_point: str | unicode :return: The response of the request. :rtype: requests.Response NzWinvalid environment argument provided "{arg}", supported environments: "{environments}",)arg environments)subscription_id tenant_id) client_id client_secret environment/v1/{mount_point}/config mount_pointurljson) rrParamValidationErrorformatjoinupdater remove_nones format_url_adapterpost) selfr r r rrr error_msgparamsapi_pathr"I/usr/local/lib/python3.10/dist-packages/hvac/api/secrets_engines/azure.py configures0! zAzure.configurecCs&tjd|d}|jj|d}|dS)aqRead the stored configuration, omitting client_secret. Supported methods: GET: /{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 data key from the JSON response of the request. :rtype: dict rrrdatarrrgetrrr!responser"r"r# read_configN   zAzure.read_configcCstjd|d}|jj|dS)akDelete the stored Azure configuration and credentials. Supported methods: DELETE: /auth/{mount_point}/config. Produces: 204 (empty body) :param mount_point: The "path" the method/backend was mounted on. :type mount_point: str | unicode :return: The response of the request. :rtype: requests.Response rrr%)rrrdelete)rrr!r"r"r# delete_config`s zAzure.delete_configcCsDdt|i}|t||dtjd||d}|jj||dS)aCreate or update a Vault role. The provided Azure roles must exist for this call to succeed. See the Azure secrets roles docs for more information about roles. Supported methods: POST: /{mount_point}/roles/{name}. Produces: 204 (empty body) :param name: Name of the role. :type name: str | unicode :param azure_roles: List of Azure roles to be assigned to the generated service principal. :type azure_roles: list(dict) :param ttl: Specifies the default TTL for service principals generated using this role. Accepts time suffixed strings ("1h") or an integer number of seconds. Defaults to the system/engine default TTL time. :type ttl: str | unicode :param max_ttl: Specifies the maximum TTL for service principals generated using this role. Accepts time suffixed strings ("1h") or an integer number of seconds. Defaults to the system/engine max TTL time. :type max_ttl: str | unicode :param mount_point: The "path" the method/backend was mounted on. :type mount_point: str | unicode :return: The response of the request. :rtype: requests.Response azure_roles)ttlmax_ttlz/v1/{mount_point}/roles/{name}rnamer)rdumpsrrrrrr)rr3r/r0r1rr r!r"r"r#create_or_update_roleqs$ zAzure.create_or_update_rolecCs&tjd|d}|jj|d}|dS)auList all of the roles that are registered with the plugin. Supported methods: LIST: /{mount_point}/roles. Produces: 200 application/json :param mount_point: The "path" the method/backend was mounted on. :type mount_point: str | unicode :return: The data key from the JSON response of the request. :rtype: dict z/v1/{mount_point}/rolesrr%r&)rrrlistr(r)r"r"r# list_rolesr,zAzure.list_rolescCs(tjd||d}|jj|d}|dS)aGenerate a new service principal based on the named role. Supported methods: GET: /{mount_point}/creds/{name}. Produces: 200 application/json :param name: Specifies the name of the role to create credentials against. :type name: str | unicode :param mount_point: The "path" the method/backend was mounted on. :type mount_point: str | unicode :return: The data key from the JSON response of the request. :rtype: dict z/v1/{mount_point}/creds/{name}r2r%r&r')rr3rr!r*r"r"r#generate_credentialss zAzure.generate_credentials) __name__ __module__ __qualname____doc__DEFAULT_MOUNT_POINTr$r+r.r5r7r8r"r"r"r#r s  <  0r) r<rhvacrrhvac.api.vault_api_baserhvac.constants.azurerr=rr"r"r"r#s