Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
'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
if response.status_code != 200:
raise ClientRequestError('Request failed status code {}. {}'.format(response.status_code, response.text()))
bundle = DESERIALIZE('SecretBundle', response)
return SecretAttributes._from_secret_bundle(bundle)
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)
headers = {
'Content-Type': 'application/json; charset=utf-8',
'x-ms-client-request-id': str(uuid.uuid1())
}
request = HttpRequest('GET', url, headers)
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)
'x-ms-client-request-id': str(uuid.uuid1())
}
restore_parameters = SecretRestoreParameters(secret_bundle_backup=backup)
request_body = SERIALIZE.body(restore_parameters, 'SecretRestoreParameters')
request = HttpRequest('POST', 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 SecretAttributes._from_secret_bundle(bundle)
:start-after: [START get_deleted_secret]
:end-before: [END get_deleted_secret]
:language: python
:dedent: 4
:caption: Gets the deleted secret
"""
url = "/".join([self.vault_url, "deletedsecrets", name])
request = HttpRequest('GET', url)
request.format_parameters({'api-version': self._api_version})
response = self._pipeline.run(request, **kwargs).http_response
if response.status_code != 200:
raise ClientRequestError("Request failed with code {}: '{}'".format(response.status_code, response.text()))
bundle = DESERIALIZE('DeletedSecretBundle', response)
return DeletedSecret._from_deleted_secret_bundle(bundle)
:start-after: [START delete_secret]
:end-before: [END delete_secret]
:language: python
:dedent: 4
:caption: Deletes a secret
"""
url = '/'.join([self._vault_url, 'secrets', name])
request = HttpRequest('DELETE', url)
request.format_parameters({'api-version': self._api_version})
response = self._pipeline.run(request, **kwargs).http_response
if response.status_code != 200:
raise ClientRequestError("Request failed with code {}: '{}'".format(response.status_code, response.text()))
bundle = DESERIALIZE('DeletedSecretBundle', response)
return DeletedSecret._from_deleted_secret_bundle(bundle)
headers = {
'Content-Type': 'application/json; charset=utf-8',
'x-ms-client-request-id': str(uuid.uuid1())
}
request = HttpRequest('POST', url, headers)
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()))
result = DESERIALIZE('BackupSecretResult', response)
return result.value
:end-before: [END recover_deleted_secret]
:language: python
:dedent: 4
:caption: Restores a backed up secret to the vault
"""
url = "/".join([self.vault_url, "deletedsecrets", name, "recover"])
request = HttpRequest('POST', url)
request.format_parameters({'api-version': self._api_version})
response = self._pipeline.run(request, **kwargs).http_response
if response.status_code != 200:
raise ClientRequestError("Request failed with code {}: '{}'".format(response.status_code, response.text()))
bundle = DESERIALIZE('SecretBundle', response)
return SecretAttributes._from_secret_bundle(bundle)