code
stringlengths
26
870k
docstring
stringlengths
1
65.6k
func_name
stringlengths
1
194
language
stringclasses
1 value
repo
stringlengths
8
68
path
stringlengths
5
194
url
stringlengths
46
254
license
stringclasses
4 values
def serialize_xml(model: Model, exclude_readonly: bool = False) -> str: """Serialize a model to XML. :param Model model: The model to serialize. :param bool exclude_readonly: Whether to exclude readonly properties. :returns: The XML representation of the model. :rtype: str """ return ET.tostring(_get_element(model, exclude_readonly), encoding="unicode") # type: ignore
Serialize a model to XML. :param Model model: The model to serialize. :param bool exclude_readonly: Whether to exclude readonly properties. :returns: The XML representation of the model. :rtype: str
serialize_xml
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_model_base.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_model_base.py
MIT
def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") <HttpRequest [GET], url: 'https://www.example.org/'> >>> response = client.send_request(request) <HttpResponse: 200 OK> For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. :rtype: ~azure.core.rest.HttpResponse """ request_copy = deepcopy(request) path_format_arguments = { "vaultBaseUrl": self._serialize.url( "self._config.vault_base_url", self._config.vault_base_url, "str", skip_quote=True ), } request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore
Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") <HttpRequest [GET], url: 'https://www.example.org/'> >>> response = client.send_request(request) <HttpResponse: 200 OK> For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. :rtype: ~azure.core.rest.HttpResponse
send_request
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_client.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_client.py
MIT
async def begin_download( self, certificate_info_object: Union[CertificateInfoObject, JSON, IO[bytes]], *, content_type: str = "application/json", polling: Optional[Literal[False]] = None, **kwargs: Any, ) -> AsyncLROPoller[SecurityDomainObject]: """Retrieves the Security Domain from the managed HSM. Calling this endpoint can be used to activate a provisioned managed HSM resource. :param certificate_info_object: The Security Domain download operation requires the customer to provide N certificates (minimum 3 and maximum 10) containing a public key in JWK format. Required in one of the following types: CertificateInfoObject, JSON, or IO[bytes]. :type certificate_info_object: ~azure.keyvault.securitydomain.models.CertificateInfoObject or JSON or IO[bytes] :keyword str content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :keyword bool polling: If set to False, the operation will not poll for completion and calling `.result()` on the poller will return the security domain object immediately. Default value is None. :return: An instance of AsyncLROPoller that returns SecurityDomainObject. The SecurityDomainObject is compatible with MutableMapping :rtype: ~azure.core.polling.AsyncLROPoller[~azure.keyvault.securitydomain.models.SecurityDomainObject] :raises ~azure.core.exceptions.HttpResponseError: """ delay = kwargs.pop("polling_interval", self._config.polling_interval) polling_method = ( AsyncSecurityDomainDownloadNoPolling() if polling is False else AsyncSecurityDomainDownloadPollingMethod( lro_algorithms=[SecurityDomainDownloadPolling()], timeout=delay ) ) return await super().begin_download( # type: ignore[return-value] certificate_info_object, content_type=content_type, polling=polling_method, **kwargs, )
Retrieves the Security Domain from the managed HSM. Calling this endpoint can be used to activate a provisioned managed HSM resource. :param certificate_info_object: The Security Domain download operation requires the customer to provide N certificates (minimum 3 and maximum 10) containing a public key in JWK format. Required in one of the following types: CertificateInfoObject, JSON, or IO[bytes]. :type certificate_info_object: ~azure.keyvault.securitydomain.models.CertificateInfoObject or JSON or IO[bytes] :keyword str content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :keyword bool polling: If set to False, the operation will not poll for completion and calling `.result()` on the poller will return the security domain object immediately. Default value is None. :return: An instance of AsyncLROPoller that returns SecurityDomainObject. The SecurityDomainObject is compatible with MutableMapping :rtype: ~azure.core.polling.AsyncLROPoller[~azure.keyvault.securitydomain.models.SecurityDomainObject] :raises ~azure.core.exceptions.HttpResponseError:
begin_download
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/aio/_patch.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/aio/_patch.py
MIT
async def begin_upload( self, security_domain: Union[SecurityDomainObject, JSON, IO[bytes]], *, content_type: str = "application/json", polling: Optional[Literal[False]] = None, **kwargs: Any, ) -> AsyncLROPoller[SecurityDomainOperationStatus]: """Restore the provided Security Domain. :param security_domain: The Security Domain to be restored. Required in one of the following types: SecurityDomainObject, JSON, or IO[bytes]. :type security_domain: ~azure.keyvault.securitydomain.models.SecurityDomainObject or JSON or IO[bytes] :keyword str content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :keyword bool polling: If set to False, the operation will not poll for completion and calling `.result()` on the poller will return the initial response immediately. Default value is None. :return: An instance of AsyncLROPoller that returns SecurityDomainOperationStatus. The SecurityDomainOperationStatus is compatible with MutableMapping :rtype: ~azure.core.polling.AsyncLROPoller[~azure.keyvault.securitydomain.models.SecurityDomainOperationStatus] :raises ~azure.core.exceptions.HttpResponseError: """ delay = kwargs.pop("polling_interval", self._config.polling_interval) polling_method = ( AsyncSecurityDomainUploadNoPolling() if polling is False else AsyncSecurityDomainUploadPollingMethod(lro_algorithms=[SecurityDomainUploadPolling()], timeout=delay) ) return await super().begin_upload( security_domain, content_type=content_type, polling=polling_method, **kwargs, )
Restore the provided Security Domain. :param security_domain: The Security Domain to be restored. Required in one of the following types: SecurityDomainObject, JSON, or IO[bytes]. :type security_domain: ~azure.keyvault.securitydomain.models.SecurityDomainObject or JSON or IO[bytes] :keyword str content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :keyword bool polling: If set to False, the operation will not poll for completion and calling `.result()` on the poller will return the initial response immediately. Default value is None. :return: An instance of AsyncLROPoller that returns SecurityDomainOperationStatus. The SecurityDomainOperationStatus is compatible with MutableMapping :rtype: ~azure.core.polling.AsyncLROPoller[~azure.keyvault.securitydomain.models.SecurityDomainOperationStatus] :raises ~azure.core.exceptions.HttpResponseError:
begin_upload
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/aio/_patch.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/aio/_patch.py
MIT
def send_request( self, request: HttpRequest, *, stream: bool = False, **kwargs: Any ) -> Awaitable[AsyncHttpResponse]: """Runs a network request using the client's existing pipeline. The request URL can be relative to the vault URL. The service API version used for the request is the same as the client's unless otherwise specified. This method does not raise if the response is an error; to raise an exception, call `raise_for_status()` on the returned response object. For more information about how to send custom requests with this method, see https://aka.ms/azsdk/dpcodegen/python/send_request. :param request: The network request you want to make. :type request: ~azure.core.rest.HttpRequest :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. :rtype: ~azure.core.rest.AsyncHttpResponse """ request_copy = _format_api_version(request, self.api_version) path_format_arguments = { "vaultBaseUrl": _SERIALIZER.url("vault_base_url", self._vault_url, "str", skip_quote=True), } request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) return self._client.send_request(request_copy, stream=stream, **kwargs)
Runs a network request using the client's existing pipeline. The request URL can be relative to the vault URL. The service API version used for the request is the same as the client's unless otherwise specified. This method does not raise if the response is an error; to raise an exception, call `raise_for_status()` on the returned response object. For more information about how to send custom requests with this method, see https://aka.ms/azsdk/dpcodegen/python/send_request. :param request: The network request you want to make. :type request: ~azure.core.rest.HttpRequest :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. :rtype: ~azure.core.rest.AsyncHttpResponse
send_request
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/aio/_patch.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/aio/_patch.py
MIT
def patch_sdk(): """Do not remove from this file. `patch_sdk` is a last resort escape hatch that allows you to do customizations you can't accomplish using the techniques described in https://aka.ms/azsdk/python/dpcodegen/python/customize """
Do not remove from this file. `patch_sdk` is a last resort escape hatch that allows you to do customizations you can't accomplish using the techniques described in https://aka.ms/azsdk/python/dpcodegen/python/customize
patch_sdk
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/aio/_patch.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/aio/_patch.py
MIT
def send_request( self, request: HttpRequest, *, stream: bool = False, **kwargs: Any ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") <HttpRequest [GET], url: 'https://www.example.org/'> >>> response = await client.send_request(request) <AsyncHttpResponse: 200 OK> For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. :rtype: ~azure.core.rest.AsyncHttpResponse """ request_copy = deepcopy(request) path_format_arguments = { "vaultBaseUrl": self._serialize.url( "self._config.vault_base_url", self._config.vault_base_url, "str", skip_quote=True ), } request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments) return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore
Runs the network request through the client's chained policies. >>> from azure.core.rest import HttpRequest >>> request = HttpRequest("GET", "https://www.example.org/") <HttpRequest [GET], url: 'https://www.example.org/'> >>> response = await client.send_request(request) <AsyncHttpResponse: 200 OK> For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request :param request: The network request you want to make. Required. :type request: ~azure.core.rest.HttpRequest :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. :rtype: ~azure.core.rest.AsyncHttpResponse
send_request
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/aio/_client.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/aio/_client.py
MIT
async def download_pending(self, **kwargs: Any) -> _models.SecurityDomainOperationStatus: """Retrieves the Security Domain download operation status. :return: SecurityDomainOperationStatus. The SecurityDomainOperationStatus is compatible with MutableMapping :rtype: ~azure.keyvault.securitydomain.models.SecurityDomainOperationStatus :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} cls: ClsType[_models.SecurityDomainOperationStatus] = kwargs.pop("cls", None) _request = build_hsm_security_domain_download_pending_request( api_version=self._config.api_version, headers=_headers, params=_params, ) path_format_arguments = { "vaultBaseUrl": self._serialize.url( "self._config.vault_base_url", self._config.vault_base_url, "str", skip_quote=True ), } _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: if _stream: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) if _stream: deserialized = response.iter_bytes() else: deserialized = _deserialize(_models.SecurityDomainOperationStatus, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
Retrieves the Security Domain download operation status. :return: SecurityDomainOperationStatus. The SecurityDomainOperationStatus is compatible with MutableMapping :rtype: ~azure.keyvault.securitydomain.models.SecurityDomainOperationStatus :raises ~azure.core.exceptions.HttpResponseError:
download_pending
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/aio/operations/_operations.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/aio/operations/_operations.py
MIT
async def begin_download( self, certificate_info_object: _models.CertificateInfoObject, *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.SecurityDomainOperationStatus]: """Retrieves the Security Domain from the managed HSM. Calling this endpoint can be used to activate a provisioned managed HSM resource. :param certificate_info_object: The Security Domain download operation requires customer to provide N certificates (minimum 3 and maximum 10) containing a public key in JWK format. Required. :type certificate_info_object: ~azure.keyvault.securitydomain.models.CertificateInfoObject :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of AsyncLROPoller that returns SecurityDomainOperationStatus. The SecurityDomainOperationStatus is compatible with MutableMapping :rtype: ~azure.core.polling.AsyncLROPoller[~azure.keyvault.securitydomain.models.SecurityDomainOperationStatus] :raises ~azure.core.exceptions.HttpResponseError: """
Retrieves the Security Domain from the managed HSM. Calling this endpoint can be used to activate a provisioned managed HSM resource. :param certificate_info_object: The Security Domain download operation requires customer to provide N certificates (minimum 3 and maximum 10) containing a public key in JWK format. Required. :type certificate_info_object: ~azure.keyvault.securitydomain.models.CertificateInfoObject :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of AsyncLROPoller that returns SecurityDomainOperationStatus. The SecurityDomainOperationStatus is compatible with MutableMapping :rtype: ~azure.core.polling.AsyncLROPoller[~azure.keyvault.securitydomain.models.SecurityDomainOperationStatus] :raises ~azure.core.exceptions.HttpResponseError:
begin_download
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/aio/operations/_operations.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/aio/operations/_operations.py
MIT
async def begin_download( self, certificate_info_object: JSON, *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.SecurityDomainOperationStatus]: """Retrieves the Security Domain from the managed HSM. Calling this endpoint can be used to activate a provisioned managed HSM resource. :param certificate_info_object: The Security Domain download operation requires customer to provide N certificates (minimum 3 and maximum 10) containing a public key in JWK format. Required. :type certificate_info_object: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of AsyncLROPoller that returns SecurityDomainOperationStatus. The SecurityDomainOperationStatus is compatible with MutableMapping :rtype: ~azure.core.polling.AsyncLROPoller[~azure.keyvault.securitydomain.models.SecurityDomainOperationStatus] :raises ~azure.core.exceptions.HttpResponseError: """
Retrieves the Security Domain from the managed HSM. Calling this endpoint can be used to activate a provisioned managed HSM resource. :param certificate_info_object: The Security Domain download operation requires customer to provide N certificates (minimum 3 and maximum 10) containing a public key in JWK format. Required. :type certificate_info_object: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of AsyncLROPoller that returns SecurityDomainOperationStatus. The SecurityDomainOperationStatus is compatible with MutableMapping :rtype: ~azure.core.polling.AsyncLROPoller[~azure.keyvault.securitydomain.models.SecurityDomainOperationStatus] :raises ~azure.core.exceptions.HttpResponseError:
begin_download
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/aio/operations/_operations.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/aio/operations/_operations.py
MIT
async def begin_download( self, certificate_info_object: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.SecurityDomainOperationStatus]: """Retrieves the Security Domain from the managed HSM. Calling this endpoint can be used to activate a provisioned managed HSM resource. :param certificate_info_object: The Security Domain download operation requires customer to provide N certificates (minimum 3 and maximum 10) containing a public key in JWK format. Required. :type certificate_info_object: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: An instance of AsyncLROPoller that returns SecurityDomainOperationStatus. The SecurityDomainOperationStatus is compatible with MutableMapping :rtype: ~azure.core.polling.AsyncLROPoller[~azure.keyvault.securitydomain.models.SecurityDomainOperationStatus] :raises ~azure.core.exceptions.HttpResponseError: """
Retrieves the Security Domain from the managed HSM. Calling this endpoint can be used to activate a provisioned managed HSM resource. :param certificate_info_object: The Security Domain download operation requires customer to provide N certificates (minimum 3 and maximum 10) containing a public key in JWK format. Required. :type certificate_info_object: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: An instance of AsyncLROPoller that returns SecurityDomainOperationStatus. The SecurityDomainOperationStatus is compatible with MutableMapping :rtype: ~azure.core.polling.AsyncLROPoller[~azure.keyvault.securitydomain.models.SecurityDomainOperationStatus] :raises ~azure.core.exceptions.HttpResponseError:
begin_download
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/aio/operations/_operations.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/aio/operations/_operations.py
MIT
async def begin_download( self, certificate_info_object: Union[_models.CertificateInfoObject, JSON, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.SecurityDomainOperationStatus]: """Retrieves the Security Domain from the managed HSM. Calling this endpoint can be used to activate a provisioned managed HSM resource. :param certificate_info_object: The Security Domain download operation requires customer to provide N certificates (minimum 3 and maximum 10) containing a public key in JWK format. Is one of the following types: CertificateInfoObject, JSON, IO[bytes] Required. :type certificate_info_object: ~azure.keyvault.securitydomain.models.CertificateInfoObject or JSON or IO[bytes] :return: An instance of AsyncLROPoller that returns SecurityDomainOperationStatus. The SecurityDomainOperationStatus is compatible with MutableMapping :rtype: ~azure.core.polling.AsyncLROPoller[~azure.keyvault.securitydomain.models.SecurityDomainOperationStatus] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SecurityDomainOperationStatus] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._download_initial( certificate_info_object=certificate_info_object, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): response_headers = {} response = pipeline_response.http_response response_headers["Azure-AsyncOperation"] = self._deserialize( "str", response.headers.get("Azure-AsyncOperation") ) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = _deserialize(_models.SecurityDomainOperationStatus, response.json()) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized path_format_arguments = { "vaultBaseUrl": self._serialize.url( "self._config.vault_base_url", self._config.vault_base_url, "str", skip_quote=True ), } if polling is True: polling_method: AsyncPollingMethod = cast( AsyncPollingMethod, AsyncLROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs), ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller[_models.SecurityDomainOperationStatus].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return AsyncLROPoller[_models.SecurityDomainOperationStatus]( self._client, raw_result, get_long_running_output, polling_method # type: ignore )
Retrieves the Security Domain from the managed HSM. Calling this endpoint can be used to activate a provisioned managed HSM resource. :param certificate_info_object: The Security Domain download operation requires customer to provide N certificates (minimum 3 and maximum 10) containing a public key in JWK format. Is one of the following types: CertificateInfoObject, JSON, IO[bytes] Required. :type certificate_info_object: ~azure.keyvault.securitydomain.models.CertificateInfoObject or JSON or IO[bytes] :return: An instance of AsyncLROPoller that returns SecurityDomainOperationStatus. The SecurityDomainOperationStatus is compatible with MutableMapping :rtype: ~azure.core.polling.AsyncLROPoller[~azure.keyvault.securitydomain.models.SecurityDomainOperationStatus] :raises ~azure.core.exceptions.HttpResponseError:
begin_download
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/aio/operations/_operations.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/aio/operations/_operations.py
MIT
async def transfer_key(self, **kwargs: Any) -> _models.TransferKey: """Retrieve Security Domain transfer key. :return: TransferKey. The TransferKey is compatible with MutableMapping :rtype: ~azure.keyvault.securitydomain.models.TransferKey :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} cls: ClsType[_models.TransferKey] = kwargs.pop("cls", None) _request = build_hsm_security_domain_transfer_key_request( api_version=self._config.api_version, headers=_headers, params=_params, ) path_format_arguments = { "vaultBaseUrl": self._serialize.url( "self._config.vault_base_url", self._config.vault_base_url, "str", skip_quote=True ), } _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: if _stream: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) if _stream: deserialized = response.iter_bytes() else: deserialized = _deserialize(_models.TransferKey, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
Retrieve Security Domain transfer key. :return: TransferKey. The TransferKey is compatible with MutableMapping :rtype: ~azure.keyvault.securitydomain.models.TransferKey :raises ~azure.core.exceptions.HttpResponseError:
transfer_key
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/aio/operations/_operations.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/aio/operations/_operations.py
MIT
async def begin_upload( self, security_domain: _models.SecurityDomainObject, *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.SecurityDomainOperationStatus]: """Restore the provided Security Domain. :param security_domain: The Security Domain to be restored. Required. :type security_domain: ~azure.keyvault.securitydomain.models.SecurityDomainObject :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of AsyncLROPoller that returns SecurityDomainOperationStatus. The SecurityDomainOperationStatus is compatible with MutableMapping :rtype: ~azure.core.polling.AsyncLROPoller[~azure.keyvault.securitydomain.models.SecurityDomainOperationStatus] :raises ~azure.core.exceptions.HttpResponseError: """
Restore the provided Security Domain. :param security_domain: The Security Domain to be restored. Required. :type security_domain: ~azure.keyvault.securitydomain.models.SecurityDomainObject :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of AsyncLROPoller that returns SecurityDomainOperationStatus. The SecurityDomainOperationStatus is compatible with MutableMapping :rtype: ~azure.core.polling.AsyncLROPoller[~azure.keyvault.securitydomain.models.SecurityDomainOperationStatus] :raises ~azure.core.exceptions.HttpResponseError:
begin_upload
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/aio/operations/_operations.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/aio/operations/_operations.py
MIT
async def begin_upload( self, security_domain: JSON, *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.SecurityDomainOperationStatus]: """Restore the provided Security Domain. :param security_domain: The Security Domain to be restored. Required. :type security_domain: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of AsyncLROPoller that returns SecurityDomainOperationStatus. The SecurityDomainOperationStatus is compatible with MutableMapping :rtype: ~azure.core.polling.AsyncLROPoller[~azure.keyvault.securitydomain.models.SecurityDomainOperationStatus] :raises ~azure.core.exceptions.HttpResponseError: """
Restore the provided Security Domain. :param security_domain: The Security Domain to be restored. Required. :type security_domain: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of AsyncLROPoller that returns SecurityDomainOperationStatus. The SecurityDomainOperationStatus is compatible with MutableMapping :rtype: ~azure.core.polling.AsyncLROPoller[~azure.keyvault.securitydomain.models.SecurityDomainOperationStatus] :raises ~azure.core.exceptions.HttpResponseError:
begin_upload
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/aio/operations/_operations.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/aio/operations/_operations.py
MIT
async def begin_upload( self, security_domain: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.SecurityDomainOperationStatus]: """Restore the provided Security Domain. :param security_domain: The Security Domain to be restored. Required. :type security_domain: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: An instance of AsyncLROPoller that returns SecurityDomainOperationStatus. The SecurityDomainOperationStatus is compatible with MutableMapping :rtype: ~azure.core.polling.AsyncLROPoller[~azure.keyvault.securitydomain.models.SecurityDomainOperationStatus] :raises ~azure.core.exceptions.HttpResponseError: """
Restore the provided Security Domain. :param security_domain: The Security Domain to be restored. Required. :type security_domain: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: An instance of AsyncLROPoller that returns SecurityDomainOperationStatus. The SecurityDomainOperationStatus is compatible with MutableMapping :rtype: ~azure.core.polling.AsyncLROPoller[~azure.keyvault.securitydomain.models.SecurityDomainOperationStatus] :raises ~azure.core.exceptions.HttpResponseError:
begin_upload
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/aio/operations/_operations.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/aio/operations/_operations.py
MIT
async def begin_upload( self, security_domain: Union[_models.SecurityDomainObject, JSON, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.SecurityDomainOperationStatus]: """Restore the provided Security Domain. :param security_domain: The Security Domain to be restored. Is one of the following types: SecurityDomainObject, JSON, IO[bytes] Required. :type security_domain: ~azure.keyvault.securitydomain.models.SecurityDomainObject or JSON or IO[bytes] :return: An instance of AsyncLROPoller that returns SecurityDomainOperationStatus. The SecurityDomainOperationStatus is compatible with MutableMapping :rtype: ~azure.core.polling.AsyncLROPoller[~azure.keyvault.securitydomain.models.SecurityDomainOperationStatus] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SecurityDomainOperationStatus] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._upload_initial( security_domain=security_domain, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): response_headers = {} response = pipeline_response.http_response response_headers["Azure-AsyncOperation"] = self._deserialize( "str", response.headers.get("Azure-AsyncOperation") ) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = _deserialize(_models.SecurityDomainOperationStatus, response.json()) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized path_format_arguments = { "vaultBaseUrl": self._serialize.url( "self._config.vault_base_url", self._config.vault_base_url, "str", skip_quote=True ), } if polling is True: polling_method: AsyncPollingMethod = cast( AsyncPollingMethod, AsyncLROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs), ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller[_models.SecurityDomainOperationStatus].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return AsyncLROPoller[_models.SecurityDomainOperationStatus]( self._client, raw_result, get_long_running_output, polling_method # type: ignore )
Restore the provided Security Domain. :param security_domain: The Security Domain to be restored. Is one of the following types: SecurityDomainObject, JSON, IO[bytes] Required. :type security_domain: ~azure.keyvault.securitydomain.models.SecurityDomainObject or JSON or IO[bytes] :return: An instance of AsyncLROPoller that returns SecurityDomainOperationStatus. The SecurityDomainOperationStatus is compatible with MutableMapping :rtype: ~azure.core.polling.AsyncLROPoller[~azure.keyvault.securitydomain.models.SecurityDomainOperationStatus] :raises ~azure.core.exceptions.HttpResponseError:
begin_upload
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/aio/operations/_operations.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/aio/operations/_operations.py
MIT
async def upload_pending(self, **kwargs: Any) -> _models.SecurityDomainOperationStatus: """Get Security Domain upload operation status. :return: SecurityDomainOperationStatus. The SecurityDomainOperationStatus is compatible with MutableMapping :rtype: ~azure.keyvault.securitydomain.models.SecurityDomainOperationStatus :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} cls: ClsType[_models.SecurityDomainOperationStatus] = kwargs.pop("cls", None) _request = build_hsm_security_domain_upload_pending_request( api_version=self._config.api_version, headers=_headers, params=_params, ) path_format_arguments = { "vaultBaseUrl": self._serialize.url( "self._config.vault_base_url", self._config.vault_base_url, "str", skip_quote=True ), } _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: if _stream: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) if _stream: deserialized = response.iter_bytes() else: deserialized = _deserialize(_models.SecurityDomainOperationStatus, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
Get Security Domain upload operation status. :return: SecurityDomainOperationStatus. The SecurityDomainOperationStatus is compatible with MutableMapping :rtype: ~azure.keyvault.securitydomain.models.SecurityDomainOperationStatus :raises ~azure.core.exceptions.HttpResponseError:
upload_pending
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/aio/operations/_operations.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/aio/operations/_operations.py
MIT
def patch_sdk(): """Do not remove from this file. `patch_sdk` is a last resort escape hatch that allows you to do customizations you can't accomplish using the techniques described in https://aka.ms/azsdk/python/dpcodegen/python/customize """
Do not remove from this file. `patch_sdk` is a last resort escape hatch that allows you to do customizations you can't accomplish using the techniques described in https://aka.ms/azsdk/python/dpcodegen/python/customize
patch_sdk
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/aio/operations/_patch.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/aio/operations/_patch.py
MIT
async def get_download_status(self, **kwargs: Any) -> _models.SecurityDomainOperationStatus: """Retrieves the Security Domain download operation status. :return: SecurityDomainOperationStatus. The SecurityDomainOperationStatus is compatible with MutableMapping :rtype: ~azure.keyvault.securitydomain.models.SecurityDomainOperationStatus :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} cls: ClsType[_models.SecurityDomainOperationStatus] = kwargs.pop("cls", None) _request = build_key_vault_get_download_status_request( api_version=self._config.api_version, headers=_headers, params=_params, ) path_format_arguments = { "vaultBaseUrl": self._serialize.url( "self._config.vault_base_url", self._config.vault_base_url, "str", skip_quote=True ), } _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: if _stream: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) if _stream: deserialized = response.iter_bytes() else: deserialized = _deserialize(_models.SecurityDomainOperationStatus, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
Retrieves the Security Domain download operation status. :return: SecurityDomainOperationStatus. The SecurityDomainOperationStatus is compatible with MutableMapping :rtype: ~azure.keyvault.securitydomain.models.SecurityDomainOperationStatus :raises ~azure.core.exceptions.HttpResponseError:
get_download_status
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/aio/_operations/_operations.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/aio/_operations/_operations.py
MIT
async def begin_download( self, certificate_info_object: _models.CertificateInfoObject, *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[None]: """Retrieves the Security Domain from the managed HSM. Calling this endpoint can be used to activate a provisioned managed HSM resource. :param certificate_info_object: The Security Domain download operation requires customer to provide N certificates (minimum 3 and maximum 10) containing a public key in JWK format. Required. :type certificate_info_object: ~azure.keyvault.securitydomain.models.CertificateInfoObject :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of AsyncLROPoller that returns None :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """
Retrieves the Security Domain from the managed HSM. Calling this endpoint can be used to activate a provisioned managed HSM resource. :param certificate_info_object: The Security Domain download operation requires customer to provide N certificates (minimum 3 and maximum 10) containing a public key in JWK format. Required. :type certificate_info_object: ~azure.keyvault.securitydomain.models.CertificateInfoObject :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of AsyncLROPoller that returns None :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError:
begin_download
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/aio/_operations/_operations.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/aio/_operations/_operations.py
MIT
async def begin_download( self, certificate_info_object: JSON, *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[None]: """Retrieves the Security Domain from the managed HSM. Calling this endpoint can be used to activate a provisioned managed HSM resource. :param certificate_info_object: The Security Domain download operation requires customer to provide N certificates (minimum 3 and maximum 10) containing a public key in JWK format. Required. :type certificate_info_object: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of AsyncLROPoller that returns None :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """
Retrieves the Security Domain from the managed HSM. Calling this endpoint can be used to activate a provisioned managed HSM resource. :param certificate_info_object: The Security Domain download operation requires customer to provide N certificates (minimum 3 and maximum 10) containing a public key in JWK format. Required. :type certificate_info_object: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of AsyncLROPoller that returns None :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError:
begin_download
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/aio/_operations/_operations.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/aio/_operations/_operations.py
MIT
async def begin_download( self, certificate_info_object: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[None]: """Retrieves the Security Domain from the managed HSM. Calling this endpoint can be used to activate a provisioned managed HSM resource. :param certificate_info_object: The Security Domain download operation requires customer to provide N certificates (minimum 3 and maximum 10) containing a public key in JWK format. Required. :type certificate_info_object: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: An instance of AsyncLROPoller that returns None :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """
Retrieves the Security Domain from the managed HSM. Calling this endpoint can be used to activate a provisioned managed HSM resource. :param certificate_info_object: The Security Domain download operation requires customer to provide N certificates (minimum 3 and maximum 10) containing a public key in JWK format. Required. :type certificate_info_object: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: An instance of AsyncLROPoller that returns None :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError:
begin_download
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/aio/_operations/_operations.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/aio/_operations/_operations.py
MIT
async def begin_download( self, certificate_info_object: Union[_models.CertificateInfoObject, JSON, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[None]: """Retrieves the Security Domain from the managed HSM. Calling this endpoint can be used to activate a provisioned managed HSM resource. :param certificate_info_object: The Security Domain download operation requires customer to provide N certificates (minimum 3 and maximum 10) containing a public key in JWK format. Is one of the following types: CertificateInfoObject, JSON, IO[bytes] Required. :type certificate_info_object: ~azure.keyvault.securitydomain.models.CertificateInfoObject or JSON or IO[bytes] :return: An instance of AsyncLROPoller that returns None :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._download_initial( certificate_info_object=certificate_info_object, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) # type: ignore path_format_arguments = { "vaultBaseUrl": self._serialize.url( "self._config.vault_base_url", self._config.vault_base_url, "str", skip_quote=True ), } if polling is True: polling_method: AsyncPollingMethod = cast( AsyncPollingMethod, AsyncLROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs), ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore
Retrieves the Security Domain from the managed HSM. Calling this endpoint can be used to activate a provisioned managed HSM resource. :param certificate_info_object: The Security Domain download operation requires customer to provide N certificates (minimum 3 and maximum 10) containing a public key in JWK format. Is one of the following types: CertificateInfoObject, JSON, IO[bytes] Required. :type certificate_info_object: ~azure.keyvault.securitydomain.models.CertificateInfoObject or JSON or IO[bytes] :return: An instance of AsyncLROPoller that returns None :rtype: ~azure.core.polling.AsyncLROPoller[None] :raises ~azure.core.exceptions.HttpResponseError:
begin_download
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/aio/_operations/_operations.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/aio/_operations/_operations.py
MIT
async def get_upload_status(self, **kwargs: Any) -> _models.SecurityDomainOperationStatus: """Get Security Domain upload operation status. :return: SecurityDomainOperationStatus. The SecurityDomainOperationStatus is compatible with MutableMapping :rtype: ~azure.keyvault.securitydomain.models.SecurityDomainOperationStatus :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} cls: ClsType[_models.SecurityDomainOperationStatus] = kwargs.pop("cls", None) _request = build_key_vault_get_upload_status_request( api_version=self._config.api_version, headers=_headers, params=_params, ) path_format_arguments = { "vaultBaseUrl": self._serialize.url( "self._config.vault_base_url", self._config.vault_base_url, "str", skip_quote=True ), } _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: if _stream: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) if _stream: deserialized = response.iter_bytes() else: deserialized = _deserialize(_models.SecurityDomainOperationStatus, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
Get Security Domain upload operation status. :return: SecurityDomainOperationStatus. The SecurityDomainOperationStatus is compatible with MutableMapping :rtype: ~azure.keyvault.securitydomain.models.SecurityDomainOperationStatus :raises ~azure.core.exceptions.HttpResponseError:
get_upload_status
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/aio/_operations/_operations.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/aio/_operations/_operations.py
MIT
async def begin_upload( self, security_domain: _models.SecurityDomainObject, *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.SecurityDomainOperationStatus]: """Restore the provided Security Domain. :param security_domain: The Security Domain to be restored. Required. :type security_domain: ~azure.keyvault.securitydomain.models.SecurityDomainObject :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of AsyncLROPoller that returns SecurityDomainOperationStatus. The SecurityDomainOperationStatus is compatible with MutableMapping :rtype: ~azure.core.polling.AsyncLROPoller[~azure.keyvault.securitydomain.models.SecurityDomainOperationStatus] :raises ~azure.core.exceptions.HttpResponseError: """
Restore the provided Security Domain. :param security_domain: The Security Domain to be restored. Required. :type security_domain: ~azure.keyvault.securitydomain.models.SecurityDomainObject :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of AsyncLROPoller that returns SecurityDomainOperationStatus. The SecurityDomainOperationStatus is compatible with MutableMapping :rtype: ~azure.core.polling.AsyncLROPoller[~azure.keyvault.securitydomain.models.SecurityDomainOperationStatus] :raises ~azure.core.exceptions.HttpResponseError:
begin_upload
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/aio/_operations/_operations.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/aio/_operations/_operations.py
MIT
async def begin_upload( self, security_domain: JSON, *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.SecurityDomainOperationStatus]: """Restore the provided Security Domain. :param security_domain: The Security Domain to be restored. Required. :type security_domain: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of AsyncLROPoller that returns SecurityDomainOperationStatus. The SecurityDomainOperationStatus is compatible with MutableMapping :rtype: ~azure.core.polling.AsyncLROPoller[~azure.keyvault.securitydomain.models.SecurityDomainOperationStatus] :raises ~azure.core.exceptions.HttpResponseError: """
Restore the provided Security Domain. :param security_domain: The Security Domain to be restored. Required. :type security_domain: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of AsyncLROPoller that returns SecurityDomainOperationStatus. The SecurityDomainOperationStatus is compatible with MutableMapping :rtype: ~azure.core.polling.AsyncLROPoller[~azure.keyvault.securitydomain.models.SecurityDomainOperationStatus] :raises ~azure.core.exceptions.HttpResponseError:
begin_upload
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/aio/_operations/_operations.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/aio/_operations/_operations.py
MIT
async def begin_upload( self, security_domain: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> AsyncLROPoller[_models.SecurityDomainOperationStatus]: """Restore the provided Security Domain. :param security_domain: The Security Domain to be restored. Required. :type security_domain: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: An instance of AsyncLROPoller that returns SecurityDomainOperationStatus. The SecurityDomainOperationStatus is compatible with MutableMapping :rtype: ~azure.core.polling.AsyncLROPoller[~azure.keyvault.securitydomain.models.SecurityDomainOperationStatus] :raises ~azure.core.exceptions.HttpResponseError: """
Restore the provided Security Domain. :param security_domain: The Security Domain to be restored. Required. :type security_domain: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: An instance of AsyncLROPoller that returns SecurityDomainOperationStatus. The SecurityDomainOperationStatus is compatible with MutableMapping :rtype: ~azure.core.polling.AsyncLROPoller[~azure.keyvault.securitydomain.models.SecurityDomainOperationStatus] :raises ~azure.core.exceptions.HttpResponseError:
begin_upload
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/aio/_operations/_operations.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/aio/_operations/_operations.py
MIT
async def begin_upload( self, security_domain: Union[_models.SecurityDomainObject, JSON, IO[bytes]], **kwargs: Any ) -> AsyncLROPoller[_models.SecurityDomainOperationStatus]: """Restore the provided Security Domain. :param security_domain: The Security Domain to be restored. Is one of the following types: SecurityDomainObject, JSON, IO[bytes] Required. :type security_domain: ~azure.keyvault.securitydomain.models.SecurityDomainObject or JSON or IO[bytes] :return: An instance of AsyncLROPoller that returns SecurityDomainOperationStatus. The SecurityDomainOperationStatus is compatible with MutableMapping :rtype: ~azure.core.polling.AsyncLROPoller[~azure.keyvault.securitydomain.models.SecurityDomainOperationStatus] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SecurityDomainOperationStatus] = kwargs.pop("cls", None) polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = await self._upload_initial( security_domain=security_domain, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) await raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): response_headers = {} response = pipeline_response.http_response response_headers["Azure-AsyncOperation"] = self._deserialize( "str", response.headers.get("Azure-AsyncOperation") ) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = _deserialize(_models.SecurityDomainOperationStatus, response.json()) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized path_format_arguments = { "vaultBaseUrl": self._serialize.url( "self._config.vault_base_url", self._config.vault_base_url, "str", skip_quote=True ), } if polling is True: polling_method: AsyncPollingMethod = cast( AsyncPollingMethod, AsyncLROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs), ) elif polling is False: polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) else: polling_method = polling if cont_token: return AsyncLROPoller[_models.SecurityDomainOperationStatus].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return AsyncLROPoller[_models.SecurityDomainOperationStatus]( self._client, raw_result, get_long_running_output, polling_method # type: ignore )
Restore the provided Security Domain. :param security_domain: The Security Domain to be restored. Is one of the following types: SecurityDomainObject, JSON, IO[bytes] Required. :type security_domain: ~azure.keyvault.securitydomain.models.SecurityDomainObject or JSON or IO[bytes] :return: An instance of AsyncLROPoller that returns SecurityDomainOperationStatus. The SecurityDomainOperationStatus is compatible with MutableMapping :rtype: ~azure.core.polling.AsyncLROPoller[~azure.keyvault.securitydomain.models.SecurityDomainOperationStatus] :raises ~azure.core.exceptions.HttpResponseError:
begin_upload
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/aio/_operations/_operations.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/aio/_operations/_operations.py
MIT
async def get_transfer_key(self, **kwargs: Any) -> _models.TransferKey: """Retrieve Security Domain transfer key. :return: TransferKey. The TransferKey is compatible with MutableMapping :rtype: ~azure.keyvault.securitydomain.models.TransferKey :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} cls: ClsType[_models.TransferKey] = kwargs.pop("cls", None) _request = build_key_vault_get_transfer_key_request( api_version=self._config.api_version, headers=_headers, params=_params, ) path_format_arguments = { "vaultBaseUrl": self._serialize.url( "self._config.vault_base_url", self._config.vault_base_url, "str", skip_quote=True ), } _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: if _stream: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) if _stream: deserialized = response.iter_bytes() else: deserialized = _deserialize(_models.TransferKey, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
Retrieve Security Domain transfer key. :return: TransferKey. The TransferKey is compatible with MutableMapping :rtype: ~azure.keyvault.securitydomain.models.TransferKey :raises ~azure.core.exceptions.HttpResponseError:
get_transfer_key
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/aio/_operations/_operations.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/aio/_operations/_operations.py
MIT
def patch_sdk(): """Do not remove from this file. `patch_sdk` is a last resort escape hatch that allows you to do customizations you can't accomplish using the techniques described in https://aka.ms/azsdk/python/dpcodegen/python/customize """
Do not remove from this file. `patch_sdk` is a last resort escape hatch that allows you to do customizations you can't accomplish using the techniques described in https://aka.ms/azsdk/python/dpcodegen/python/customize
patch_sdk
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/aio/_operations/_patch.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/aio/_operations/_patch.py
MIT
def __init__(self, mapping: Mapping[str, Any]) -> None: """ :param mapping: raw JSON to initialize the model. :type mapping: Mapping[str, Any] """
:param mapping: raw JSON to initialize the model. :type mapping: Mapping[str, Any]
__init__
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/models/_models.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/models/_models.py
MIT
def __init__(self, mapping: Mapping[str, Any]) -> None: """ :param mapping: raw JSON to initialize the model. :type mapping: Mapping[str, Any] """
:param mapping: raw JSON to initialize the model. :type mapping: Mapping[str, Any]
__init__
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/models/_models.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/models/_models.py
MIT
def __init__(self, mapping: Mapping[str, Any]) -> None: """ :param mapping: raw JSON to initialize the model. :type mapping: Mapping[str, Any] """
:param mapping: raw JSON to initialize the model. :type mapping: Mapping[str, Any]
__init__
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/models/_models.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/models/_models.py
MIT
def __init__(self, mapping: Mapping[str, Any]) -> None: """ :param mapping: raw JSON to initialize the model. :type mapping: Mapping[str, Any] """
:param mapping: raw JSON to initialize the model. :type mapping: Mapping[str, Any]
__init__
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/models/_models.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/models/_models.py
MIT
def __init__(self, mapping: Mapping[str, Any]) -> None: """ :param mapping: raw JSON to initialize the model. :type mapping: Mapping[str, Any] """
:param mapping: raw JSON to initialize the model. :type mapping: Mapping[str, Any]
__init__
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/models/_models.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/models/_models.py
MIT
def patch_sdk(): """Do not remove from this file. `patch_sdk` is a last resort escape hatch that allows you to do customizations you can't accomplish using the techniques described in https://aka.ms/azsdk/python/dpcodegen/python/customize """
Do not remove from this file. `patch_sdk` is a last resort escape hatch that allows you to do customizations you can't accomplish using the techniques described in https://aka.ms/azsdk/python/dpcodegen/python/customize
patch_sdk
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/models/_patch.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/models/_patch.py
MIT
def download_pending(self, **kwargs: Any) -> _models.SecurityDomainOperationStatus: """Retrieves the Security Domain download operation status. :return: SecurityDomainOperationStatus. The SecurityDomainOperationStatus is compatible with MutableMapping :rtype: ~azure.keyvault.securitydomain.models.SecurityDomainOperationStatus :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} cls: ClsType[_models.SecurityDomainOperationStatus] = kwargs.pop("cls", None) _request = build_hsm_security_domain_download_pending_request( api_version=self._config.api_version, headers=_headers, params=_params, ) path_format_arguments = { "vaultBaseUrl": self._serialize.url( "self._config.vault_base_url", self._config.vault_base_url, "str", skip_quote=True ), } _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: if _stream: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) if _stream: deserialized = response.iter_bytes() else: deserialized = _deserialize(_models.SecurityDomainOperationStatus, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
Retrieves the Security Domain download operation status. :return: SecurityDomainOperationStatus. The SecurityDomainOperationStatus is compatible with MutableMapping :rtype: ~azure.keyvault.securitydomain.models.SecurityDomainOperationStatus :raises ~azure.core.exceptions.HttpResponseError:
download_pending
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/operations/_operations.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/operations/_operations.py
MIT
def begin_download( self, certificate_info_object: _models.CertificateInfoObject, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.SecurityDomainOperationStatus]: """Retrieves the Security Domain from the managed HSM. Calling this endpoint can be used to activate a provisioned managed HSM resource. :param certificate_info_object: The Security Domain download operation requires customer to provide N certificates (minimum 3 and maximum 10) containing a public key in JWK format. Required. :type certificate_info_object: ~azure.keyvault.securitydomain.models.CertificateInfoObject :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns SecurityDomainOperationStatus. The SecurityDomainOperationStatus is compatible with MutableMapping :rtype: ~azure.core.polling.LROPoller[~azure.keyvault.securitydomain.models.SecurityDomainOperationStatus] :raises ~azure.core.exceptions.HttpResponseError: """
Retrieves the Security Domain from the managed HSM. Calling this endpoint can be used to activate a provisioned managed HSM resource. :param certificate_info_object: The Security Domain download operation requires customer to provide N certificates (minimum 3 and maximum 10) containing a public key in JWK format. Required. :type certificate_info_object: ~azure.keyvault.securitydomain.models.CertificateInfoObject :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns SecurityDomainOperationStatus. The SecurityDomainOperationStatus is compatible with MutableMapping :rtype: ~azure.core.polling.LROPoller[~azure.keyvault.securitydomain.models.SecurityDomainOperationStatus] :raises ~azure.core.exceptions.HttpResponseError:
begin_download
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/operations/_operations.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/operations/_operations.py
MIT
def begin_download( self, certificate_info_object: JSON, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.SecurityDomainOperationStatus]: """Retrieves the Security Domain from the managed HSM. Calling this endpoint can be used to activate a provisioned managed HSM resource. :param certificate_info_object: The Security Domain download operation requires customer to provide N certificates (minimum 3 and maximum 10) containing a public key in JWK format. Required. :type certificate_info_object: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns SecurityDomainOperationStatus. The SecurityDomainOperationStatus is compatible with MutableMapping :rtype: ~azure.core.polling.LROPoller[~azure.keyvault.securitydomain.models.SecurityDomainOperationStatus] :raises ~azure.core.exceptions.HttpResponseError: """
Retrieves the Security Domain from the managed HSM. Calling this endpoint can be used to activate a provisioned managed HSM resource. :param certificate_info_object: The Security Domain download operation requires customer to provide N certificates (minimum 3 and maximum 10) containing a public key in JWK format. Required. :type certificate_info_object: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns SecurityDomainOperationStatus. The SecurityDomainOperationStatus is compatible with MutableMapping :rtype: ~azure.core.polling.LROPoller[~azure.keyvault.securitydomain.models.SecurityDomainOperationStatus] :raises ~azure.core.exceptions.HttpResponseError:
begin_download
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/operations/_operations.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/operations/_operations.py
MIT
def begin_download( self, certificate_info_object: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.SecurityDomainOperationStatus]: """Retrieves the Security Domain from the managed HSM. Calling this endpoint can be used to activate a provisioned managed HSM resource. :param certificate_info_object: The Security Domain download operation requires customer to provide N certificates (minimum 3 and maximum 10) containing a public key in JWK format. Required. :type certificate_info_object: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns SecurityDomainOperationStatus. The SecurityDomainOperationStatus is compatible with MutableMapping :rtype: ~azure.core.polling.LROPoller[~azure.keyvault.securitydomain.models.SecurityDomainOperationStatus] :raises ~azure.core.exceptions.HttpResponseError: """
Retrieves the Security Domain from the managed HSM. Calling this endpoint can be used to activate a provisioned managed HSM resource. :param certificate_info_object: The Security Domain download operation requires customer to provide N certificates (minimum 3 and maximum 10) containing a public key in JWK format. Required. :type certificate_info_object: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns SecurityDomainOperationStatus. The SecurityDomainOperationStatus is compatible with MutableMapping :rtype: ~azure.core.polling.LROPoller[~azure.keyvault.securitydomain.models.SecurityDomainOperationStatus] :raises ~azure.core.exceptions.HttpResponseError:
begin_download
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/operations/_operations.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/operations/_operations.py
MIT
def begin_download( self, certificate_info_object: Union[_models.CertificateInfoObject, JSON, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.SecurityDomainOperationStatus]: """Retrieves the Security Domain from the managed HSM. Calling this endpoint can be used to activate a provisioned managed HSM resource. :param certificate_info_object: The Security Domain download operation requires customer to provide N certificates (minimum 3 and maximum 10) containing a public key in JWK format. Is one of the following types: CertificateInfoObject, JSON, IO[bytes] Required. :type certificate_info_object: ~azure.keyvault.securitydomain.models.CertificateInfoObject or JSON or IO[bytes] :return: An instance of LROPoller that returns SecurityDomainOperationStatus. The SecurityDomainOperationStatus is compatible with MutableMapping :rtype: ~azure.core.polling.LROPoller[~azure.keyvault.securitydomain.models.SecurityDomainOperationStatus] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SecurityDomainOperationStatus] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._download_initial( certificate_info_object=certificate_info_object, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): response_headers = {} response = pipeline_response.http_response response_headers["Azure-AsyncOperation"] = self._deserialize( "str", response.headers.get("Azure-AsyncOperation") ) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = _deserialize(_models.SecurityDomainOperationStatus, response.json()) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized path_format_arguments = { "vaultBaseUrl": self._serialize.url( "self._config.vault_base_url", self._config.vault_base_url, "str", skip_quote=True ), } if polling is True: polling_method: PollingMethod = cast( PollingMethod, LROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[_models.SecurityDomainOperationStatus].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[_models.SecurityDomainOperationStatus]( self._client, raw_result, get_long_running_output, polling_method # type: ignore )
Retrieves the Security Domain from the managed HSM. Calling this endpoint can be used to activate a provisioned managed HSM resource. :param certificate_info_object: The Security Domain download operation requires customer to provide N certificates (minimum 3 and maximum 10) containing a public key in JWK format. Is one of the following types: CertificateInfoObject, JSON, IO[bytes] Required. :type certificate_info_object: ~azure.keyvault.securitydomain.models.CertificateInfoObject or JSON or IO[bytes] :return: An instance of LROPoller that returns SecurityDomainOperationStatus. The SecurityDomainOperationStatus is compatible with MutableMapping :rtype: ~azure.core.polling.LROPoller[~azure.keyvault.securitydomain.models.SecurityDomainOperationStatus] :raises ~azure.core.exceptions.HttpResponseError:
begin_download
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/operations/_operations.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/operations/_operations.py
MIT
def transfer_key(self, **kwargs: Any) -> _models.TransferKey: """Retrieve Security Domain transfer key. :return: TransferKey. The TransferKey is compatible with MutableMapping :rtype: ~azure.keyvault.securitydomain.models.TransferKey :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} cls: ClsType[_models.TransferKey] = kwargs.pop("cls", None) _request = build_hsm_security_domain_transfer_key_request( api_version=self._config.api_version, headers=_headers, params=_params, ) path_format_arguments = { "vaultBaseUrl": self._serialize.url( "self._config.vault_base_url", self._config.vault_base_url, "str", skip_quote=True ), } _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: if _stream: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) if _stream: deserialized = response.iter_bytes() else: deserialized = _deserialize(_models.TransferKey, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
Retrieve Security Domain transfer key. :return: TransferKey. The TransferKey is compatible with MutableMapping :rtype: ~azure.keyvault.securitydomain.models.TransferKey :raises ~azure.core.exceptions.HttpResponseError:
transfer_key
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/operations/_operations.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/operations/_operations.py
MIT
def begin_upload( self, security_domain: _models.SecurityDomainObject, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.SecurityDomainOperationStatus]: """Restore the provided Security Domain. :param security_domain: The Security Domain to be restored. Required. :type security_domain: ~azure.keyvault.securitydomain.models.SecurityDomainObject :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns SecurityDomainOperationStatus. The SecurityDomainOperationStatus is compatible with MutableMapping :rtype: ~azure.core.polling.LROPoller[~azure.keyvault.securitydomain.models.SecurityDomainOperationStatus] :raises ~azure.core.exceptions.HttpResponseError: """
Restore the provided Security Domain. :param security_domain: The Security Domain to be restored. Required. :type security_domain: ~azure.keyvault.securitydomain.models.SecurityDomainObject :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns SecurityDomainOperationStatus. The SecurityDomainOperationStatus is compatible with MutableMapping :rtype: ~azure.core.polling.LROPoller[~azure.keyvault.securitydomain.models.SecurityDomainOperationStatus] :raises ~azure.core.exceptions.HttpResponseError:
begin_upload
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/operations/_operations.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/operations/_operations.py
MIT
def begin_upload( self, security_domain: JSON, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.SecurityDomainOperationStatus]: """Restore the provided Security Domain. :param security_domain: The Security Domain to be restored. Required. :type security_domain: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns SecurityDomainOperationStatus. The SecurityDomainOperationStatus is compatible with MutableMapping :rtype: ~azure.core.polling.LROPoller[~azure.keyvault.securitydomain.models.SecurityDomainOperationStatus] :raises ~azure.core.exceptions.HttpResponseError: """
Restore the provided Security Domain. :param security_domain: The Security Domain to be restored. Required. :type security_domain: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns SecurityDomainOperationStatus. The SecurityDomainOperationStatus is compatible with MutableMapping :rtype: ~azure.core.polling.LROPoller[~azure.keyvault.securitydomain.models.SecurityDomainOperationStatus] :raises ~azure.core.exceptions.HttpResponseError:
begin_upload
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/operations/_operations.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/operations/_operations.py
MIT
def begin_upload( self, security_domain: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.SecurityDomainOperationStatus]: """Restore the provided Security Domain. :param security_domain: The Security Domain to be restored. Required. :type security_domain: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns SecurityDomainOperationStatus. The SecurityDomainOperationStatus is compatible with MutableMapping :rtype: ~azure.core.polling.LROPoller[~azure.keyvault.securitydomain.models.SecurityDomainOperationStatus] :raises ~azure.core.exceptions.HttpResponseError: """
Restore the provided Security Domain. :param security_domain: The Security Domain to be restored. Required. :type security_domain: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns SecurityDomainOperationStatus. The SecurityDomainOperationStatus is compatible with MutableMapping :rtype: ~azure.core.polling.LROPoller[~azure.keyvault.securitydomain.models.SecurityDomainOperationStatus] :raises ~azure.core.exceptions.HttpResponseError:
begin_upload
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/operations/_operations.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/operations/_operations.py
MIT
def begin_upload( self, security_domain: Union[_models.SecurityDomainObject, JSON, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.SecurityDomainOperationStatus]: """Restore the provided Security Domain. :param security_domain: The Security Domain to be restored. Is one of the following types: SecurityDomainObject, JSON, IO[bytes] Required. :type security_domain: ~azure.keyvault.securitydomain.models.SecurityDomainObject or JSON or IO[bytes] :return: An instance of LROPoller that returns SecurityDomainOperationStatus. The SecurityDomainOperationStatus is compatible with MutableMapping :rtype: ~azure.core.polling.LROPoller[~azure.keyvault.securitydomain.models.SecurityDomainOperationStatus] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SecurityDomainOperationStatus] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._upload_initial( security_domain=security_domain, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): response_headers = {} response = pipeline_response.http_response response_headers["Azure-AsyncOperation"] = self._deserialize( "str", response.headers.get("Azure-AsyncOperation") ) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = _deserialize(_models.SecurityDomainOperationStatus, response.json()) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized path_format_arguments = { "vaultBaseUrl": self._serialize.url( "self._config.vault_base_url", self._config.vault_base_url, "str", skip_quote=True ), } if polling is True: polling_method: PollingMethod = cast( PollingMethod, LROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[_models.SecurityDomainOperationStatus].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[_models.SecurityDomainOperationStatus]( self._client, raw_result, get_long_running_output, polling_method # type: ignore )
Restore the provided Security Domain. :param security_domain: The Security Domain to be restored. Is one of the following types: SecurityDomainObject, JSON, IO[bytes] Required. :type security_domain: ~azure.keyvault.securitydomain.models.SecurityDomainObject or JSON or IO[bytes] :return: An instance of LROPoller that returns SecurityDomainOperationStatus. The SecurityDomainOperationStatus is compatible with MutableMapping :rtype: ~azure.core.polling.LROPoller[~azure.keyvault.securitydomain.models.SecurityDomainOperationStatus] :raises ~azure.core.exceptions.HttpResponseError:
begin_upload
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/operations/_operations.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/operations/_operations.py
MIT
def upload_pending(self, **kwargs: Any) -> _models.SecurityDomainOperationStatus: """Get Security Domain upload operation status. :return: SecurityDomainOperationStatus. The SecurityDomainOperationStatus is compatible with MutableMapping :rtype: ~azure.keyvault.securitydomain.models.SecurityDomainOperationStatus :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} cls: ClsType[_models.SecurityDomainOperationStatus] = kwargs.pop("cls", None) _request = build_hsm_security_domain_upload_pending_request( api_version=self._config.api_version, headers=_headers, params=_params, ) path_format_arguments = { "vaultBaseUrl": self._serialize.url( "self._config.vault_base_url", self._config.vault_base_url, "str", skip_quote=True ), } _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: if _stream: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) if _stream: deserialized = response.iter_bytes() else: deserialized = _deserialize(_models.SecurityDomainOperationStatus, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
Get Security Domain upload operation status. :return: SecurityDomainOperationStatus. The SecurityDomainOperationStatus is compatible with MutableMapping :rtype: ~azure.keyvault.securitydomain.models.SecurityDomainOperationStatus :raises ~azure.core.exceptions.HttpResponseError:
upload_pending
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/operations/_operations.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/operations/_operations.py
MIT
def patch_sdk(): """Do not remove from this file. `patch_sdk` is a last resort escape hatch that allows you to do customizations you can't accomplish using the techniques described in https://aka.ms/azsdk/python/dpcodegen/python/customize """
Do not remove from this file. `patch_sdk` is a last resort escape hatch that allows you to do customizations you can't accomplish using the techniques described in https://aka.ms/azsdk/python/dpcodegen/python/customize
patch_sdk
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/operations/_patch.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/operations/_patch.py
MIT
def get_download_status(self, **kwargs: Any) -> _models.SecurityDomainOperationStatus: """Retrieves the Security Domain download operation status. :return: SecurityDomainOperationStatus. The SecurityDomainOperationStatus is compatible with MutableMapping :rtype: ~azure.keyvault.securitydomain.models.SecurityDomainOperationStatus :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} cls: ClsType[_models.SecurityDomainOperationStatus] = kwargs.pop("cls", None) _request = build_key_vault_get_download_status_request( api_version=self._config.api_version, headers=_headers, params=_params, ) path_format_arguments = { "vaultBaseUrl": self._serialize.url( "self._config.vault_base_url", self._config.vault_base_url, "str", skip_quote=True ), } _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: if _stream: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) if _stream: deserialized = response.iter_bytes() else: deserialized = _deserialize(_models.SecurityDomainOperationStatus, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
Retrieves the Security Domain download operation status. :return: SecurityDomainOperationStatus. The SecurityDomainOperationStatus is compatible with MutableMapping :rtype: ~azure.keyvault.securitydomain.models.SecurityDomainOperationStatus :raises ~azure.core.exceptions.HttpResponseError:
get_download_status
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_operations/_operations.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_operations/_operations.py
MIT
def begin_download( self, certificate_info_object: _models.CertificateInfoObject, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[None]: """Retrieves the Security Domain from the managed HSM. Calling this endpoint can be used to activate a provisioned managed HSM resource. :param certificate_info_object: The Security Domain download operation requires customer to provide N certificates (minimum 3 and maximum 10) containing a public key in JWK format. Required. :type certificate_info_object: ~azure.keyvault.securitydomain.models.CertificateInfoObject :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns None :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """
Retrieves the Security Domain from the managed HSM. Calling this endpoint can be used to activate a provisioned managed HSM resource. :param certificate_info_object: The Security Domain download operation requires customer to provide N certificates (minimum 3 and maximum 10) containing a public key in JWK format. Required. :type certificate_info_object: ~azure.keyvault.securitydomain.models.CertificateInfoObject :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns None :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError:
begin_download
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_operations/_operations.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_operations/_operations.py
MIT
def begin_download( self, certificate_info_object: JSON, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[None]: """Retrieves the Security Domain from the managed HSM. Calling this endpoint can be used to activate a provisioned managed HSM resource. :param certificate_info_object: The Security Domain download operation requires customer to provide N certificates (minimum 3 and maximum 10) containing a public key in JWK format. Required. :type certificate_info_object: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns None :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """
Retrieves the Security Domain from the managed HSM. Calling this endpoint can be used to activate a provisioned managed HSM resource. :param certificate_info_object: The Security Domain download operation requires customer to provide N certificates (minimum 3 and maximum 10) containing a public key in JWK format. Required. :type certificate_info_object: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns None :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError:
begin_download
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_operations/_operations.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_operations/_operations.py
MIT
def begin_download( self, certificate_info_object: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[None]: """Retrieves the Security Domain from the managed HSM. Calling this endpoint can be used to activate a provisioned managed HSM resource. :param certificate_info_object: The Security Domain download operation requires customer to provide N certificates (minimum 3 and maximum 10) containing a public key in JWK format. Required. :type certificate_info_object: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns None :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """
Retrieves the Security Domain from the managed HSM. Calling this endpoint can be used to activate a provisioned managed HSM resource. :param certificate_info_object: The Security Domain download operation requires customer to provide N certificates (minimum 3 and maximum 10) containing a public key in JWK format. Required. :type certificate_info_object: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns None :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError:
begin_download
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_operations/_operations.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_operations/_operations.py
MIT
def begin_download( self, certificate_info_object: Union[_models.CertificateInfoObject, JSON, IO[bytes]], **kwargs: Any ) -> LROPoller[None]: """Retrieves the Security Domain from the managed HSM. Calling this endpoint can be used to activate a provisioned managed HSM resource. :param certificate_info_object: The Security Domain download operation requires customer to provide N certificates (minimum 3 and maximum 10) containing a public key in JWK format. Is one of the following types: CertificateInfoObject, JSON, IO[bytes] Required. :type certificate_info_object: ~azure.keyvault.securitydomain.models.CertificateInfoObject or JSON or IO[bytes] :return: An instance of LROPoller that returns None :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[None] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._download_initial( certificate_info_object=certificate_info_object, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): # pylint: disable=inconsistent-return-statements if cls: return cls(pipeline_response, None, {}) # type: ignore path_format_arguments = { "vaultBaseUrl": self._serialize.url( "self._config.vault_base_url", self._config.vault_base_url, "str", skip_quote=True ), } if polling is True: polling_method: PollingMethod = cast( PollingMethod, LROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[None].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore
Retrieves the Security Domain from the managed HSM. Calling this endpoint can be used to activate a provisioned managed HSM resource. :param certificate_info_object: The Security Domain download operation requires customer to provide N certificates (minimum 3 and maximum 10) containing a public key in JWK format. Is one of the following types: CertificateInfoObject, JSON, IO[bytes] Required. :type certificate_info_object: ~azure.keyvault.securitydomain.models.CertificateInfoObject or JSON or IO[bytes] :return: An instance of LROPoller that returns None :rtype: ~azure.core.polling.LROPoller[None] :raises ~azure.core.exceptions.HttpResponseError:
begin_download
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_operations/_operations.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_operations/_operations.py
MIT
def get_upload_status(self, **kwargs: Any) -> _models.SecurityDomainOperationStatus: """Get Security Domain upload operation status. :return: SecurityDomainOperationStatus. The SecurityDomainOperationStatus is compatible with MutableMapping :rtype: ~azure.keyvault.securitydomain.models.SecurityDomainOperationStatus :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} cls: ClsType[_models.SecurityDomainOperationStatus] = kwargs.pop("cls", None) _request = build_key_vault_get_upload_status_request( api_version=self._config.api_version, headers=_headers, params=_params, ) path_format_arguments = { "vaultBaseUrl": self._serialize.url( "self._config.vault_base_url", self._config.vault_base_url, "str", skip_quote=True ), } _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: if _stream: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) if _stream: deserialized = response.iter_bytes() else: deserialized = _deserialize(_models.SecurityDomainOperationStatus, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
Get Security Domain upload operation status. :return: SecurityDomainOperationStatus. The SecurityDomainOperationStatus is compatible with MutableMapping :rtype: ~azure.keyvault.securitydomain.models.SecurityDomainOperationStatus :raises ~azure.core.exceptions.HttpResponseError:
get_upload_status
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_operations/_operations.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_operations/_operations.py
MIT
def begin_upload( self, security_domain: _models.SecurityDomainObject, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.SecurityDomainOperationStatus]: """Restore the provided Security Domain. :param security_domain: The Security Domain to be restored. Required. :type security_domain: ~azure.keyvault.securitydomain.models.SecurityDomainObject :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns SecurityDomainOperationStatus. The SecurityDomainOperationStatus is compatible with MutableMapping :rtype: ~azure.core.polling.LROPoller[~azure.keyvault.securitydomain.models.SecurityDomainOperationStatus] :raises ~azure.core.exceptions.HttpResponseError: """
Restore the provided Security Domain. :param security_domain: The Security Domain to be restored. Required. :type security_domain: ~azure.keyvault.securitydomain.models.SecurityDomainObject :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns SecurityDomainOperationStatus. The SecurityDomainOperationStatus is compatible with MutableMapping :rtype: ~azure.core.polling.LROPoller[~azure.keyvault.securitydomain.models.SecurityDomainOperationStatus] :raises ~azure.core.exceptions.HttpResponseError:
begin_upload
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_operations/_operations.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_operations/_operations.py
MIT
def begin_upload( self, security_domain: JSON, *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.SecurityDomainOperationStatus]: """Restore the provided Security Domain. :param security_domain: The Security Domain to be restored. Required. :type security_domain: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns SecurityDomainOperationStatus. The SecurityDomainOperationStatus is compatible with MutableMapping :rtype: ~azure.core.polling.LROPoller[~azure.keyvault.securitydomain.models.SecurityDomainOperationStatus] :raises ~azure.core.exceptions.HttpResponseError: """
Restore the provided Security Domain. :param security_domain: The Security Domain to be restored. Required. :type security_domain: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns SecurityDomainOperationStatus. The SecurityDomainOperationStatus is compatible with MutableMapping :rtype: ~azure.core.polling.LROPoller[~azure.keyvault.securitydomain.models.SecurityDomainOperationStatus] :raises ~azure.core.exceptions.HttpResponseError:
begin_upload
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_operations/_operations.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_operations/_operations.py
MIT
def begin_upload( self, security_domain: IO[bytes], *, content_type: str = "application/json", **kwargs: Any ) -> LROPoller[_models.SecurityDomainOperationStatus]: """Restore the provided Security Domain. :param security_domain: The Security Domain to be restored. Required. :type security_domain: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns SecurityDomainOperationStatus. The SecurityDomainOperationStatus is compatible with MutableMapping :rtype: ~azure.core.polling.LROPoller[~azure.keyvault.securitydomain.models.SecurityDomainOperationStatus] :raises ~azure.core.exceptions.HttpResponseError: """
Restore the provided Security Domain. :param security_domain: The Security Domain to be restored. Required. :type security_domain: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str :return: An instance of LROPoller that returns SecurityDomainOperationStatus. The SecurityDomainOperationStatus is compatible with MutableMapping :rtype: ~azure.core.polling.LROPoller[~azure.keyvault.securitydomain.models.SecurityDomainOperationStatus] :raises ~azure.core.exceptions.HttpResponseError:
begin_upload
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_operations/_operations.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_operations/_operations.py
MIT
def begin_upload( self, security_domain: Union[_models.SecurityDomainObject, JSON, IO[bytes]], **kwargs: Any ) -> LROPoller[_models.SecurityDomainOperationStatus]: """Restore the provided Security Domain. :param security_domain: The Security Domain to be restored. Is one of the following types: SecurityDomainObject, JSON, IO[bytes] Required. :type security_domain: ~azure.keyvault.securitydomain.models.SecurityDomainObject or JSON or IO[bytes] :return: An instance of LROPoller that returns SecurityDomainOperationStatus. The SecurityDomainOperationStatus is compatible with MutableMapping :rtype: ~azure.core.polling.LROPoller[~azure.keyvault.securitydomain.models.SecurityDomainOperationStatus] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[_models.SecurityDomainOperationStatus] = kwargs.pop("cls", None) polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) cont_token: Optional[str] = kwargs.pop("continuation_token", None) if cont_token is None: raw_result = self._upload_initial( security_domain=security_domain, content_type=content_type, cls=lambda x, y, z: x, headers=_headers, params=_params, **kwargs ) raw_result.http_response.read() # type: ignore kwargs.pop("error_map", None) def get_long_running_output(pipeline_response): response_headers = {} response = pipeline_response.http_response response_headers["Azure-AsyncOperation"] = self._deserialize( "str", response.headers.get("Azure-AsyncOperation") ) response_headers["Retry-After"] = self._deserialize("int", response.headers.get("Retry-After")) deserialized = _deserialize(_models.SecurityDomainOperationStatus, response.json()) if cls: return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized path_format_arguments = { "vaultBaseUrl": self._serialize.url( "self._config.vault_base_url", self._config.vault_base_url, "str", skip_quote=True ), } if polling is True: polling_method: PollingMethod = cast( PollingMethod, LROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) ) elif polling is False: polling_method = cast(PollingMethod, NoPolling()) else: polling_method = polling if cont_token: return LROPoller[_models.SecurityDomainOperationStatus].from_continuation_token( polling_method=polling_method, continuation_token=cont_token, client=self._client, deserialization_callback=get_long_running_output, ) return LROPoller[_models.SecurityDomainOperationStatus]( self._client, raw_result, get_long_running_output, polling_method # type: ignore )
Restore the provided Security Domain. :param security_domain: The Security Domain to be restored. Is one of the following types: SecurityDomainObject, JSON, IO[bytes] Required. :type security_domain: ~azure.keyvault.securitydomain.models.SecurityDomainObject or JSON or IO[bytes] :return: An instance of LROPoller that returns SecurityDomainOperationStatus. The SecurityDomainOperationStatus is compatible with MutableMapping :rtype: ~azure.core.polling.LROPoller[~azure.keyvault.securitydomain.models.SecurityDomainOperationStatus] :raises ~azure.core.exceptions.HttpResponseError:
begin_upload
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_operations/_operations.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_operations/_operations.py
MIT
def get_transfer_key(self, **kwargs: Any) -> _models.TransferKey: """Retrieve Security Domain transfer key. :return: TransferKey. The TransferKey is compatible with MutableMapping :rtype: ~azure.keyvault.securitydomain.models.TransferKey :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError, 304: ResourceNotModifiedError, } error_map.update(kwargs.pop("error_map", {}) or {}) _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} cls: ClsType[_models.TransferKey] = kwargs.pop("cls", None) _request = build_key_vault_get_transfer_key_request( api_version=self._config.api_version, headers=_headers, params=_params, ) path_format_arguments = { "vaultBaseUrl": self._serialize.url( "self._config.vault_base_url", self._config.vault_base_url, "str", skip_quote=True ), } _request.url = self._client.format_url(_request.url, **path_format_arguments) _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response if response.status_code not in [200]: if _stream: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) if _stream: deserialized = response.iter_bytes() else: deserialized = _deserialize(_models.TransferKey, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore
Retrieve Security Domain transfer key. :return: TransferKey. The TransferKey is compatible with MutableMapping :rtype: ~azure.keyvault.securitydomain.models.TransferKey :raises ~azure.core.exceptions.HttpResponseError:
get_transfer_key
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_operations/_operations.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_operations/_operations.py
MIT
def patch_sdk(): """Do not remove from this file. `patch_sdk` is a last resort escape hatch that allows you to do customizations you can't accomplish using the techniques described in https://aka.ms/azsdk/python/dpcodegen/python/customize """
Do not remove from this file. `patch_sdk` is a last resort escape hatch that allows you to do customizations you can't accomplish using the techniques described in https://aka.ms/azsdk/python/dpcodegen/python/customize
patch_sdk
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_operations/_patch.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_operations/_patch.py
MIT
def _has_claims(challenge: str) -> bool: """Check if a challenge header contains claims. :param challenge: The challenge header to check. :type challenge: str :returns: True if the challenge contains claims; False otherwise. :rtype: bool """ # Split the challenge into its scheme and parameters, then check if any parameter contains claims split_challenge = challenge.strip().split(" ", 1) return any("claims=" in item for item in split_challenge[1].split(","))
Check if a challenge header contains claims. :param challenge: The challenge header to check. :type challenge: str :returns: True if the challenge contains claims; False otherwise. :rtype: bool
_has_claims
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_internal/challenge_auth_policy.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_internal/challenge_auth_policy.py
MIT
def _update_challenge(request: PipelineRequest, challenger: PipelineResponse) -> HttpChallenge: """Parse challenge from a challenge response, cache it, and return it. :param request: The pipeline request that prompted the challenge response. :type request: ~azure.core.pipeline.PipelineRequest :param challenger: The pipeline response containing the authentication challenge. :type challenger: ~azure.core.pipeline.PipelineResponse :returns: An HttpChallenge object representing the authentication challenge. :rtype: HttpChallenge """ challenge = HttpChallenge( request.http_request.url, challenger.http_response.headers.get("WWW-Authenticate"), response_headers=challenger.http_response.headers, ) ChallengeCache.set_challenge_for_url(request.http_request.url, challenge) return challenge
Parse challenge from a challenge response, cache it, and return it. :param request: The pipeline request that prompted the challenge response. :type request: ~azure.core.pipeline.PipelineRequest :param challenger: The pipeline response containing the authentication challenge. :type challenger: ~azure.core.pipeline.PipelineResponse :returns: An HttpChallenge object representing the authentication challenge. :rtype: HttpChallenge
_update_challenge
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_internal/challenge_auth_policy.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_internal/challenge_auth_policy.py
MIT
def send(self, request: PipelineRequest[HttpRequest]) -> PipelineResponse[HttpRequest, HttpResponse]: """Authorize request with a bearer token and send it to the next policy. We implement this method to account for the valid scenario where a Key Vault authentication challenge is immediately followed by a CAE claims challenge. The base class's implementation would return the second 401 to the caller, but we should handle that second challenge as well (and only return any third 401 response). :param request: The pipeline request object :type request: ~azure.core.pipeline.PipelineRequest :return: The pipeline response object :rtype: ~azure.core.pipeline.PipelineResponse """ self.on_request(request) try: response = self.next.send(request) except Exception: # pylint:disable=broad-except self.on_exception(request) raise self.on_response(request, response) if response.http_response.status_code == 401: return self.handle_challenge_flow(request, response) return response
Authorize request with a bearer token and send it to the next policy. We implement this method to account for the valid scenario where a Key Vault authentication challenge is immediately followed by a CAE claims challenge. The base class's implementation would return the second 401 to the caller, but we should handle that second challenge as well (and only return any third 401 response). :param request: The pipeline request object :type request: ~azure.core.pipeline.PipelineRequest :return: The pipeline response object :rtype: ~azure.core.pipeline.PipelineResponse
send
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_internal/challenge_auth_policy.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_internal/challenge_auth_policy.py
MIT
def handle_challenge_flow( self, request: PipelineRequest[HttpRequest], response: PipelineResponse[HttpRequest, HttpResponse], consecutive_challenge: bool = False, ) -> PipelineResponse[HttpRequest, HttpResponse]: """Handle the challenge flow of Key Vault and CAE authentication. :param request: The pipeline request object :type request: ~azure.core.pipeline.PipelineRequest :param response: The pipeline response object :type response: ~azure.core.pipeline.PipelineResponse :param bool consecutive_challenge: Whether the challenge is arriving immediately after another challenge. Consecutive challenges can only be valid if a Key Vault challenge is followed by a CAE claims challenge. True if the preceding challenge was a Key Vault challenge; False otherwise. :return: The pipeline response object :rtype: ~azure.core.pipeline.PipelineResponse """ self._token = None # any cached token is invalid if "WWW-Authenticate" in response.http_response.headers: # If the previous challenge was a KV challenge and this one is too, return the 401 claims_challenge = _has_claims(response.http_response.headers["WWW-Authenticate"]) if consecutive_challenge and not claims_challenge: return response request_authorized = self.on_challenge(request, response) if request_authorized: # if we receive a challenge response, we retrieve a new token # which matches the new target. In this case, we don't want to remove # token from the request so clear the 'insecure_domain_change' tag request.context.options.pop("insecure_domain_change", False) try: response = self.next.send(request) except Exception: # pylint:disable=broad-except self.on_exception(request) raise # If consecutive_challenge == True, this could be a third consecutive 401 if response.http_response.status_code == 401 and not consecutive_challenge: # If the previous challenge wasn't from CAE, we can try this function one more time if not claims_challenge: return self.handle_challenge_flow(request, response, consecutive_challenge=True) self.on_response(request, response) return response
Handle the challenge flow of Key Vault and CAE authentication. :param request: The pipeline request object :type request: ~azure.core.pipeline.PipelineRequest :param response: The pipeline response object :type response: ~azure.core.pipeline.PipelineResponse :param bool consecutive_challenge: Whether the challenge is arriving immediately after another challenge. Consecutive challenges can only be valid if a Key Vault challenge is followed by a CAE claims challenge. True if the preceding challenge was a Key Vault challenge; False otherwise. :return: The pipeline response object :rtype: ~azure.core.pipeline.PipelineResponse
handle_challenge_flow
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_internal/challenge_auth_policy.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_internal/challenge_auth_policy.py
MIT
def _request_kv_token(self, scope: str, challenge: HttpChallenge) -> None: """Implementation of BearerTokenCredentialPolicy's _request_token method, but specific to Key Vault. :param str scope: The scope for which to request a token. :param challenge: The challenge for the request being made. :type challenge: HttpChallenge """ # Exclude tenant for AD FS authentication exclude_tenant = challenge.tenant_id and challenge.tenant_id.lower().endswith("adfs") # The SupportsTokenInfo protocol needs TokenRequestOptions for token requests instead of kwargs if hasattr(self._credential, "get_token_info"): options: TokenRequestOptions = {"enable_cae": True} if challenge.tenant_id and not exclude_tenant: options["tenant_id"] = challenge.tenant_id self._token = cast(SupportsTokenInfo, self._credential).get_token_info(scope, options=options) else: if exclude_tenant: self._token = self._credential.get_token(scope, enable_cae=True) else: self._token = cast(TokenCredential, self._credential).get_token( scope, tenant_id=challenge.tenant_id, enable_cae=True )
Implementation of BearerTokenCredentialPolicy's _request_token method, but specific to Key Vault. :param str scope: The scope for which to request a token. :param challenge: The challenge for the request being made. :type challenge: HttpChallenge
_request_kv_token
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_internal/challenge_auth_policy.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_internal/challenge_auth_policy.py
MIT
async def await_result(func: Callable[P, Union[T, Awaitable[T]]], *args: P.args, **kwargs: P.kwargs) -> T: """If func returns an awaitable, await it. :param func: The function to run. :type func: callable :param args: The positional arguments to pass to the function. :type args: list :rtype: any :return: The result of the function """ result = func(*args, **kwargs) if isinstance(result, Awaitable): return await result return result
If func returns an awaitable, await it. :param func: The function to run. :type func: callable :param args: The positional arguments to pass to the function. :type args: list :rtype: any :return: The result of the function
await_result
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_internal/async_challenge_auth_policy.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_internal/async_challenge_auth_policy.py
MIT
async def send(self, request: PipelineRequest[HttpRequest]) -> PipelineResponse[HttpRequest, AsyncHttpResponse]: """Authorize request with a bearer token and send it to the next policy. We implement this method to account for the valid scenario where a Key Vault authentication challenge is immediately followed by a CAE claims challenge. The base class's implementation would return the second 401 to the caller, but we should handle that second challenge as well (and only return any third 401 response). :param request: The pipeline request object :type request: ~azure.core.pipeline.PipelineRequest :return: The pipeline response object :rtype: ~azure.core.pipeline.PipelineResponse """ await await_result(self.on_request, request) response: PipelineResponse[HttpRequest, AsyncHttpResponse] try: response = await self.next.send(request) except Exception: # pylint:disable=broad-except await await_result(self.on_exception, request) raise await await_result(self.on_response, request, response) if response.http_response.status_code == 401: return await self.handle_challenge_flow(request, response) return response
Authorize request with a bearer token and send it to the next policy. We implement this method to account for the valid scenario where a Key Vault authentication challenge is immediately followed by a CAE claims challenge. The base class's implementation would return the second 401 to the caller, but we should handle that second challenge as well (and only return any third 401 response). :param request: The pipeline request object :type request: ~azure.core.pipeline.PipelineRequest :return: The pipeline response object :rtype: ~azure.core.pipeline.PipelineResponse
send
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_internal/async_challenge_auth_policy.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_internal/async_challenge_auth_policy.py
MIT
async def handle_challenge_flow( self, request: PipelineRequest[HttpRequest], response: PipelineResponse[HttpRequest, AsyncHttpResponse], consecutive_challenge: bool = False, ) -> PipelineResponse[HttpRequest, AsyncHttpResponse]: """Handle the challenge flow of Key Vault and CAE authentication. :param request: The pipeline request object :type request: ~azure.core.pipeline.PipelineRequest :param response: The pipeline response object :type response: ~azure.core.pipeline.PipelineResponse :param bool consecutive_challenge: Whether the challenge is arriving immediately after another challenge. Consecutive challenges can only be valid if a Key Vault challenge is followed by a CAE claims challenge. True if the preceding challenge was a Key Vault challenge; False otherwise. :return: The pipeline response object :rtype: ~azure.core.pipeline.PipelineResponse """ self._token = None # any cached token is invalid if "WWW-Authenticate" in response.http_response.headers: # If the previous challenge was a KV challenge and this one is too, return the 401 claims_challenge = _has_claims(response.http_response.headers["WWW-Authenticate"]) if consecutive_challenge and not claims_challenge: return response request_authorized = await self.on_challenge(request, response) if request_authorized: # if we receive a challenge response, we retrieve a new token # which matches the new target. In this case, we don't want to remove # token from the request so clear the 'insecure_domain_change' tag request.context.options.pop("insecure_domain_change", False) try: response = await self.next.send(request) except Exception: # pylint:disable=broad-except await await_result(self.on_exception, request) raise # If consecutive_challenge == True, this could be a third consecutive 401 if response.http_response.status_code == 401 and not consecutive_challenge: # If the previous challenge wasn't from CAE, we can try this function one more time if not claims_challenge: return await self.handle_challenge_flow(request, response, consecutive_challenge=True) await await_result(self.on_response, request, response) return response
Handle the challenge flow of Key Vault and CAE authentication. :param request: The pipeline request object :type request: ~azure.core.pipeline.PipelineRequest :param response: The pipeline response object :type response: ~azure.core.pipeline.PipelineResponse :param bool consecutive_challenge: Whether the challenge is arriving immediately after another challenge. Consecutive challenges can only be valid if a Key Vault challenge is followed by a CAE claims challenge. True if the preceding challenge was a Key Vault challenge; False otherwise. :return: The pipeline response object :rtype: ~azure.core.pipeline.PipelineResponse
handle_challenge_flow
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_internal/async_challenge_auth_policy.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_internal/async_challenge_auth_policy.py
MIT
async def _request_kv_token(self, scope: str, challenge: HttpChallenge) -> None: """Implementation of BearerTokenCredentialPolicy's _request_token method, but specific to Key Vault. :param str scope: The scope for which to request a token. :param challenge: The challenge for the request being made. :type challenge: HttpChallenge """ # Exclude tenant for AD FS authentication exclude_tenant = challenge.tenant_id and challenge.tenant_id.lower().endswith("adfs") # The AsyncSupportsTokenInfo protocol needs TokenRequestOptions for token requests instead of kwargs if hasattr(self._credential, "get_token_info"): options: TokenRequestOptions = {"enable_cae": True} if challenge.tenant_id and not exclude_tenant: options["tenant_id"] = challenge.tenant_id self._token = await cast(AsyncSupportsTokenInfo, self._credential).get_token_info(scope, options=options) else: if exclude_tenant: self._token = await self._credential.get_token(scope, enable_cae=True) else: self._token = await cast(AsyncTokenCredential, self._credential).get_token( scope, tenant_id=challenge.tenant_id, enable_cae=True )
Implementation of BearerTokenCredentialPolicy's _request_token method, but specific to Key Vault. :param str scope: The scope for which to request a token. :param challenge: The challenge for the request being made. :type challenge: HttpChallenge
_request_kv_token
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_internal/async_challenge_auth_policy.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_internal/async_challenge_auth_policy.py
MIT
def _is_empty(response: HttpResponse) -> bool: """Check if response body contains meaningful content. :param response: The response object. :type response: any :return: True if response body is empty, False otherwise. :rtype: bool """ return not bool(response.content)
Check if response body contains meaningful content. :param response: The response object. :type response: any :return: True if response body is empty, False otherwise. :rtype: bool
_is_empty
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_internal/polling.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_internal/polling.py
MIT
def finished(self) -> bool: """Is this polling finished? :rtype: bool :return: True if finished, False otherwise. """ return _finished(self.status())
Is this polling finished? :rtype: bool :return: True if finished, False otherwise.
finished
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_internal/polling.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_internal/polling.py
MIT
def parse_resource( self, pipeline_response: PipelineResponse[HttpRequest, HttpResponse], ) -> Union[SecurityDomainObject, SecurityDomainOperationStatus]: """Assuming this response is a resource, use the deserialization callback to parse it. If body is empty, assuming no resource to return. :param pipeline_response: The response object. :type pipeline_response: ~azure.core.pipeline.PipelineResponse :return: The parsed resource. :rtype: any """ response = pipeline_response.http_response if not _is_empty(response): return self._deserialization_callback(pipeline_response) # This "type ignore" has been discussed with architects. # We have a typing problem that if the Swagger/TSP describes a return type (PollingReturnType_co is not None), # BUT the returned payload is actually empty, we don't want to fail, but return None. # To be clean, we would have to make the polling return type Optional "just in case the Swagger/TSP is wrong". # This is reducing the quality and the value of the typing annotations # for a case that is not supposed to happen in the first place. So we decided to ignore the type error here. return None # type: ignore
Assuming this response is a resource, use the deserialization callback to parse it. If body is empty, assuming no resource to return. :param pipeline_response: The response object. :type pipeline_response: ~azure.core.pipeline.PipelineResponse :return: The parsed resource. :rtype: any
parse_resource
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_internal/polling.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_internal/polling.py
MIT
def finished(self) -> bool: """Is this polling finished? :rtype: bool :return: Whether this polling is finished """ return True
Is this polling finished? :rtype: bool :return: Whether this polling is finished
finished
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_internal/polling.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_internal/polling.py
MIT
def status(self) -> str: """Return the current status. :rtype: str :return: The current status """ return "succeeded"
Return the current status. :rtype: str :return: The current status
status
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_internal/polling.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_internal/polling.py
MIT
def initialize( self, client: PipelineClient[Any, Any], initial_response: PipelineResponse[HttpRequest, HttpResponse], deserialization_callback: Callable[ [PipelineResponse[HttpRequest, HttpResponse]], PollingReturnType_co, ], ) -> None: """Set the initial status of this LRO. :param client: The Azure Core Pipeline client used to make request. :type client: ~azure.core.pipeline.PipelineClient :param initial_response: The initial response for the call. :type initial_response: ~azure.core.pipeline.PipelineResponse :param deserialization_callback: A callback function to deserialize the final response. :type deserialization_callback: callable :raises: HttpResponseError if initial status is incorrect LRO state """ def get_long_running_output(pipeline_response): response_headers = {} response = pipeline_response.http_response deserializer = Deserializer() response_headers["Azure-AsyncOperation"] = deserializer._deserialize( # pylint: disable=protected-access "str", response.headers.get("Azure-AsyncOperation") ) response_headers["Retry-After"] = deserializer._deserialize( "int", response.headers.get("Retry-After") ) # pylint: disable=protected-access return _deserialize(SecurityDomainObject, response.json()) super().initialize(client, initial_response, get_long_running_output)
Set the initial status of this LRO. :param client: The Azure Core Pipeline client used to make request. :type client: ~azure.core.pipeline.PipelineClient :param initial_response: The initial response for the call. :type initial_response: ~azure.core.pipeline.PipelineResponse :param deserialization_callback: A callback function to deserialize the final response. :type deserialization_callback: callable :raises: HttpResponseError if initial status is incorrect LRO state
initialize
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_internal/polling.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_internal/polling.py
MIT
def resource(self) -> SecurityDomainObject: """Return the built resource. :rtype: any :return: The built resource. """ # The final response should actually be the security domain object that was returned in the initial response return cast(SecurityDomainObject, self.parse_resource(self._initial_response))
Return the built resource. :rtype: any :return: The built resource.
resource
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_internal/polling.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_internal/polling.py
MIT
def initialize( self, client: PipelineClient[Any, Any], initial_response: PipelineResponse[HttpRequest, HttpResponse], deserialization_callback: Callable[ [PipelineResponse[HttpRequest, HttpResponse]], PollingReturnType_co, ], ) -> None: """Set the initial status of this LRO. :param client: The Azure Core Pipeline client used to make request. :type client: ~azure.core.pipeline.PipelineClient :param initial_response: The initial response for the call. :type initial_response: ~azure.core.pipeline.PipelineResponse :param deserialization_callback: A callback function to deserialize the final response. :type deserialization_callback: callable :raises: HttpResponseError if initial status is incorrect LRO state """ def get_long_running_output(pipeline_response): response_headers = {} response = pipeline_response.http_response deserializer = Deserializer() response_headers["Azure-AsyncOperation"] = deserializer._deserialize( # pylint: disable=protected-access "str", response.headers.get("Azure-AsyncOperation") ) response_headers["Retry-After"] = deserializer._deserialize( "int", response.headers.get("Retry-After") ) # pylint: disable=protected-access return _deserialize(SecurityDomainOperationStatus, response.json()) super().initialize(client, initial_response, get_long_running_output)
Set the initial status of this LRO. :param client: The Azure Core Pipeline client used to make request. :type client: ~azure.core.pipeline.PipelineClient :param initial_response: The initial response for the call. :type initial_response: ~azure.core.pipeline.PipelineResponse :param deserialization_callback: A callback function to deserialize the final response. :type deserialization_callback: callable :raises: HttpResponseError if initial status is incorrect LRO state
initialize
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_internal/polling.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_internal/polling.py
MIT
def resource(self) -> SecurityDomainOperationStatus: """Return the built resource. :rtype: any :return: The built resource. """ return cast(SecurityDomainOperationStatus, self.parse_resource(self._pipeline_response))
Return the built resource. :rtype: any :return: The built resource.
resource
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_internal/polling.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_internal/polling.py
MIT
def resource(self) -> SecurityDomainOperationStatus: """Return the built resource. :rtype: any :return: The built resource. """ return cast(SecurityDomainOperationStatus, self.parse_resource(self._initial_response))
Return the built resource. :rtype: any :return: The built resource.
resource
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_internal/polling.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_internal/polling.py
MIT
def get_challenge_for_url(url: str) -> "Optional[HttpChallenge]": """Gets the challenge for the cached URL. :param str url: the URL the challenge is cached for. :returns: The challenge for the cached request URL, or None if the request URL isn't cached. :rtype: HttpChallenge or None """ if not url: raise ValueError("URL cannot be None") key = _get_cache_key(url) with _lock: return _cache.get(key)
Gets the challenge for the cached URL. :param str url: the URL the challenge is cached for. :returns: The challenge for the cached request URL, or None if the request URL isn't cached. :rtype: HttpChallenge or None
get_challenge_for_url
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_internal/http_challenge_cache.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_internal/http_challenge_cache.py
MIT
def _get_cache_key(url: str) -> str: """Use the URL's netloc as cache key except when the URL specifies the default port for its scheme. In that case use the netloc without the port. That is to say, https://foo.bar and https://foo.bar:443 are considered equivalent. This equivalency prevents an unnecessary challenge when using Key Vault's paging API. The Key Vault client doesn't specify ports, but Key Vault's next page links do, so a redundant challenge would otherwise be executed when the client requests the next page. :param str url: The HTTP request URL. :returns: The URL's `netloc`, minus any port attached to the URL. :rtype: str """ parsed = parse.urlparse(url) if parsed.scheme == "https" and parsed.port == 443: return parsed.netloc[:-4] return parsed.netloc
Use the URL's netloc as cache key except when the URL specifies the default port for its scheme. In that case use the netloc without the port. That is to say, https://foo.bar and https://foo.bar:443 are considered equivalent. This equivalency prevents an unnecessary challenge when using Key Vault's paging API. The Key Vault client doesn't specify ports, but Key Vault's next page links do, so a redundant challenge would otherwise be executed when the client requests the next page. :param str url: The HTTP request URL. :returns: The URL's `netloc`, minus any port attached to the URL. :rtype: str
_get_cache_key
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_internal/http_challenge_cache.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_internal/http_challenge_cache.py
MIT
def remove_challenge_for_url(url: str) -> None: """Removes the cached challenge for the specified URL. :param str url: the URL for which to remove the cached challenge """ if not url: raise ValueError("URL cannot be empty") parsed = parse.urlparse(url) with _lock: del _cache[parsed.netloc]
Removes the cached challenge for the specified URL. :param str url: the URL for which to remove the cached challenge
remove_challenge_for_url
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_internal/http_challenge_cache.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_internal/http_challenge_cache.py
MIT
def set_challenge_for_url(url: str, challenge: "HttpChallenge") -> None: """Caches the challenge for the specified URL. :param str url: the URL for which to cache the challenge :param challenge: the challenge to cache :type challenge: HttpChallenge """ if not url: raise ValueError("URL cannot be empty") if not challenge: raise ValueError("Challenge cannot be empty") src_url = parse.urlparse(url) if src_url.netloc != challenge.source_authority: raise ValueError("Source URL and Challenge URL do not match") with _lock: _cache[src_url.netloc] = challenge
Caches the challenge for the specified URL. :param str url: the URL for which to cache the challenge :param challenge: the challenge to cache :type challenge: HttpChallenge
set_challenge_for_url
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_internal/http_challenge_cache.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_internal/http_challenge_cache.py
MIT
def clear() -> None: """Clears the cache.""" with _lock: _cache.clear()
Clears the cache.
clear
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_internal/http_challenge_cache.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_internal/http_challenge_cache.py
MIT
def __init__( self, request_uri: str, challenge: str, response_headers: "Optional[MutableMapping[str, str]]" = None ) -> None: """Parses an HTTP WWW-Authentication Bearer challenge from a server. Example challenge with claims: Bearer authorization="https://login.windows-ppe.net/", error="invalid_token", error_description="User session has been revoked", claims="eyJhY2Nlc3NfdG9rZW4iOnsibmJmIjp7ImVzc2VudGlhbCI6dHJ1ZSwgInZhbHVlIjoiMTYwMzc0MjgwMCJ9fX0=" """ self.source_authority = self._validate_request_uri(request_uri) self.source_uri = request_uri self._parameters: "Dict[str, str]" = {} # get the scheme of the challenge and remove from the challenge string trimmed_challenge = self._validate_challenge(challenge) split_challenge = trimmed_challenge.split(" ", 1) self.scheme = split_challenge[0] trimmed_challenge = split_challenge[1] self.claims = None # split trimmed challenge into comma-separated name=value pairs. Values are expected # to be surrounded by quotes which are stripped here. for item in trimmed_challenge.split(","): # Special case for claims, which can contain = symbols as padding. Assume at most one claim per challenge if "claims=" in item: encoded_claims = item[item.index("=") + 1 :].strip(" \"'") padding_needed = -len(encoded_claims) % 4 try: decoded_claims = base64.urlsafe_b64decode(encoded_claims + "=" * padding_needed).decode() self.claims = decoded_claims except Exception: # pylint:disable=broad-except continue # process name=value pairs else: comps = item.split("=") if len(comps) == 2: key = comps[0].strip(' "') value = comps[1].strip(' "') if key: self._parameters[key] = value # minimum set of parameters if not self._parameters: raise ValueError("Invalid challenge parameters") # must specify authorization or authorization_uri if "authorization" not in self._parameters and "authorization_uri" not in self._parameters: raise ValueError("Invalid challenge parameters") authorization_uri = self.get_authorization_server() # the authorization server URI should look something like https://login.windows.net/tenant-id raw_uri_path = str(parse.urlparse(authorization_uri).path) uri_path = raw_uri_path.lstrip("/") self.tenant_id = uri_path.split("/", maxsplit=1)[0] or None # if the response headers were supplied if response_headers: # get the message signing key and message key encryption key from the headers self.server_signature_key = response_headers.get("x-ms-message-signing-key", None) self.server_encryption_key = response_headers.get("x-ms-message-encryption-key", None)
Parses an HTTP WWW-Authentication Bearer challenge from a server. Example challenge with claims: Bearer authorization="https://login.windows-ppe.net/", error="invalid_token", error_description="User session has been revoked", claims="eyJhY2Nlc3NfdG9rZW4iOnsibmJmIjp7ImVzc2VudGlhbCI6dHJ1ZSwgInZhbHVlIjoiMTYwMzc0MjgwMCJ9fX0="
__init__
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_internal/http_challenge.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_internal/http_challenge.py
MIT
def is_bearer_challenge(self) -> bool: """Tests whether the HttpChallenge is a Bearer challenge. :returns: True if the challenge is a Bearer challenge; False otherwise. :rtype: bool """ if not self.scheme: return False return self.scheme.lower() == "bearer"
Tests whether the HttpChallenge is a Bearer challenge. :returns: True if the challenge is a Bearer challenge; False otherwise. :rtype: bool
is_bearer_challenge
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_internal/http_challenge.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_internal/http_challenge.py
MIT
def is_pop_challenge(self) -> bool: """Tests whether the HttpChallenge is a proof of possession challenge. :returns: True if the challenge is a proof of possession challenge; False otherwise. :rtype: bool """ if not self.scheme: return False return self.scheme.lower() == "pop"
Tests whether the HttpChallenge is a proof of possession challenge. :returns: True if the challenge is a proof of possession challenge; False otherwise. :rtype: bool
is_pop_challenge
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_internal/http_challenge.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_internal/http_challenge.py
MIT
def get_authorization_server(self) -> str: """Returns the URI for the authorization server if present, otherwise an empty string. :returns: The URI for the authorization server if present, otherwise an empty string. :rtype: str """ value = "" for key in ["authorization_uri", "authorization"]: value = self.get_value(key) or "" if value: break return value
Returns the URI for the authorization server if present, otherwise an empty string. :returns: The URI for the authorization server if present, otherwise an empty string. :rtype: str
get_authorization_server
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_internal/http_challenge.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_internal/http_challenge.py
MIT
def get_resource(self) -> str: """Returns the resource if present, otherwise an empty string. :returns: The challenge resource if present, otherwise an empty string. :rtype: str """ return self.get_value("resource") or ""
Returns the resource if present, otherwise an empty string. :returns: The challenge resource if present, otherwise an empty string. :rtype: str
get_resource
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_internal/http_challenge.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_internal/http_challenge.py
MIT
def get_scope(self) -> str: """Returns the scope if present, otherwise an empty string. :returns: The challenge scope if present, otherwise an empty string. :rtype: str """ return self.get_value("scope") or ""
Returns the scope if present, otherwise an empty string. :returns: The challenge scope if present, otherwise an empty string. :rtype: str
get_scope
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_internal/http_challenge.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_internal/http_challenge.py
MIT
def supports_pop(self) -> bool: """Returns True if the challenge supports proof of possession token auth; False otherwise. :returns: True if the challenge supports proof of possession token auth; False otherwise. :rtype: bool """ return self._parameters.get("supportspop", "").lower() == "true"
Returns True if the challenge supports proof of possession token auth; False otherwise. :returns: True if the challenge supports proof of possession token auth; False otherwise. :rtype: bool
supports_pop
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_internal/http_challenge.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_internal/http_challenge.py
MIT
def supports_message_protection(self) -> bool: """Returns True if the challenge vault supports message protection; False otherwise. :returns: True if the challenge vault supports message protection; False otherwise. :rtype: bool """ return self.supports_pop() and self.server_encryption_key and self.server_signature_key # type: ignore
Returns True if the challenge vault supports message protection; False otherwise. :returns: True if the challenge vault supports message protection; False otherwise. :rtype: bool
supports_message_protection
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_internal/http_challenge.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_internal/http_challenge.py
MIT
def _validate_challenge( self, challenge: str ) -> str: # pylint:disable=bad-option-value,useless-option-value,no-self-use """Verifies that the challenge is a valid auth challenge and returns the key=value pairs. :param str challenge: The WWW-Authenticate header of the challenge response. :returns: The challenge key/value pairs, with whitespace removed, as a string. :rtype: str """ if not challenge: raise ValueError("Challenge cannot be empty") return challenge.strip()
Verifies that the challenge is a valid auth challenge and returns the key=value pairs. :param str challenge: The WWW-Authenticate header of the challenge response. :returns: The challenge key/value pairs, with whitespace removed, as a string. :rtype: str
_validate_challenge
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_internal/http_challenge.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_internal/http_challenge.py
MIT
def _validate_request_uri( self, uri: str ) -> str: # pylint:disable=bad-option-value,useless-option-value,no-self-use """Extracts the host authority from the given URI. :param str uri: The URI of the HTTP request that prompted the challenge. :returns: The challenge host authority. :rtype: str """ if not uri: raise ValueError("request_uri cannot be empty") parsed = parse.urlparse(uri) if not parsed.netloc: raise ValueError("request_uri must be an absolute URI") if parsed.scheme.lower() not in ["http", "https"]: raise ValueError("request_uri must be HTTP or HTTPS") return parsed.netloc
Extracts the host authority from the given URI. :param str uri: The URI of the HTTP request that prompted the challenge. :returns: The challenge host authority. :rtype: str
_validate_request_uri
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_internal/http_challenge.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/vendored_sdks/azure_keyvault_securitydomain/_internal/http_challenge.py
MIT
def test_keyvault_mgmt(self, resource_group): self.kwargs.update({ 'kv': self.create_random_name('cli-test-kv-mgmt-', 24), 'kv2': self.create_random_name('cli-test-kv-mgmt-', 24), 'kv3': self.create_random_name('cli-test-kv-mgmt-', 24), 'kv4': self.create_random_name('cli-test-kv-mgmt-', 24), 'loc': 'westus' }) # test create keyvault with default access policy set keyvault = self.cmd('keyvault create -g {rg} -n {kv} -l {loc}', checks=[ self.check('name', '{kv}'), self.check('location', '{loc}'), self.check('resourceGroup', '{rg}'), self.check('type(properties.accessPolicies)', 'array'), self.check('length(properties.accessPolicies)', 1), self.check('properties.sku.name', 'standard'), self.check('properties.enablePurgeProtection', None), self.check('properties.softDeleteRetentionInDays', 90) ]).get_output_in_json() self.kwargs['policy_id'] = keyvault['properties']['accessPolicies'][0]['objectId'] self.cmd('keyvault show -n {kv}', checks=[ self.check('name', '{kv}'), self.check('location', '{loc}'), self.check('resourceGroup', '{rg}'), self.check('type(properties.accessPolicies)', 'array'), self.check('length(properties.accessPolicies)', 1), ]) self.cmd('keyvault list -g {rg}', checks=[ self.check('type(@)', 'array'), self.check('length(@)', 1), self.check('[0].name', '{kv}'), self.check('[0].location', '{loc}'), self.check('[0].resourceGroup', '{rg}') ]) # test updating keyvault sku name self.cmd('keyvault update -g {rg} -n {kv} --set properties.sku.name=premium', checks=[ self.check('name', '{kv}'), self.check('properties.sku.name', 'premium'), ]) # test updating updating other properties self.cmd('keyvault update -g {rg} -n {kv} ' '--enabled-for-deployment --enabled-for-disk-encryption --enabled-for-template-deployment ' '--bypass AzureServices --default-action Deny', checks=[ self.check('name', '{kv}'), self.check('properties.enableSoftDelete', True), self.check('properties.enablePurgeProtection', None), self.check('properties.enabledForDeployment', True), self.check('properties.enabledForDiskEncryption', True), self.check('properties.enabledForTemplateDeployment', True), self.check('properties.networkAcls.bypass', 'AzureServices'), self.check('properties.networkAcls.defaultAction', 'Deny') ]) # test policy set/delete self.cmd('keyvault set-policy -g {rg} -n {kv} --object-id {policy_id} --key-permissions get wrapkey wrapKey', checks=self.check('length(properties.accessPolicies[0].permissions.keys)', 2)) self.cmd('keyvault set-policy -g {rg} -n {kv} --object-id {policy_id} --key-permissions get wrapkey wrapkey', checks=self.check('length(properties.accessPolicies[0].permissions.keys)', 2)) self.cmd('keyvault set-policy -g {rg} -n {kv} --object-id {policy_id} --certificate-permissions get list', checks=self.check('length(properties.accessPolicies[0].permissions.certificates)', 2)) self.cmd('keyvault delete-policy -g {rg} -n {kv} --object-id {policy_id}', checks=[ self.check('type(properties.accessPolicies)', 'array'), self.check('length(properties.accessPolicies)', 0) ]) # test keyvault delete self.cmd('keyvault delete -n {kv}') self.cmd('keyvault list -g {rg}', checks=self.is_empty()) self.cmd('keyvault purge -n {kv}') # ' will be parsed by shlex, so need escaping self.cmd(r"az keyvault list-deleted --query [?name==\'{kv}\']", checks=self.is_empty()) # test create keyvault further self.cmd('keyvault create -g {rg} -n {kv2} -l {loc} ' # enableSoftDelete is True if omitted '--retention-days 7 ' '--sku premium ' '--enabled-for-deployment true --enabled-for-disk-encryption true --enabled-for-template-deployment true ' '--no-self-perms ', # no self permission assigned checks=[ self.check('properties.enableSoftDelete', True), self.check('properties.softDeleteRetentionInDays', 7), self.check('properties.sku.name', 'premium'), self.check('properties.enabledForDeployment', True), self.check('properties.enabledForDiskEncryption', True), self.check('properties.enabledForTemplateDeployment', True), self.check('type(properties.accessPolicies)', 'array'), self.check('length(properties.accessPolicies)', 0), ]) self.cmd('keyvault delete -n {kv2}') self.cmd('keyvault purge -n {kv2}') # test explicitly set '--enable-purge-protection true' # unfortunately this will leave some waste behind, so make it the last test to lowered the execution count self.cmd('keyvault create -g {rg} -n {kv4} -l {loc} --enable-purge-protection true --retention-days 7', checks=[self.check('properties.enableSoftDelete', True), self.check('properties.enablePurgeProtection', True)]) # test '--enable-rbac-authorization' # temporarily disable this since our test subscription doesn't support RBAC authorization """ self.kwargs.update({ 'kv': self.create_random_name('cli-test-keyvault-', 24), 'loc': 'eastus2' }) _create_keyvault(self, self.kwargs, additional_args='--enable-rbac-authorization') self.cmd('keyvault show -n {kv}', checks=self.check('properties.enableRbacAuthorization', True)) with self.assertRaises(CLIError): self.cmd('keyvault set-policy -n {kv} --object-id 00000000-0000-0000-0000-000000000000 ' '--key-permissions get') with self.assertRaises(CLIError): self.cmd('keyvault delete-policy -n {kv} --object-id 00000000-0000-0000-0000-000000000000') self.cmd('keyvault update -n {kv} --enable-rbac-authorization false', checks=self.check('properties.enableRbacAuthorization', False)) self.cmd('keyvault update -n {kv} --enable-rbac-authorization true', checks=self.check('properties.enableRbacAuthorization', True)) """
self.kwargs.update({ 'kv': self.create_random_name('cli-test-keyvault-', 24), 'loc': 'eastus2' }) _create_keyvault(self, self.kwargs, additional_args='--enable-rbac-authorization') self.cmd('keyvault show -n {kv}', checks=self.check('properties.enableRbacAuthorization', True)) with self.assertRaises(CLIError): self.cmd('keyvault set-policy -n {kv} --object-id 00000000-0000-0000-0000-000000000000 ' '--key-permissions get') with self.assertRaises(CLIError): self.cmd('keyvault delete-policy -n {kv} --object-id 00000000-0000-0000-0000-000000000000') self.cmd('keyvault update -n {kv} --enable-rbac-authorization false', checks=self.check('properties.enableRbacAuthorization', False)) self.cmd('keyvault update -n {kv} --enable-rbac-authorization true', checks=self.check('properties.enableRbacAuthorization', True))
test_keyvault_mgmt
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/tests/hybrid_2020_09_01/test_keyvault_commands.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/tests/hybrid_2020_09_01/test_keyvault_commands.py
MIT
def test_keyvault_hsm_key_using_hsm_name(self, resource_group, managed_hsm): self.kwargs.update({ 'hsm_url': f'https://{managed_hsm}.managedhsm.azure.net', 'hsm_name': managed_hsm, 'key': self.create_random_name('key1-', 24) }) # create a key hsm_key = self.cmd('keyvault key create --hsm-name {hsm_name} -n {key}', checks=self.check('attributes.enabled', True)).get_output_in_json() self.kwargs['hsm_kid1'] = hsm_key['key']['kid'] self.kwargs['hsm_version1'] = self.kwargs['hsm_kid1'].rsplit('/', 1)[1] # encrypt/decrypt self.kwargs['plaintext_value'] = 'abcdef' self.kwargs['base64_value'] = 'YWJjZGVm' self.kwargs['encryption_result1'] = \ self.cmd('keyvault key encrypt -n {key} --hsm-name {hsm_name} -a RSA-OAEP --value "{plaintext_value}" ' '--data-type plaintext').get_output_in_json()['result'] self.kwargs['encryption_result2'] = \ self.cmd('keyvault key encrypt -n {key} --hsm-name {hsm_name} -a RSA-OAEP --value "{base64_value}" ' '--data-type base64').get_output_in_json()['result'] self.cmd('keyvault key decrypt -n {key} --hsm-name {hsm_name} -a RSA-OAEP --value "{encryption_result1}" ' '--data-type plaintext', checks=self.check('result', '{plaintext_value}')) self.cmd('keyvault key decrypt -n {key} --hsm-name {hsm_name} -a RSA-OAEP --value "{encryption_result2}" ' '--data-type base64', checks=self.check('result', '{base64_value}')) # delete/recover deleted_key = self.cmd('keyvault key delete --hsm-name {hsm_name} -n {key}', checks=self.check('key.kid', '{hsm_kid1}')).get_output_in_json() self.kwargs['hsm_recovery_id'] = deleted_key['recoveryId'] self.cmd('keyvault key list-deleted --hsm-name {hsm_name}', checks=self.check('length(@)', 1)) self.cmd('keyvault key recover --hsm-name {hsm_name} -n {key}', checks=self.check('key.kid', '{hsm_kid1}')) # list keys self.cmd('keyvault key list --hsm-name {hsm_name}', checks=self.check('length(@)', 1)) self.cmd('keyvault key list --hsm-name {hsm_name} --maxresults 10', checks=self.check('length(@)', 1)) # create a new key version hsm_key = self.cmd('keyvault key create --hsm-name {hsm_name} -n {key} --disabled --ops encrypt decrypt ' '--kty RSA-HSM', checks=[ self.check('attributes.enabled', False), self.check('length(key.keyOps)', 2) ]).get_output_in_json() hsm_second_kid = hsm_key['key']['kid'] hsm_pure_kid = '/'.join(hsm_second_kid.split('/')[:-1]) # Remove version field self.kwargs['hsm_kid'] = hsm_second_kid self.kwargs['hsm_pkid'] = hsm_pure_kid # list key versions self.cmd('keyvault key list-versions --hsm-name {hsm_name} -n {key}', checks=self.check('length(@)', 2)) self.cmd('keyvault key list-versions --hsm-name {hsm_name} -n {key} --maxresults 10', checks=self.check('length(@)', 2)) # show key (latest) self.cmd('keyvault key show --hsm-name {hsm_name} -n {key}', checks=self.check('key.kid', hsm_second_kid)) # show key (specific version) self.kwargs['hsm_kid2'] = hsm_second_kid self.cmd('keyvault key show --hsm-name {hsm_name} -n {key} -v {hsm_version1}', checks=self.check('key.kid', '{hsm_kid1}')) # show key (by id) self.cmd('keyvault key show --id {hsm_kid1}', checks=self.check('key.kid', '{hsm_kid1}')) # set key attributes self.cmd('keyvault key set-attributes --hsm-name {hsm_name} -n {key} --enabled true', checks=[ self.check('key.kid', '{hsm_kid2}'), self.check('attributes.enabled', True) ]) # backup and then delete key self.kwargs['key_file'] = os.path.join(tempfile.mkdtemp(), 'backup-hsm.key') self.cmd('keyvault key backup --hsm-name {hsm_name} -n {key} --file "{key_file}"') self.cmd('keyvault key delete --hsm-name {hsm_name} -n {key}') self.cmd('keyvault key purge --hsm-name {hsm_name} -n {key}') self.cmd('keyvault key list --hsm-name {hsm_name}', checks=self.is_empty()) self.cmd('keyvault key list --hsm-name {hsm_name} --maxresults 10', checks=self.is_empty()) # restore key from backup self.cmd('keyvault key restore --hsm-name {hsm_name} --file "{key_file}"') self.cmd('keyvault key list --hsm-name {hsm_name}', checks=[ self.check('length(@)', 1), self.check('[0].name', '{key}') ]) if os.path.exists(self.kwargs['key_file']): os.remove(self.kwargs['key_file']) # import PEM self.kwargs.update({ 'key_enc_file': os.path.join(TEST_DIR, 'mydomain.test.encrypted.pem'), 'key_enc_password': 'password', 'key_plain_file': os.path.join(TEST_DIR, 'mydomain.test.pem') }) self.cmd('keyvault key import --hsm-name {hsm_name} -n import-key-plain --pem-file "{key_plain_file}" -p hsm', checks=self.check('key.kty', 'RSA-HSM')) self.cmd('keyvault key import --hsm-name {hsm_name} -n import-key-encrypted --pem-file "{key_enc_file}" ' '--pem-password {key_enc_password} -p hsm', checks=self.check('key.kty', 'RSA-HSM')) # import ec PEM self.kwargs.update({ 'key_enc_file': os.path.join(TEST_DIR, 'ec521pw.pem'), 'key_enc_password': 'pass1234', 'key_plain_file': os.path.join(TEST_DIR, 'ec256.pem') }) self.cmd('keyvault key import --hsm-name {hsm_name} -n import-eckey-plain --pem-file "{key_plain_file}" ' '-p hsm', checks=[self.check('key.kty', 'EC-HSM'), self.check('key.crv', 'P-256')]) """ Enable this when service is ready self.cmd('keyvault key import --hsm-name {hsm_name} -n import-eckey-encrypted --pem-file "{key_enc_file}" ' '--pem-password {key_enc_password}', checks=[self.check('key.kty', 'EC-HSM'), self.check('key.crv', 'P-521')]) """ # create ec keys self.cmd('keyvault key create --hsm-name {hsm_name} -n eckey1 --kty EC-HSM', checks=self.check('key.kty', 'EC-HSM')) self.cmd('keyvault key create --hsm-name {hsm_name} -n eckey1 --kty EC-HSM --curve P-256', checks=[self.check('key.kty', 'EC-HSM'), self.check('key.crv', 'P-256')]) self.cmd('keyvault key delete --hsm-name {hsm_name} -n eckey1') # create KEK self.cmd('keyvault key create --hsm-name {hsm_name} -n key1 --kty RSA-HSM --size 2048 --ops import', checks=[self.check('key.kty', 'RSA-HSM'), self.check('key.keyOps', ['import'])]) self.cmd('keyvault key create --hsm-name {hsm_name} -n key2 --kty RSA-HSM --size 3072 --ops import', checks=[self.check('key.kty', 'RSA-HSM'), self.check('key.keyOps', ['import'])]) self.cmd('keyvault key create --hsm-name {hsm_name} -n key2 --kty RSA-HSM --size 4096 --ops import', checks=[self.check('key.kty', 'RSA-HSM'), self.check('key.keyOps', ['import'])])
Enable this when service is ready self.cmd('keyvault key import --hsm-name {hsm_name} -n import-eckey-encrypted --pem-file "{key_enc_file}" ' '--pem-password {key_enc_password}', checks=[self.check('key.kty', 'EC-HSM'), self.check('key.crv', 'P-521')])
test_keyvault_hsm_key_using_hsm_name
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/tests/latest/test_keyvault_commands.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/tests/latest/test_keyvault_commands.py
MIT
def test_keyvault_hsm_key_using_hsm_url(self): self.kwargs.update({ 'hsm_name': ACTIVE_HSM_NAME, 'hsm_url': ACTIVE_HSM_URL, 'key': self.create_random_name('key-', 24) }) _clear_hsm(self, hsm_url=self.kwargs['hsm_url']) # test exception with self.assertRaises(CLIError): self.cmd('keyvault key create --vault-name {hsm_name} --id {hsm_url} -n {key}') with self.assertRaises(CLIError): self.cmd('keyvault key create --hsm-name {hsm_name} --id {hsm_url} -n {key}') with self.assertRaises(CLIError): self.cmd('keyvault key create --vault-name {hsm_name} --hsm-name {hsm_name} -n {key}') with self.assertRaises(CLIError): self.cmd('keyvault key delete --vault-name {hsm_name} --hsm-name {hsm_name} -n {key}') with self.assertRaises(CLIError): self.cmd('keyvault key download --vault-name {hsm_name} --hsm-name {hsm_name} -n {key} -f test.key') with self.assertRaises(CLIError): self.cmd('keyvault key list --vault-name {hsm_name} --hsm-name {hsm_name}') with self.assertRaises(CLIError): self.cmd('keyvault key list-deleted --vault-name {hsm_name} --hsm-name {hsm_name}') with self.assertRaises(CLIError): self.cmd('keyvault key list-versions --vault-name {hsm_name} --hsm-name {hsm_name} -n {key}') with self.assertRaises(CLIError): self.cmd('keyvault key purge --vault-name {hsm_name} --hsm-name {hsm_name} -n {key}') with self.assertRaises(CLIError): self.cmd('keyvault key set-attributes --vault-name {hsm_name} --hsm-name {hsm_name} -n {key}') with self.assertRaises(CLIError): self.cmd('keyvault key show --vault-name {hsm_name} --hsm-name {hsm_name} -n {key}') with self.assertRaises(CLIError): self.cmd('keyvault key show-deleted --vault-name {hsm_name} --hsm-name {hsm_name} -n {key}') # create a key hsm_key = self.cmd('keyvault key create --id {hsm_url}/keys/{key} -p hsm', checks=self.check('attributes.enabled', True)).get_output_in_json() self.kwargs['hsm_kid1'] = hsm_key['key']['kid'] self.kwargs['hsm_version1'] = self.kwargs['hsm_kid1'].rsplit('/', 1)[1] # encrypt/decrypt self.kwargs['plaintext_value'] = 'abcdef' self.kwargs['base64_value'] = 'YWJjZGVm' self.kwargs['encryption_result1'] = \ self.cmd('keyvault key encrypt --id {hsm_url}/keys/{key} -a RSA-OAEP --value "{plaintext_value}" ' '--data-type plaintext').get_output_in_json()['result'] self.kwargs['encryption_result2'] = \ self.cmd('keyvault key encrypt --id {hsm_url}/keys/{key} -a RSA-OAEP --value "{base64_value}" ' '--data-type base64').get_output_in_json()['result'] self.cmd('keyvault key decrypt --id {hsm_url}/keys/{key} -a RSA-OAEP --value "{encryption_result1}" ' '--data-type plaintext', checks=self.check('result', '{plaintext_value}')) self.cmd('keyvault key decrypt --id {hsm_url}/keys/{key} -a RSA-OAEP --value "{encryption_result2}" ' '--data-type base64', checks=self.check('result', '{base64_value}')) # delete/recover deleted_key = self.cmd('keyvault key delete --id {hsm_kid1}', checks=self.check('key.kid', '{hsm_kid1}')).get_output_in_json() self.kwargs['hsm_recovery_id'] = deleted_key['recoveryId'] self.cmd('keyvault key list-deleted --id {hsm_url}', checks=self.check('length(@)', 1)) self.cmd('keyvault key recover --id {hsm_recovery_id}', checks=self.check('key.kid', '{hsm_kid1}')) # list keys self.cmd('keyvault key list --id {hsm_url}', checks=self.check('length(@)', 1)) self.cmd('keyvault key list --id {hsm_url} --maxresults 10', checks=self.check('length(@)', 1)) # create a new key version hsm_key = self.cmd('keyvault key create --id {hsm_url}/keys/{key} -p hsm --disabled --ops encrypt decrypt ' '--kty RSA-HSM', checks=[ self.check('attributes.enabled', False), self.check('length(key.keyOps)', 2) ]).get_output_in_json() hsm_second_kid = hsm_key['key']['kid'] hsm_pure_kid = '/'.join(hsm_second_kid.split('/')[:-1]) # Remove version field self.kwargs['hsm_kid'] = hsm_second_kid self.kwargs['hsm_pkid'] = hsm_pure_kid # list key versions self.cmd('keyvault key list-versions --id {hsm_url}/keys/{key}', checks=self.check('length(@)', 2)) self.cmd('keyvault key list-versions --id {hsm_url}/keys/{key} --maxresults 10', checks=self.check('length(@)', 2)) self.cmd('keyvault key list-versions --id {hsm_kid}', checks=self.check('length(@)', 2)) self.cmd('keyvault key list-versions --id {hsm_pkid}', checks=self.check('length(@)', 2)) # show key (latest) self.cmd('keyvault key show --id {hsm_url}/keys/{key}', checks=self.check('key.kid', hsm_second_kid)) # show key (specific version) self.kwargs['hsm_kid2'] = hsm_second_kid self.cmd('keyvault key show --id {hsm_url}/keys/{key} -v {hsm_version1}', checks=self.check('key.kid', '{hsm_kid1}')) # show key (by id) self.cmd('keyvault key show --id {hsm_kid1}', checks=self.check('key.kid', '{hsm_kid1}')) # set key attributes self.cmd('keyvault key set-attributes --id {hsm_url}/keys/{key} --enabled true', checks=[ self.check('key.kid', '{hsm_kid2}'), self.check('attributes.enabled', True) ]) # backup and then delete key self.kwargs['key_file'] = os.path.join(tempfile.mkdtemp(), 'backup-hsm.key') self.cmd('keyvault key backup --id {hsm_url}/keys/{key} --file "{key_file}"') self.cmd('keyvault key delete --id {hsm_url}/keys/{key}') self.cmd('keyvault key purge --id {hsm_url}/deletedkeys/{key}') self.cmd('keyvault key list --id {hsm_url}', checks=self.is_empty()) self.cmd('keyvault key list --id {hsm_url} --maxresults 10', checks=self.is_empty()) # restore key from backup self.cmd('keyvault key restore --id {hsm_url} --file "{key_file}"') self.cmd('keyvault key list --id {hsm_url}', checks=[ self.check('length(@)', 1), self.check('[0].name', '{key}') ]) if os.path.isfile(self.kwargs['key_file']): os.remove(self.kwargs['key_file']) # import PEM self.kwargs.update({ 'key_enc_file': os.path.join(TEST_DIR, 'mydomain.test.encrypted.pem'), 'key_enc_password': 'password', 'key_plain_file': os.path.join(TEST_DIR, 'mydomain.test.pem') }) self.cmd('keyvault key import --id {hsm_url}/keys/import-key-plain --pem-file "{key_plain_file}" -p hsm', checks=self.check('key.kty', 'RSA-HSM')) self.cmd('keyvault key import --id {hsm_url}/keys/import-key-encrypted --pem-file "{key_enc_file}" ' '--pem-password {key_enc_password} -p hsm', checks=self.check('key.kty', 'RSA-HSM')) # import ec PEM self.kwargs.update({ 'key_enc_file': os.path.join(TEST_DIR, 'ec521pw.pem'), 'key_enc_password': 'pass1234', 'key_plain_file': os.path.join(TEST_DIR, 'ec256.pem') }) self.cmd('keyvault key import --id {hsm_url}/keys/import-eckey-plain --pem-file "{key_plain_file}" ' '-p hsm', checks=[self.check('key.kty', 'EC-HSM'), self.check('key.crv', 'P-256')]) """ Enable this when service is ready self.cmd('keyvault key import --id {hsm_url}/keys/import-eckey-encrypted --pem-file "{key_enc_file}" ' '--pem-password {key_enc_password}', checks=[self.check('key.kty', 'EC-HSM'), self.check('key.crv', 'P-521')]) """ # create ec keys self.cmd('keyvault key create --id {hsm_url}/keys/eckey1 --kty EC-HSM', checks=self.check('key.kty', 'EC-HSM')) self.cmd('keyvault key create --id {hsm_url}/keys/eckey1 --kty EC-HSM --curve P-256', checks=[self.check('key.kty', 'EC-HSM'), self.check('key.crv', 'P-256')]) self.cmd('keyvault key delete --id {hsm_url}/keys/eckey1') # create KEK self.cmd('keyvault key create --id {hsm_url}/keys/key1 --kty RSA-HSM --size 2048 --ops import', checks=[self.check('key.kty', 'RSA-HSM'), self.check('key.keyOps', ['import'])]) self.cmd('keyvault key create --id {hsm_url}/keys/key2 --kty RSA-HSM --size 3072 --ops import', checks=[self.check('key.kty', 'RSA-HSM'), self.check('key.keyOps', ['import'])]) self.cmd('keyvault key create --id {hsm_url}/keys/key2 --kty RSA-HSM --size 4096 --ops import', checks=[self.check('key.kty', 'RSA-HSM'), self.check('key.keyOps', ['import'])])
Enable this when service is ready self.cmd('keyvault key import --id {hsm_url}/keys/import-eckey-encrypted --pem-file "{key_enc_file}" ' '--pem-password {key_enc_password}', checks=[self.check('key.kty', 'EC-HSM'), self.check('key.crv', 'P-521')])
test_keyvault_hsm_key_using_hsm_url
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/tests/latest/test_keyvault_commands.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/tests/latest/test_keyvault_commands.py
MIT
def __init__(self, alg=None, enc=None, zip=None, # pylint: disable=redefined-builtin jku=None, jwk=None, kid=None, x5u=None, x5c=None, x5t=None, x5t_S256=None, typ=None, cty=None, crit=None): """ JWE header :param alg: algorithm :param enc: encryption algorithm :param zip: compression algorithm :param jku: JWK set URL :param jwk: JSON Web key :param kid: Key ID :param x5u: X.509 certificate URL :param x5c: X.509 certificate chain :param x5t: X.509 certificate SHA-1 Thumbprint :param x5t_S256: X.509 certificate SHA-256 Thumbprint :param typ: type :param cty: content type :param crit: critical """ self.alg = alg self.enc = enc self.zip = zip self.jku = jku self.jwk = jwk self.kid = kid self.x5u = x5u self.x5c = x5c self.x5t = x5t self.x5t_S256 = x5t_S256 self.typ = typ self.cty = cty self.crit = crit
JWE header :param alg: algorithm :param enc: encryption algorithm :param zip: compression algorithm :param jku: JWK set URL :param jwk: JSON Web key :param kid: Key ID :param x5u: X.509 certificate URL :param x5c: X.509 certificate chain :param x5t: X.509 certificate SHA-1 Thumbprint :param x5t_S256: X.509 certificate SHA-256 Thumbprint :param typ: type :param cty: content type :param crit: critical
__init__
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/security_domain/jwe.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/security_domain/jwe.py
MIT
def sp800_108(key_in: bytearray, label: str, context: str, bit_length): """ Note - initialize out to be the number of bytes of keying material that you need This implements SP 800-108 in counter mode, see section 5.1 Fixed values: 1. h - The length of the output of the PRF in bits, and 2. r - The length of the binary representation of the counter i. Input: KI, Label, Context, and L. Process: 1. n := ⎡L/h⎤. 2. If n > 2^(r-1), then indicate an error and stop. 3. result(0):= ∅. 4. For i = 1 to n, do a. K(i) := PRF (KI, [i]2 || Label || 0x00 || Context || [L]2) b. result(i) := result(i-1) || K(i). 5. Return: KO := the leftmost L bits of result(n). """ if bit_length <= 0 or bit_length % 8 != 0: return None L = bit_length bytes_needed = bit_length // 8 hMAC = hmac.HMAC(key_in, digestmod=hashlib.sha512) hash_bits = hMAC.digest_size n = L // hash_bits if L % hash_bits != 0: n += 1 hmac_data_suffix = bytearray() hmac_data_suffix.extend(label.encode('UTF-8')) hmac_data_suffix.append(0) hmac_data_suffix.extend(context.encode('UTF-8')) hmac_data_suffix.extend(KDF.to_big_endian_32bits(bit_length)) out_value = bytearray() for i in range(n): hmac_data = bytearray() hmac_data.extend(KDF.to_big_endian_32bits(i + 1)) hmac_data.extend(hmac_data_suffix) hMAC.update(hmac_data) hash_value = hMAC.digest() if bytes_needed > len(hash_value): out_value.extend(hash_value) bytes_needed -= len(hash_value) else: out_value.extend(hash_value[len(out_value): len(out_value) + bytes_needed]) return out_value return None
Note - initialize out to be the number of bytes of keying material that you need This implements SP 800-108 in counter mode, see section 5.1 Fixed values: 1. h - The length of the output of the PRF in bits, and 2. r - The length of the binary representation of the counter i. Input: KI, Label, Context, and L. Process: 1. n := ⎡L/h⎤. 2. If n > 2^(r-1), then indicate an error and stop. 3. result(0):= ∅. 4. For i = 1 to n, do a. K(i) := PRF (KI, [i]2 || Label || 0x00 || Context || [L]2) b. result(i) := result(i-1) || K(i). 5. Return: KO := the leftmost L bits of result(n).
sp800_108
python
Azure/azure-cli
src/azure-cli/azure/cli/command_modules/keyvault/security_domain/sp800_108.py
https://github.com/Azure/azure-cli/blob/master/src/azure-cli/azure/cli/command_modules/keyvault/security_domain/sp800_108.py
MIT