o |nh @s4ddlZddlmZddlmZGdddeZdS)N)utils)SystemBackendMixinc@s.eZdZddZddZd ddZdd Zd S) PolicycCsd}|jj|dS)zList all configured policies. Supported methods: GET: /sys/policy. Produces: 200 application/json :return: The JSON response of the request. :rtype: dict z/v1/sys/policyurl)_adapterget)selfapi_pathr I/usr/local/lib/python3.10/dist-packages/hvac/api/system_backend/policy.py list_policiess zPolicy.list_policiescCtjd|d}|jj|dS)a5Retrieve the policy body for the named policy. Supported methods: GET: /sys/policy/{name}. Produces: 200 application/json :param name: The name of the policy to retrieve. :type name: str | unicode :return: The response of the request :rtype: dict /v1/sys/policy/{name}namer)r format_urlrrr rr r r r read_policys zPolicy.read_policyTcCsPt|tr|rtj|ddd}nt|}d|i}tjd|d}|jj||dS)aAdd a new or update an existing policy. Once a policy is updated, it takes effect immediately to all associated users. Supported methods: PUT: /sys/policy/{name}. Produces: 204 (empty body) :param name: Specifies the name of the policy to create. :type name: str | unicode :param policy: Specifies the policy document. :type policy: str | unicode | dict :param pretty_print: If True, and provided a dict for the policy argument, send the policy JSON to Vault with "pretty" formatting. :type pretty_print: bool :return: The response of the request. :rtype: requests.Response T)indent sort_keyspolicyrr)rjson) isinstancedictrdumpsrrrput)r rr pretty_printparamsr r r r create_or_update_policy&s  zPolicy.create_or_update_policycCr)aDelete the policy with the given name. This will immediately affect all users associated with this policy. Supported methods: DELETE: /sys/policy/{name}. Produces: 204 (empty body) :param name: Specifies the name of the policy to delete. :type name: str | unicode :return: The response of the request. :rtype: requests.Response rrr)rrrdeleterr r r delete_policyFs zPolicy.delete_policyN)T)__name__ __module__ __qualname__r rr r"r r r r rs   r)rhvacr,hvac.api.system_backend.system_backend_mixinrrr r r r s