diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_sql_management_client.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_sql_management_client.py index 1222dc3d01be..d6c4c2afba21 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_sql_management_client.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/_sql_management_client.py @@ -107,6 +107,7 @@ from .operations import ServerAzureADOnlyAuthenticationsOperations from .operations import ImportExportOperations from .operations import ManagedInstanceAzureADOnlyAuthenticationsOperations +from .operations import ServerTrustGroupsOperations from . import models @@ -304,6 +305,8 @@ class SqlManagementClient(SDKClient): :vartype import_export: azure.mgmt.sql.operations.ImportExportOperations :ivar managed_instance_azure_ad_only_authentications: ManagedInstanceAzureADOnlyAuthentications operations :vartype managed_instance_azure_ad_only_authentications: azure.mgmt.sql.operations.ManagedInstanceAzureADOnlyAuthenticationsOperations + :ivar server_trust_groups: ServerTrustGroups operations + :vartype server_trust_groups: azure.mgmt.sql.operations.ServerTrustGroupsOperations :param credentials: Credentials needed for the client to connect to Azure. :type credentials: :mod:`A msrestazure Credentials @@ -512,3 +515,5 @@ def __init__( self._client, self.config, self._serialize, self._deserialize) self.managed_instance_azure_ad_only_authentications = ManagedInstanceAzureADOnlyAuthenticationsOperations( self._client, self.config, self._serialize, self._deserialize) + self.server_trust_groups = ServerTrustGroupsOperations( + self._client, self.config, self._serialize, self._deserialize) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/__init__.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/__init__.py index e00e5a2c9407..68ab5a939e20 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/__init__.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/__init__.py @@ -153,9 +153,11 @@ from ._models_py3 import ServerConnectionPolicy from ._models_py3 import ServerDnsAlias from ._models_py3 import ServerDnsAliasAcquisition + from ._models_py3 import ServerInfo from ._models_py3 import ServerKey from ._models_py3 import ServerPrivateEndpointConnection from ._models_py3 import ServerSecurityAlertPolicy + from ._models_py3 import ServerTrustGroup from ._models_py3 import ServerUpdate from ._models_py3 import ServerUsage from ._models_py3 import ServerVersionCapability @@ -340,9 +342,11 @@ from ._models import ServerConnectionPolicy from ._models import ServerDnsAlias from ._models import ServerDnsAliasAcquisition + from ._models import ServerInfo from ._models import ServerKey from ._models import ServerPrivateEndpointConnection from ._models import ServerSecurityAlertPolicy + from ._models import ServerTrustGroup from ._models import ServerUpdate from ._models import ServerUsage from ._models import ServerVersionCapability @@ -445,6 +449,7 @@ from ._paged_models import ServerKeyPaged from ._paged_models import ServerPaged from ._paged_models import ServerSecurityAlertPolicyPaged +from ._paged_models import ServerTrustGroupPaged from ._paged_models import ServerUsagePaged from ._paged_models import ServerVulnerabilityAssessmentPaged from ._paged_models import ServiceObjectivePaged @@ -704,9 +709,11 @@ 'ServerConnectionPolicy', 'ServerDnsAlias', 'ServerDnsAliasAcquisition', + 'ServerInfo', 'ServerKey', 'ServerPrivateEndpointConnection', 'ServerSecurityAlertPolicy', + 'ServerTrustGroup', 'ServerUpdate', 'ServerUsage', 'ServerVersionCapability', @@ -828,6 +835,7 @@ 'ManagedDatabasePaged', 'ServerAzureADOnlyAuthenticationPaged', 'ManagedInstanceAzureADOnlyAuthenticationPaged', + 'ServerTrustGroupPaged', 'ServerConnectionType', 'SecurityAlertPolicyState', 'SecurityAlertPolicyEmailAccountAdmins', diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/_models.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/_models.py index 80f16fb02777..af1a9b2380c1 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/_models.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/_models.py @@ -628,8 +628,7 @@ class Database(TrackedResource): automatically paused. A value of -1 means that automatic pause is disabled :type auto_pause_delay: int :param storage_account_type: The storage account type used to store - backups for this database. Currently the only supported option is GRS - (GeoRedundantStorage). Possible values include: 'GRS', 'LRS', 'ZRS' + backups for this database. Possible values include: 'GRS', 'LRS', 'ZRS' :type storage_account_type: str or ~azure.mgmt.sql.models.StorageAccountType :param min_capacity: Minimal capacity that database will always have @@ -1280,8 +1279,7 @@ class DatabaseUpdate(Model): automatically paused. A value of -1 means that automatic pause is disabled :type auto_pause_delay: int :param storage_account_type: The storage account type used to store - backups for this database. Currently the only supported option is GRS - (GeoRedundantStorage). Possible values include: 'GRS', 'LRS', 'ZRS' + backups for this database. Possible values include: 'GRS', 'LRS', 'ZRS' :type storage_account_type: str or ~azure.mgmt.sql.models.StorageAccountType :param min_capacity: Minimal capacity that database will always have @@ -8408,6 +8406,28 @@ def __init__(self, **kwargs): self.old_server_dns_alias_id = kwargs.get('old_server_dns_alias_id', None) +class ServerInfo(Model): + """Server info for the server trust group. + + All required parameters must be populated in order to send to Azure. + + :param server_id: Required. Server Id. + :type server_id: str + """ + + _validation = { + 'server_id': {'required': True}, + } + + _attribute_map = { + 'server_id': {'key': 'serverId', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(ServerInfo, self).__init__(**kwargs) + self.server_id = kwargs.get('server_id', None) + + class ServerKey(ProxyResource): """A server key. @@ -8579,6 +8599,49 @@ def __init__(self, **kwargs): self.creation_time = None +class ServerTrustGroup(ProxyResource): + """A server trust group. + + Variables are only populated by the server, and will be ignored when + sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :param group_members: Required. Group members information for the server + trust group. + :type group_members: list[~azure.mgmt.sql.models.ServerInfo] + :param trust_scopes: Required. Trust scope of the server trust group. + :type trust_scopes: list[str] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'group_members': {'required': True}, + 'trust_scopes': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'group_members': {'key': 'properties.groupMembers', 'type': '[ServerInfo]'}, + 'trust_scopes': {'key': 'properties.trustScopes', 'type': '[str]'}, + } + + def __init__(self, **kwargs): + super(ServerTrustGroup, self).__init__(**kwargs) + self.group_members = kwargs.get('group_members', None) + self.trust_scopes = kwargs.get('trust_scopes', None) + + class ServerUpdate(Model): """An update request for an Azure SQL Database server. @@ -9599,6 +9662,9 @@ class SyncGroup(ProxyResource): :param use_private_link_connection: If use private link connection is enabled. :type use_private_link_connection: bool + :ivar private_endpoint_name: Private endpoint name of the sync group if + use private link connection is enabled. + :vartype private_endpoint_name: str """ _validation = { @@ -9607,6 +9673,7 @@ class SyncGroup(ProxyResource): 'type': {'readonly': True}, 'last_sync_time': {'readonly': True}, 'sync_state': {'readonly': True}, + 'private_endpoint_name': {'readonly': True}, } _attribute_map = { @@ -9622,6 +9689,7 @@ class SyncGroup(ProxyResource): 'sync_state': {'key': 'properties.syncState', 'type': 'str'}, 'schema': {'key': 'properties.schema', 'type': 'SyncGroupSchema'}, 'use_private_link_connection': {'key': 'properties.usePrivateLinkConnection', 'type': 'bool'}, + 'private_endpoint_name': {'key': 'properties.privateEndpointName', 'type': 'str'}, } def __init__(self, **kwargs): @@ -9635,6 +9703,7 @@ def __init__(self, **kwargs): self.sync_state = None self.schema = kwargs.get('schema', None) self.use_private_link_connection = kwargs.get('use_private_link_connection', None) + self.private_endpoint_name = None class SyncGroupLogProperties(Model): @@ -9777,6 +9846,9 @@ class SyncMember(ProxyResource): :param use_private_link_connection: Whether to use private link connection. :type use_private_link_connection: bool + :ivar private_endpoint_name: Private endpoint name of the sync member if + use private link connection is enabled, for sync members in Azure. + :vartype private_endpoint_name: str :param server_name: Server name of the member database in the sync member :type server_name: str :param database_name: Database name of the member database in the sync @@ -9803,6 +9875,7 @@ class SyncMember(ProxyResource): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, + 'private_endpoint_name': {'readonly': True}, 'sync_state': {'readonly': True}, } @@ -9815,6 +9888,7 @@ class SyncMember(ProxyResource): 'sql_server_database_id': {'key': 'properties.sqlServerDatabaseId', 'type': 'str'}, 'sync_member_azure_database_resource_id': {'key': 'properties.syncMemberAzureDatabaseResourceId', 'type': 'str'}, 'use_private_link_connection': {'key': 'properties.usePrivateLinkConnection', 'type': 'bool'}, + 'private_endpoint_name': {'key': 'properties.privateEndpointName', 'type': 'str'}, 'server_name': {'key': 'properties.serverName', 'type': 'str'}, 'database_name': {'key': 'properties.databaseName', 'type': 'str'}, 'user_name': {'key': 'properties.userName', 'type': 'str'}, @@ -9830,6 +9904,7 @@ def __init__(self, **kwargs): self.sql_server_database_id = kwargs.get('sql_server_database_id', None) self.sync_member_azure_database_resource_id = kwargs.get('sync_member_azure_database_resource_id', None) self.use_private_link_connection = kwargs.get('use_private_link_connection', None) + self.private_endpoint_name = None self.server_name = kwargs.get('server_name', None) self.database_name = kwargs.get('database_name', None) self.user_name = kwargs.get('user_name', None) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/_models_py3.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/_models_py3.py index 4def9e609867..5dd2def32735 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/_models_py3.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/_models_py3.py @@ -628,8 +628,7 @@ class Database(TrackedResource): automatically paused. A value of -1 means that automatic pause is disabled :type auto_pause_delay: int :param storage_account_type: The storage account type used to store - backups for this database. Currently the only supported option is GRS - (GeoRedundantStorage). Possible values include: 'GRS', 'LRS', 'ZRS' + backups for this database. Possible values include: 'GRS', 'LRS', 'ZRS' :type storage_account_type: str or ~azure.mgmt.sql.models.StorageAccountType :param min_capacity: Minimal capacity that database will always have @@ -1280,8 +1279,7 @@ class DatabaseUpdate(Model): automatically paused. A value of -1 means that automatic pause is disabled :type auto_pause_delay: int :param storage_account_type: The storage account type used to store - backups for this database. Currently the only supported option is GRS - (GeoRedundantStorage). Possible values include: 'GRS', 'LRS', 'ZRS' + backups for this database. Possible values include: 'GRS', 'LRS', 'ZRS' :type storage_account_type: str or ~azure.mgmt.sql.models.StorageAccountType :param min_capacity: Minimal capacity that database will always have @@ -8408,6 +8406,28 @@ def __init__(self, *, old_server_dns_alias_id: str=None, **kwargs) -> None: self.old_server_dns_alias_id = old_server_dns_alias_id +class ServerInfo(Model): + """Server info for the server trust group. + + All required parameters must be populated in order to send to Azure. + + :param server_id: Required. Server Id. + :type server_id: str + """ + + _validation = { + 'server_id': {'required': True}, + } + + _attribute_map = { + 'server_id': {'key': 'serverId', 'type': 'str'}, + } + + def __init__(self, *, server_id: str, **kwargs) -> None: + super(ServerInfo, self).__init__(**kwargs) + self.server_id = server_id + + class ServerKey(ProxyResource): """A server key. @@ -8579,6 +8599,49 @@ def __init__(self, *, state, disabled_alerts=None, email_addresses=None, email_a self.creation_time = None +class ServerTrustGroup(ProxyResource): + """A server trust group. + + Variables are only populated by the server, and will be ignored when + sending a request. + + All required parameters must be populated in order to send to Azure. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :param group_members: Required. Group members information for the server + trust group. + :type group_members: list[~azure.mgmt.sql.models.ServerInfo] + :param trust_scopes: Required. Trust scope of the server trust group. + :type trust_scopes: list[str] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'group_members': {'required': True}, + 'trust_scopes': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'group_members': {'key': 'properties.groupMembers', 'type': '[ServerInfo]'}, + 'trust_scopes': {'key': 'properties.trustScopes', 'type': '[str]'}, + } + + def __init__(self, *, group_members, trust_scopes, **kwargs) -> None: + super(ServerTrustGroup, self).__init__(**kwargs) + self.group_members = group_members + self.trust_scopes = trust_scopes + + class ServerUpdate(Model): """An update request for an Azure SQL Database server. @@ -9599,6 +9662,9 @@ class SyncGroup(ProxyResource): :param use_private_link_connection: If use private link connection is enabled. :type use_private_link_connection: bool + :ivar private_endpoint_name: Private endpoint name of the sync group if + use private link connection is enabled. + :vartype private_endpoint_name: str """ _validation = { @@ -9607,6 +9673,7 @@ class SyncGroup(ProxyResource): 'type': {'readonly': True}, 'last_sync_time': {'readonly': True}, 'sync_state': {'readonly': True}, + 'private_endpoint_name': {'readonly': True}, } _attribute_map = { @@ -9622,6 +9689,7 @@ class SyncGroup(ProxyResource): 'sync_state': {'key': 'properties.syncState', 'type': 'str'}, 'schema': {'key': 'properties.schema', 'type': 'SyncGroupSchema'}, 'use_private_link_connection': {'key': 'properties.usePrivateLinkConnection', 'type': 'bool'}, + 'private_endpoint_name': {'key': 'properties.privateEndpointName', 'type': 'str'}, } def __init__(self, *, interval: int=None, conflict_resolution_policy=None, sync_database_id: str=None, hub_database_user_name: str=None, hub_database_password: str=None, schema=None, use_private_link_connection: bool=None, **kwargs) -> None: @@ -9635,6 +9703,7 @@ def __init__(self, *, interval: int=None, conflict_resolution_policy=None, sync_ self.sync_state = None self.schema = schema self.use_private_link_connection = use_private_link_connection + self.private_endpoint_name = None class SyncGroupLogProperties(Model): @@ -9777,6 +9846,9 @@ class SyncMember(ProxyResource): :param use_private_link_connection: Whether to use private link connection. :type use_private_link_connection: bool + :ivar private_endpoint_name: Private endpoint name of the sync member if + use private link connection is enabled, for sync members in Azure. + :vartype private_endpoint_name: str :param server_name: Server name of the member database in the sync member :type server_name: str :param database_name: Database name of the member database in the sync @@ -9803,6 +9875,7 @@ class SyncMember(ProxyResource): 'id': {'readonly': True}, 'name': {'readonly': True}, 'type': {'readonly': True}, + 'private_endpoint_name': {'readonly': True}, 'sync_state': {'readonly': True}, } @@ -9815,6 +9888,7 @@ class SyncMember(ProxyResource): 'sql_server_database_id': {'key': 'properties.sqlServerDatabaseId', 'type': 'str'}, 'sync_member_azure_database_resource_id': {'key': 'properties.syncMemberAzureDatabaseResourceId', 'type': 'str'}, 'use_private_link_connection': {'key': 'properties.usePrivateLinkConnection', 'type': 'bool'}, + 'private_endpoint_name': {'key': 'properties.privateEndpointName', 'type': 'str'}, 'server_name': {'key': 'properties.serverName', 'type': 'str'}, 'database_name': {'key': 'properties.databaseName', 'type': 'str'}, 'user_name': {'key': 'properties.userName', 'type': 'str'}, @@ -9830,6 +9904,7 @@ def __init__(self, *, database_type=None, sync_agent_id: str=None, sql_server_da self.sql_server_database_id = sql_server_database_id self.sync_member_azure_database_resource_id = sync_member_azure_database_resource_id self.use_private_link_connection = use_private_link_connection + self.private_endpoint_name = None self.server_name = server_name self.database_name = database_name self.user_name = user_name diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/_paged_models.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/_paged_models.py index 0987c5643fa5..9199c698f3e3 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/_paged_models.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/_paged_models.py @@ -1065,3 +1065,16 @@ class ManagedInstanceAzureADOnlyAuthenticationPaged(Paged): def __init__(self, *args, **kwargs): super(ManagedInstanceAzureADOnlyAuthenticationPaged, self).__init__(*args, **kwargs) +class ServerTrustGroupPaged(Paged): + """ + A paging container for iterating over a list of :class:`ServerTrustGroup ` object + """ + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'current_page': {'key': 'value', 'type': '[ServerTrustGroup]'} + } + + def __init__(self, *args, **kwargs): + + super(ServerTrustGroupPaged, self).__init__(*args, **kwargs) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/__init__.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/__init__.py index e9cb64531c69..95d0161cb160 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/__init__.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/__init__.py @@ -103,6 +103,7 @@ from ._server_azure_ad_only_authentications_operations import ServerAzureADOnlyAuthenticationsOperations from ._import_export_operations import ImportExportOperations from ._managed_instance_azure_ad_only_authentications_operations import ManagedInstanceAzureADOnlyAuthenticationsOperations +from ._server_trust_groups_operations import ServerTrustGroupsOperations __all__ = [ 'RecoverableDatabasesOperations', @@ -199,4 +200,5 @@ 'ServerAzureADOnlyAuthenticationsOperations', 'ImportExportOperations', 'ManagedInstanceAzureADOnlyAuthenticationsOperations', + 'ServerTrustGroupsOperations', ] diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_trust_groups_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_trust_groups_operations.py new file mode 100644 index 000000000000..807eae1649a1 --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_trust_groups_operations.py @@ -0,0 +1,459 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +import uuid +from msrest.pipeline import ClientRawResponse +from msrestazure.azure_exceptions import CloudError +from msrest.polling import LROPoller, NoPolling +from msrestazure.polling.arm_polling import ARMPolling + +from .. import models + + +class ServerTrustGroupsOperations(object): + """ServerTrustGroupsOperations operations. + + You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + :ivar api_version: The API version to use for the request. Constant value: "2020-02-02-preview". + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self.api_version = "2020-02-02-preview" + + self.config = config + + def get( + self, resource_group_name, location_name, server_trust_group_name, custom_headers=None, raw=False, **operation_config): + """Gets a server trust group. + + :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 location_name: The name of the region where the resource is + located. + :type location_name: str + :param server_trust_group_name: The name of the server trust group. + :type server_trust_group_name: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: ServerTrustGroup or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.sql.models.ServerTrustGroup or + ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + # Construct URL + url = self.get.metadata['url'] + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'locationName': self._serialize.url("location_name", location_name, 'str'), + 'serverTrustGroupName': self._serialize.url("server_trust_group_name", server_trust_group_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 = {} + header_parameters['Accept'] = 'application/json' + 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.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ServerTrustGroup', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/serverTrustGroups/{serverTrustGroupName}'} + + + def _create_or_update_initial( + self, resource_group_name, location_name, server_trust_group_name, group_members, trust_scopes, custom_headers=None, raw=False, **operation_config): + parameters = models.ServerTrustGroup(group_members=group_members, trust_scopes=trust_scopes) + + # Construct URL + url = self.create_or_update.metadata['url'] + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'locationName': self._serialize.url("location_name", location_name, 'str'), + 'serverTrustGroupName': self._serialize.url("server_trust_group_name", server_trust_group_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 = {} + header_parameters['Accept'] = 'application/json' + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + 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 body + body_content = self._serialize.body(parameters, 'ServerTrustGroup') + + # Construct and send request + request = self._client.put(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200, 201, 202]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + deserialized = None + + if response.status_code == 200: + deserialized = self._deserialize('ServerTrustGroup', response) + if response.status_code == 201: + deserialized = self._deserialize('ServerTrustGroup', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + def create_or_update( + self, resource_group_name, location_name, server_trust_group_name, group_members, trust_scopes, custom_headers=None, raw=False, polling=True, **operation_config): + """Creates or updates a server trust group. + + :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 location_name: The name of the region where the resource is + located. + :type location_name: str + :param server_trust_group_name: The name of the server trust group. + :type server_trust_group_name: str + :param group_members: Group members information for the server trust + group. + :type group_members: list[~azure.mgmt.sql.models.ServerInfo] + :param trust_scopes: Trust scope of the server trust group. + :type trust_scopes: list[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 ServerTrustGroup or + ClientRawResponse if raw==True + :rtype: + ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.sql.models.ServerTrustGroup] + or + ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.sql.models.ServerTrustGroup]] + :raises: :class:`CloudError` + """ + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + location_name=location_name, + server_trust_group_name=server_trust_group_name, + group_members=group_members, + trust_scopes=trust_scopes, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + + def get_long_running_output(response): + deserialized = self._deserialize('ServerTrustGroup', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + 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) + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/serverTrustGroups/{serverTrustGroupName}'} + + + def _delete_initial( + self, resource_group_name, location_name, server_trust_group_name, custom_headers=None, raw=False, **operation_config): + # Construct URL + url = self.delete.metadata['url'] + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'locationName': self._serialize.url("location_name", location_name, 'str'), + 'serverTrustGroupName': self._serialize.url("server_trust_group_name", server_trust_group_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.delete(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200, 202, 204]: + 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 delete( + self, resource_group_name, location_name, server_trust_group_name, custom_headers=None, raw=False, polling=True, **operation_config): + """Deletes a server trust group. + + :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 location_name: The name of the region where the resource is + located. + :type location_name: str + :param server_trust_group_name: The name of the server trust group. + :type server_trust_group_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._delete_initial( + resource_group_name=resource_group_name, + location_name=location_name, + server_trust_group_name=server_trust_group_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) + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/serverTrustGroups/{serverTrustGroupName}'} + + def list_by_location( + self, resource_group_name, location_name, custom_headers=None, raw=False, **operation_config): + """Lists a server trust group. + + :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 location_name: The name of the region where the resource is + located. + :type location_name: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: An iterator like instance of ServerTrustGroup + :rtype: + ~azure.mgmt.sql.models.ServerTrustGroupPaged[~azure.mgmt.sql.models.ServerTrustGroup] + :raises: :class:`CloudError` + """ + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list_by_location.metadata['url'] + path_format_arguments = { + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'locationName': self._serialize.url("location_name", location_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') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + 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.get(url, query_parameters, header_parameters) + return request + + def internal_paging(next_link=None): + request = prepare_request(next_link) + + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + return response + + # Deserialize response + header_dict = None + if raw: + header_dict = {} + deserialized = models.ServerTrustGroupPaged(internal_paging, self._deserialize.dependencies, header_dict) + + return deserialized + list_by_location.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/locations/{locationName}/serverTrustGroups'} + + def list_by_instance( + self, resource_group_name, managed_instance_name, custom_headers=None, raw=False, **operation_config): + """Gets a server trust groups by instance name. + + :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: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: An iterator like instance of ServerTrustGroup + :rtype: + ~azure.mgmt.sql.models.ServerTrustGroupPaged[~azure.mgmt.sql.models.ServerTrustGroup] + :raises: :class:`CloudError` + """ + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list_by_instance.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'), + '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') + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + 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.get(url, query_parameters, header_parameters) + return request + + def internal_paging(next_link=None): + request = prepare_request(next_link) + + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + return response + + # Deserialize response + header_dict = None + if raw: + header_dict = {} + deserialized = models.ServerTrustGroupPaged(internal_paging, self._deserialize.dependencies, header_dict) + + return deserialized + list_by_instance.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/managedInstances/{managedInstanceName}/serverTrustGroups'}