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 5312457b984e..49162abefab1 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 @@ -165,6 +165,8 @@ from .usage_py3 import Usage from .managed_instance_py3 import ManagedInstance from .managed_instance_update_py3 import ManagedInstanceUpdate + from .private_link_resource_properties_py3 import PrivateLinkResourceProperties + from .private_link_resource_py3 import PrivateLinkResource except (SyntaxError, ImportError): from .recoverable_database import RecoverableDatabase from .restorable_dropped_database import RestorableDroppedDatabase @@ -321,6 +323,8 @@ from .usage import Usage from .managed_instance import ManagedInstance from .managed_instance_update import ManagedInstanceUpdate + from .private_link_resource_properties import PrivateLinkResourceProperties + from .private_link_resource import PrivateLinkResource from .recoverable_database_paged import RecoverableDatabasePaged from .restorable_dropped_database_paged import RestorableDroppedDatabasePaged from .server_paged import ServerPaged @@ -388,6 +392,7 @@ from .instance_pool_paged import InstancePoolPaged from .usage_paged import UsagePaged from .managed_instance_paged import ManagedInstancePaged +from .private_link_resource_paged import PrivateLinkResourcePaged from .sql_management_client_enums import ( CheckNameAvailabilityReason, ServerConnectionType, @@ -628,6 +633,8 @@ 'Usage', 'ManagedInstance', 'ManagedInstanceUpdate', + 'PrivateLinkResourceProperties', + 'PrivateLinkResource', 'RecoverableDatabasePaged', 'RestorableDroppedDatabasePaged', 'ServerPaged', @@ -695,6 +702,7 @@ 'InstancePoolPaged', 'UsagePaged', 'ManagedInstancePaged', + 'PrivateLinkResourcePaged', 'CheckNameAvailabilityReason', 'ServerConnectionType', 'SecurityAlertPolicyState', diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/private_link_resource.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/private_link_resource.py new file mode 100644 index 000000000000..211b9d617d71 --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/private_link_resource.py @@ -0,0 +1,47 @@ +# 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. +# -------------------------------------------------------------------------- + +from .proxy_resource import ProxyResource + + +class PrivateLinkResource(ProxyResource): + """A private link resource. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar properties: The private link resource group id. + :vartype properties: ~azure.mgmt.sql.models.PrivateLinkResourceProperties + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'properties': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'PrivateLinkResourceProperties'}, + } + + def __init__(self, **kwargs): + super(PrivateLinkResource, self).__init__(**kwargs) + self.properties = None diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/private_link_resource_paged.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/private_link_resource_paged.py new file mode 100644 index 000000000000..eb2aaf5d8254 --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/private_link_resource_paged.py @@ -0,0 +1,27 @@ +# 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. +# -------------------------------------------------------------------------- + +from msrest.paging import Paged + + +class PrivateLinkResourcePaged(Paged): + """ + A paging container for iterating over a list of :class:`PrivateLinkResource ` object + """ + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'current_page': {'key': 'value', 'type': '[PrivateLinkResource]'} + } + + def __init__(self, *args, **kwargs): + + super(PrivateLinkResourcePaged, self).__init__(*args, **kwargs) diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/private_link_resource_properties.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/private_link_resource_properties.py new file mode 100644 index 000000000000..02849cb49e70 --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/private_link_resource_properties.py @@ -0,0 +1,40 @@ +# 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. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class PrivateLinkResourceProperties(Model): + """Properties of a private link resource. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar group_id: The private link resource group id. + :vartype group_id: str + :ivar required_members: The private link resource required member names. + :vartype required_members: list[str] + """ + + _validation = { + 'group_id': {'readonly': True}, + 'required_members': {'readonly': True}, + } + + _attribute_map = { + 'group_id': {'key': 'groupId', 'type': 'str'}, + 'required_members': {'key': 'requiredMembers', 'type': '[str]'}, + } + + def __init__(self, **kwargs): + super(PrivateLinkResourceProperties, self).__init__(**kwargs) + self.group_id = None + self.required_members = None diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/private_link_resource_properties_py3.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/private_link_resource_properties_py3.py new file mode 100644 index 000000000000..a953547ec158 --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/private_link_resource_properties_py3.py @@ -0,0 +1,40 @@ +# 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. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model + + +class PrivateLinkResourceProperties(Model): + """Properties of a private link resource. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar group_id: The private link resource group id. + :vartype group_id: str + :ivar required_members: The private link resource required member names. + :vartype required_members: list[str] + """ + + _validation = { + 'group_id': {'readonly': True}, + 'required_members': {'readonly': True}, + } + + _attribute_map = { + 'group_id': {'key': 'groupId', 'type': 'str'}, + 'required_members': {'key': 'requiredMembers', 'type': '[str]'}, + } + + def __init__(self, **kwargs) -> None: + super(PrivateLinkResourceProperties, self).__init__(**kwargs) + self.group_id = None + self.required_members = None diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/private_link_resource_py3.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/private_link_resource_py3.py new file mode 100644 index 000000000000..56241f58b466 --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/models/private_link_resource_py3.py @@ -0,0 +1,47 @@ +# 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. +# -------------------------------------------------------------------------- + +from .proxy_resource_py3 import ProxyResource + + +class PrivateLinkResource(ProxyResource): + """A private link resource. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: Resource ID. + :vartype id: str + :ivar name: Resource name. + :vartype name: str + :ivar type: Resource type. + :vartype type: str + :ivar properties: The private link resource group id. + :vartype properties: ~azure.mgmt.sql.models.PrivateLinkResourceProperties + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'properties': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': 'PrivateLinkResourceProperties'}, + } + + def __init__(self, **kwargs) -> None: + super(PrivateLinkResource, self).__init__(**kwargs) + self.properties = None 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 b5f1cf999537..c10360d7b9cd 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 @@ -91,6 +91,7 @@ from .instance_pools_operations import InstancePoolsOperations from .usages_operations import UsagesOperations from .managed_instances_operations import ManagedInstancesOperations +from .private_link_resources_operations import PrivateLinkResourcesOperations __all__ = [ 'RecoverableDatabasesOperations', @@ -175,4 +176,5 @@ 'InstancePoolsOperations', 'UsagesOperations', 'ManagedInstancesOperations', + 'PrivateLinkResourcesOperations', ] diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/private_link_resources_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/private_link_resources_operations.py new file mode 100644 index 000000000000..33f3e42eca23 --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/private_link_resources_operations.py @@ -0,0 +1,177 @@ +# 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 .. import models + + +class PrivateLinkResourcesOperations(object): + """PrivateLinkResourcesOperations operations. + + :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: "2018-06-01-preview". + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self.api_version = "2018-06-01-preview" + + self.config = config + + def list_by_server( + self, resource_group_name, server_name, custom_headers=None, raw=False, **operation_config): + """Gets the private link resources for SQL server. + + :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: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: An iterator like instance of PrivateLinkResource + :rtype: + ~azure.mgmt.sql.models.PrivateLinkResourcePaged[~azure.mgmt.sql.models.PrivateLinkResource] + :raises: :class:`CloudError` + """ + def internal_paging(next_link=None, raw=False): + + if not next_link: + # Construct URL + url = self.list_by_server.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'), + '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) + 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 + deserialized = models.PrivateLinkResourcePaged(internal_paging, self._deserialize.dependencies) + + if raw: + header_dict = {} + client_raw_response = models.PrivateLinkResourcePaged(internal_paging, self._deserialize.dependencies, header_dict) + return client_raw_response + + return deserialized + list_by_server.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/privateLinkResources'} + + def get( + self, resource_group_name, server_name, group_name, custom_headers=None, raw=False, **operation_config): + """Gets a private link resource for SQL server. + + :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 group_name: The name of the private link resource. + :type 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: PrivateLinkResource or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.sql.models.PrivateLinkResource 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'), + 'serverName': self._serialize.url("server_name", server_name, 'str'), + 'groupName': self._serialize.url("group_name", 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('PrivateLinkResource', 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/servers/{serverName}/privateLinkResources/{groupName}'} 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 334be8304ad4..3e24b4ff6101 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 @@ -95,6 +95,7 @@ from .operations.instance_pools_operations import InstancePoolsOperations from .operations.usages_operations import UsagesOperations from .operations.managed_instances_operations import ManagedInstancesOperations +from .operations.private_link_resources_operations import PrivateLinkResourcesOperations from . import models @@ -301,6 +302,8 @@ class SqlManagementClient(SDKClient): :vartype usages: azure.mgmt.sql.operations.UsagesOperations :ivar managed_instances: ManagedInstances operations :vartype managed_instances: azure.mgmt.sql.operations.ManagedInstancesOperations + :ivar private_link_resources: PrivateLinkResources operations + :vartype private_link_resources: azure.mgmt.sql.operations.PrivateLinkResourcesOperations :param credentials: Credentials needed for the client to connect to Azure. :type credentials: :mod:`A msrestazure Credentials @@ -485,3 +488,5 @@ def __init__( self._client, self.config, self._serialize, self._deserialize) self.managed_instances = ManagedInstancesOperations( self._client, self.config, self._serialize, self._deserialize) + self.private_link_resources = PrivateLinkResourcesOperations( + self._client, self.config, self._serialize, self._deserialize)