How to use the azure-keyvault.azure.keyvault._generated.v7_0.models.SecretAttributes function in azure-keyvault

To help you get started, we’ve selected a few azure-keyvault examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github Azure / azure-sdk-for-python / azure-keyvault / azure / keyvault / secrets / _client.py View on Github external
:returns: The created secret
        :rtype: ~azure.keyvault.secrets._models.SecretAttributes
        :raises: ~azure.core.exceptions.ClientRequestError if the client failed to create the secret

        Example:
            .. literalinclude:: ../tests/test_examples_keyvault.py
                :start-after: [START update_secret_attributes]
                :end-before: [END update_secret_attributes]
                :language: python
                :dedent: 4
                :caption: Updates the attributes associated with a specified secret in the key vault

        """
        url = '/'.join((self._vault_url, 'secrets', name, version))

        attributes = _SecretAttributes(enabled=enabled, not_before=not_before, expires=expires)
        secret = SecretUpdateParameters(secret_attributes=attributes, tags=tags, content_type=content_type)

        query_parameters = {'api-version': self._api_version}

        headers = {
            'Content-Type': 'application/json; charset=utf-8',
            'x-ms-client-request-id': str(uuid.uuid1())
        }

        request_body = SERIALIZE.body(secret, 'Secret')

        request = HttpRequest('PATCH', url, headers, data=request_body)

        request.format_parameters(query_parameters)

        response = self._pipeline.run(request, **kwargs).http_response
github Azure / azure-sdk-for-python / azure-keyvault / azure / keyvault / secrets / _client.py View on Github external
:end-before: [END set_secret]
                :language: python
                :dedent: 4
                :caption: Set a secret in the key vault

        """
        url = '/'.join((self._vault_url, 'secrets', name))

        query_parameters = {'api-version': self._api_version}

        headers = {
            'Content-Type': 'application/json; charset=utf-8',
            'x-ms-client-request-id': str(uuid.uuid1())
        }

        attributes = _SecretAttributes(enabled=enabled, not_before=not_before, expires=expires)
        secret = SecretSetParameters(secret_attributes=attributes, value=value, tags=tags, content_type=content_type)
        request_body = SERIALIZE.body(secret, 'SecretSetParameters')

        request = HttpRequest('PUT', url, headers, data=request_body)

        request.format_parameters(query_parameters)

        response = self._pipeline.run(request, **kwargs).http_response

        if response.status_code != 200:
            raise ClientRequestError('Request failed status code {}.  {}'.format(
                response.status_code, response.text()))

        bundle = DESERIALIZE('SecretBundle', response)

        return Secret._from_secret_bundle(bundle)