diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/encryption_protector.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/encryption_protector.py index f6fe4ba3732d..7b58d5ed458f 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/encryption_protector.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/encryption_protector.py @@ -26,9 +26,9 @@ class EncryptionProtector(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param kind: Kind of encryption protector. This is metadata used for the + :ivar kind: Kind of encryption protector. This is metadata used for the Azure portal experience. - :type kind: str + :vartype kind: str :ivar location: Resource location. :vartype location: str :ivar subregion: Subregion of the encryption protector. @@ -49,6 +49,7 @@ class EncryptionProtector(ProxyResource): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, + 'kind': {'readonly': True}, 'location': {'readonly': True}, 'subregion': {'readonly': True}, 'server_key_type': {'required': True}, @@ -71,7 +72,7 @@ class EncryptionProtector(ProxyResource): def __init__(self, **kwargs): super(EncryptionProtector, self).__init__(**kwargs) - self.kind = kwargs.get('kind', None) + self.kind = None self.location = None self.subregion = None self.server_key_name = kwargs.get('server_key_name', None) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/encryption_protector_py3.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/encryption_protector_py3.py index 6dd4bad3cfbe..3a90f6cf2884 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/encryption_protector_py3.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/encryption_protector_py3.py @@ -26,9 +26,9 @@ class EncryptionProtector(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :param kind: Kind of encryption protector. This is metadata used for the + :ivar kind: Kind of encryption protector. This is metadata used for the Azure portal experience. - :type kind: str + :vartype kind: str :ivar location: Resource location. :vartype location: str :ivar subregion: Subregion of the encryption protector. @@ -49,6 +49,7 @@ class EncryptionProtector(ProxyResource): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, + 'kind': {'readonly': True}, 'location': {'readonly': True}, 'subregion': {'readonly': True}, 'server_key_type': {'required': True}, @@ -69,9 +70,9 @@ class EncryptionProtector(ProxyResource): 'thumbprint': {'key': 'properties.thumbprint', 'type': 'str'}, } - def __init__(self, *, server_key_type, kind: str=None, server_key_name: str=None, **kwargs) -> None: + def __init__(self, *, server_key_type, server_key_name: str=None, **kwargs) -> None: super(EncryptionProtector, self).__init__(**kwargs) - self.kind = kind + self.kind = None self.location = None self.subregion = None self.server_key_name = server_key_name diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/encryption_protectors_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/encryption_protectors_operations.py index d19233971f4c..a31da6275eee 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/encryption_protectors_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/encryption_protectors_operations.py @@ -25,8 +25,8 @@ class EncryptionProtectorsOperations(object): :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. + :ivar encryption_protector_name: The name of the encryption protector to be updated. Constant value: "current". :ivar api_version: The API version to use for the request. Constant value: "2015-05-01-preview". - :ivar encryption_protector_name: The name of the encryption protector to be retrieved. Constant value: "current". """ models = models @@ -36,11 +36,93 @@ def __init__(self, client, config, serializer, deserializer): self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2015-05-01-preview" self.encryption_protector_name = "current" + self.api_version = "2015-05-01-preview" self.config = config + + def _revalidate_initial( + self, resource_group_name, server_name, custom_headers=None, raw=False, **operation_config): + # Construct URL + url = self.revalidate.metadata['url'] + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serverName': self._serialize.url("server_name", server_name, 'str'), + 'encryptionProtectorName': self._serialize.url("self.encryption_protector_name", self.encryption_protector_name, 'str'), + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.post(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200, 202]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + + def revalidate( + self, resource_group_name, server_name, custom_headers=None, raw=False, polling=True, **operation_config): + """Revalidates an existing encryption protector. + + :param resource_group_name: The name of the resource group that + contains the resource. You can obtain this value from the Azure + Resource Manager API or the portal. + :type resource_group_name: str + :param server_name: The name of the server. + :type server_name: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: The poller return type is ClientRawResponse, the + direct response alongside the deserialized response + :param polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :return: An instance of LROPoller that returns None or + ClientRawResponse if raw==True + :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or + ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] + :raises: :class:`CloudError` + """ + raw_result = self._revalidate_initial( + resource_group_name=resource_group_name, + server_name=server_name, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + + def get_long_running_output(response): + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + + lro_delay = operation_config.get( + 'long_running_operation_timeout', + self.config.long_running_operation_timeout) + if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + revalidate.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/encryptionProtector/{encryptionProtectorName}/revalidate'} + def list_by_server( self, resource_group_name, server_name, custom_headers=None, raw=False, **operation_config): """Gets a list of server encryption protectors. @@ -180,7 +262,9 @@ def get( def _create_or_update_initial( - self, resource_group_name, server_name, parameters, custom_headers=None, raw=False, **operation_config): + self, resource_group_name, server_name, server_key_type, server_key_name=None, custom_headers=None, raw=False, **operation_config): + parameters = models.EncryptionProtector(server_key_name=server_key_name, server_key_type=server_key_type) + # Construct URL url = self.create_or_update.metadata['url'] path_format_arguments = { @@ -230,7 +314,7 @@ def _create_or_update_initial( return deserialized def create_or_update( - self, resource_group_name, server_name, parameters, custom_headers=None, raw=False, polling=True, **operation_config): + self, resource_group_name, server_name, server_key_type, server_key_name=None, custom_headers=None, raw=False, polling=True, **operation_config): """Updates an existing encryption protector. :param resource_group_name: The name of the resource group that @@ -239,8 +323,12 @@ def create_or_update( :type resource_group_name: str :param server_name: The name of the server. :type server_name: str - :param parameters: The requested encryption protector resource state. - :type parameters: ~azure.mgmt.sql.models.EncryptionProtector + :param server_key_type: The encryption protector type like + 'ServiceManaged', 'AzureKeyVault'. Possible values include: + 'ServiceManaged', 'AzureKeyVault' + :type server_key_type: str or ~azure.mgmt.sql.models.ServerKeyType + :param server_key_name: The name of the server key. + :type server_key_name: str :param dict custom_headers: headers that will be added to the request :param bool raw: The poller return type is ClientRawResponse, the direct response alongside the deserialized response @@ -257,7 +345,8 @@ def create_or_update( raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, server_name=server_name, - parameters=parameters, + server_key_type=server_key_type, + server_key_name=server_key_name, custom_headers=custom_headers, raw=True, **operation_config diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/managed_instance_encryption_protectors_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/managed_instance_encryption_protectors_operations.py index 61ab8baa5d32..bffd5839330e 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/managed_instance_encryption_protectors_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/managed_instance_encryption_protectors_operations.py @@ -25,8 +25,8 @@ class ManagedInstanceEncryptionProtectorsOperations(object): :param config: Configuration of service client. :param serializer: An object model serializer. :param deserializer: An object model deserializer. + :ivar encryption_protector_name: The name of the encryption protector to be updated. Constant value: "current". :ivar api_version: The API version to use for the request. Constant value: "2017-10-01-preview". - :ivar encryption_protector_name: The name of the encryption protector to be retrieved. Constant value: "current". """ models = models @@ -36,11 +36,93 @@ def __init__(self, client, config, serializer, deserializer): self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2017-10-01-preview" self.encryption_protector_name = "current" + self.api_version = "2017-10-01-preview" self.config = config + + def _revalidate_initial( + self, resource_group_name, managed_instance_name, custom_headers=None, raw=False, **operation_config): + # Construct URL + url = self.revalidate.metadata['url'] + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'managedInstanceName': self._serialize.url("managed_instance_name", managed_instance_name, 'str'), + 'encryptionProtectorName': self._serialize.url("self.encryption_protector_name", self.encryption_protector_name, 'str'), + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str') + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} + query_parameters['api-version'] = self._serialize.query("self.api_version", self.api_version, 'str') + + # Construct headers + header_parameters = {} + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.post(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200, 202]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + + def revalidate( + self, resource_group_name, managed_instance_name, custom_headers=None, raw=False, polling=True, **operation_config): + """Revalidates an existing encryption protector. + + :param resource_group_name: The name of the resource group that + contains the resource. You can obtain this value from the Azure + Resource Manager API or the portal. + :type resource_group_name: str + :param managed_instance_name: The name of the managed instance. + :type managed_instance_name: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: The poller return type is ClientRawResponse, the + direct response alongside the deserialized response + :param polling: True for ARMPolling, False for no polling, or a + polling object for personal polling strategy + :return: An instance of LROPoller that returns None or + ClientRawResponse if raw==True + :rtype: ~msrestazure.azure_operation.AzureOperationPoller[None] or + ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[None]] + :raises: :class:`CloudError` + """ + raw_result = self._revalidate_initial( + resource_group_name=resource_group_name, + managed_instance_name=managed_instance_name, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + + def get_long_running_output(response): + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + + lro_delay = operation_config.get( + 'long_running_operation_timeout', + self.config.long_running_operation_timeout) + if polling is True: polling_method = ARMPolling(lro_delay, **operation_config) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + revalidate.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/encryptionProtector/{encryptionProtectorName}/revalidate'} + def list_by_instance( self, resource_group_name, managed_instance_name, custom_headers=None, raw=False, **operation_config): """Gets a list of managed instance encryption protectors.