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 79a5a1986c21..43abac6baf3f 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 @@ -26,7 +26,6 @@ from .operations import ElasticPoolsOperations from .operations import RecommendedElasticPoolsOperations from .operations import ReplicationLinksOperations -from .operations import ServerAzureADAdministratorsOperations from .operations import ServerCommunicationLinksOperations from .operations import ServiceObjectivesOperations from .operations import ElasticPoolActivitiesOperations @@ -99,6 +98,9 @@ from .operations import ManagedDatabasesOperations from .operations import PrivateEndpointConnectionsOperations from .operations import PrivateLinkResourcesOperations +from .operations import ServerAzureADAdministratorsOperations +from .operations import WorkloadGroupsOperations +from .operations import WorkloadClassifiersOperations from . import models @@ -134,8 +136,6 @@ class SqlManagementClient(SDKClient): :vartype recommended_elastic_pools: azure.mgmt.sql.operations.RecommendedElasticPoolsOperations :ivar replication_links: ReplicationLinks operations :vartype replication_links: azure.mgmt.sql.operations.ReplicationLinksOperations - :ivar server_azure_ad_administrators: ServerAzureADAdministrators operations - :vartype server_azure_ad_administrators: azure.mgmt.sql.operations.ServerAzureADAdministratorsOperations :ivar server_communication_links: ServerCommunicationLinks operations :vartype server_communication_links: azure.mgmt.sql.operations.ServerCommunicationLinksOperations :ivar service_objectives: ServiceObjectives operations @@ -280,6 +280,12 @@ class SqlManagementClient(SDKClient): :vartype private_endpoint_connections: azure.mgmt.sql.operations.PrivateEndpointConnectionsOperations :ivar private_link_resources: PrivateLinkResources operations :vartype private_link_resources: azure.mgmt.sql.operations.PrivateLinkResourcesOperations + :ivar server_azure_ad_administrators: ServerAzureADAdministrators operations + :vartype server_azure_ad_administrators: azure.mgmt.sql.operations.ServerAzureADAdministratorsOperations + :ivar workload_groups: WorkloadGroups operations + :vartype workload_groups: azure.mgmt.sql.operations.WorkloadGroupsOperations + :ivar workload_classifiers: WorkloadClassifiers operations + :vartype workload_classifiers: azure.mgmt.sql.operations.WorkloadClassifiersOperations :param credentials: Credentials needed for the client to connect to Azure. :type credentials: :mod:`A msrestazure Credentials @@ -326,8 +332,6 @@ def __init__( self._client, self.config, self._serialize, self._deserialize) self.replication_links = ReplicationLinksOperations( self._client, self.config, self._serialize, self._deserialize) - self.server_azure_ad_administrators = ServerAzureADAdministratorsOperations( - self._client, self.config, self._serialize, self._deserialize) self.server_communication_links = ServerCommunicationLinksOperations( self._client, self.config, self._serialize, self._deserialize) self.service_objectives = ServiceObjectivesOperations( @@ -472,3 +476,9 @@ def __init__( self._client, self.config, self._serialize, self._deserialize) self.private_link_resources = PrivateLinkResourcesOperations( self._client, self.config, self._serialize, self._deserialize) + self.server_azure_ad_administrators = ServerAzureADAdministratorsOperations( + self._client, self.config, self._serialize, self._deserialize) + self.workload_groups = WorkloadGroupsOperations( + self._client, self.config, self._serialize, self._deserialize) + self.workload_classifiers = WorkloadClassifiersOperations( + 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 fb4487981b53..cd827b06309f 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 @@ -172,6 +172,8 @@ from ._models_py3 import VulnerabilityAssessmentRecurringScansProperties from ._models_py3 import VulnerabilityAssessmentScanError from ._models_py3 import VulnerabilityAssessmentScanRecord + from ._models_py3 import WorkloadClassifier + from ._models_py3 import WorkloadGroup except (SyntaxError, ImportError): from ._models import AutomaticTuningOptions from ._models import AutomaticTuningServerOptions @@ -335,6 +337,8 @@ from ._models import VulnerabilityAssessmentRecurringScansProperties from ._models import VulnerabilityAssessmentScanError from ._models import VulnerabilityAssessmentScanRecord + from ._models import WorkloadClassifier + from ._models import WorkloadGroup from ._paged_models import BackupShortTermRetentionPolicyPaged from ._paged_models import DatabaseBlobAuditingPolicyPaged from ._paged_models import DatabaseOperationPaged @@ -407,6 +411,8 @@ from ._paged_models import VirtualClusterPaged from ._paged_models import VirtualNetworkRulePaged from ._paged_models import VulnerabilityAssessmentScanRecordPaged +from ._paged_models import WorkloadClassifierPaged +from ._paged_models import WorkloadGroupPaged from ._sql_management_client_enums import ( CheckNameAvailabilityReason, ServerConnectionType, @@ -655,6 +661,8 @@ 'VulnerabilityAssessmentRecurringScansProperties', 'VulnerabilityAssessmentScanError', 'VulnerabilityAssessmentScanRecord', + 'WorkloadClassifier', + 'WorkloadGroup', 'RecoverableDatabasePaged', 'RestorableDroppedDatabasePaged', 'ServerPaged', @@ -668,7 +676,6 @@ 'RecommendedElasticPoolPaged', 'RecommendedElasticPoolMetricPaged', 'ReplicationLinkPaged', - 'ServerAzureADAdministratorPaged', 'ServerCommunicationLinkPaged', 'ServiceObjectivePaged', 'ElasticPoolActivityPaged', @@ -727,6 +734,9 @@ 'ManagedDatabasePaged', 'PrivateEndpointConnectionPaged', 'PrivateLinkResourcePaged', + 'ServerAzureADAdministratorPaged', + 'WorkloadGroupPaged', + 'WorkloadClassifierPaged', 'CheckNameAvailabilityReason', 'ServerConnectionType', 'SecurityAlertPolicyState', 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 4ce5123d8bb0..71bc98fdd9d5 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 @@ -7123,7 +7123,7 @@ def __init__(self, **kwargs): class ServerAzureADAdministrator(ProxyResource): - """An server Active Directory Administrator. + """Azure Active Directory administrator. Variables are only populated by the server, and will be ignored when sending a request. @@ -7136,15 +7136,14 @@ class ServerAzureADAdministrator(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :ivar administrator_type: Required. The type of administrator. Default - value: "ActiveDirectory" . + :ivar administrator_type: Required. Type of the sever administrator. + Default value: "ActiveDirectory" . :vartype administrator_type: str - :param login: Required. The server administrator login value. + :param login: Required. Login name of the server administrator. :type login: str - :param sid: Required. The server administrator Sid (Secure ID). + :param sid: Required. SID (object ID) of the server administrator. :type sid: str - :param tenant_id: Required. The server Active Directory Administrator - tenant id. + :param tenant_id: Tenant ID of the administrator. :type tenant_id: str """ @@ -7155,7 +7154,6 @@ class ServerAzureADAdministrator(ProxyResource): 'administrator_type': {'required': True, 'constant': True}, 'login': {'required': True}, 'sid': {'required': True}, - 'tenant_id': {'required': True}, } _attribute_map = { @@ -9247,3 +9245,124 @@ def __init__(self, **kwargs): self.errors = None self.storage_container_path = None self.number_of_failed_security_checks = None + + +class WorkloadClassifier(ProxyResource): + """Workload classifier operations for a data warehouse. + + 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 member_name: Required. The workload classifier member name. + :type member_name: str + :param label: The workload classifier label. + :type label: str + :param context: The workload classifier context. + :type context: str + :param start_time: The workload classifier start time for classification. + :type start_time: str + :param end_time: The workload classifier end time for classification. + :type end_time: str + :param importance: The workload classifier importance. + :type importance: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'member_name': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'member_name': {'key': 'properties.memberName', 'type': 'str'}, + 'label': {'key': 'properties.label', 'type': 'str'}, + 'context': {'key': 'properties.context', 'type': 'str'}, + 'start_time': {'key': 'properties.startTime', 'type': 'str'}, + 'end_time': {'key': 'properties.endTime', 'type': 'str'}, + 'importance': {'key': 'properties.importance', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(WorkloadClassifier, self).__init__(**kwargs) + self.member_name = kwargs.get('member_name', None) + self.label = kwargs.get('label', None) + self.context = kwargs.get('context', None) + self.start_time = kwargs.get('start_time', None) + self.end_time = kwargs.get('end_time', None) + self.importance = kwargs.get('importance', None) + + +class WorkloadGroup(ProxyResource): + """Workload group operations for a data warehouse. + + 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 min_resource_percent: Required. The workload group minimum + percentage resource. + :type min_resource_percent: int + :param max_resource_percent: Required. The workload group cap percentage + resource. + :type max_resource_percent: int + :param min_resource_percent_per_request: Required. The workload group + request minimum grant percentage. + :type min_resource_percent_per_request: float + :param max_resource_percent_per_request: The workload group request + maximum grant percentage. + :type max_resource_percent_per_request: float + :param importance: The workload group importance level. + :type importance: str + :param query_execution_timeout: The workload group query execution + timeout. + :type query_execution_timeout: int + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'min_resource_percent': {'required': True}, + 'max_resource_percent': {'required': True}, + 'min_resource_percent_per_request': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'min_resource_percent': {'key': 'properties.minResourcePercent', 'type': 'int'}, + 'max_resource_percent': {'key': 'properties.maxResourcePercent', 'type': 'int'}, + 'min_resource_percent_per_request': {'key': 'properties.minResourcePercentPerRequest', 'type': 'float'}, + 'max_resource_percent_per_request': {'key': 'properties.maxResourcePercentPerRequest', 'type': 'float'}, + 'importance': {'key': 'properties.importance', 'type': 'str'}, + 'query_execution_timeout': {'key': 'properties.queryExecutionTimeout', 'type': 'int'}, + } + + def __init__(self, **kwargs): + super(WorkloadGroup, self).__init__(**kwargs) + self.min_resource_percent = kwargs.get('min_resource_percent', None) + self.max_resource_percent = kwargs.get('max_resource_percent', None) + self.min_resource_percent_per_request = kwargs.get('min_resource_percent_per_request', None) + self.max_resource_percent_per_request = kwargs.get('max_resource_percent_per_request', None) + self.importance = kwargs.get('importance', None) + self.query_execution_timeout = kwargs.get('query_execution_timeout', 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 7a6646a15ec2..a3201444ad76 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 @@ -7123,7 +7123,7 @@ def __init__(self, *, desired_state=None, options=None, **kwargs) -> None: class ServerAzureADAdministrator(ProxyResource): - """An server Active Directory Administrator. + """Azure Active Directory administrator. Variables are only populated by the server, and will be ignored when sending a request. @@ -7136,15 +7136,14 @@ class ServerAzureADAdministrator(ProxyResource): :vartype name: str :ivar type: Resource type. :vartype type: str - :ivar administrator_type: Required. The type of administrator. Default - value: "ActiveDirectory" . + :ivar administrator_type: Required. Type of the sever administrator. + Default value: "ActiveDirectory" . :vartype administrator_type: str - :param login: Required. The server administrator login value. + :param login: Required. Login name of the server administrator. :type login: str - :param sid: Required. The server administrator Sid (Secure ID). + :param sid: Required. SID (object ID) of the server administrator. :type sid: str - :param tenant_id: Required. The server Active Directory Administrator - tenant id. + :param tenant_id: Tenant ID of the administrator. :type tenant_id: str """ @@ -7155,7 +7154,6 @@ class ServerAzureADAdministrator(ProxyResource): 'administrator_type': {'required': True, 'constant': True}, 'login': {'required': True}, 'sid': {'required': True}, - 'tenant_id': {'required': True}, } _attribute_map = { @@ -7170,7 +7168,7 @@ class ServerAzureADAdministrator(ProxyResource): administrator_type = "ActiveDirectory" - def __init__(self, *, login: str, sid: str, tenant_id: str, **kwargs) -> None: + def __init__(self, *, login: str, sid: str, tenant_id: str=None, **kwargs) -> None: super(ServerAzureADAdministrator, self).__init__(**kwargs) self.login = login self.sid = sid @@ -9247,3 +9245,124 @@ def __init__(self, **kwargs) -> None: self.errors = None self.storage_container_path = None self.number_of_failed_security_checks = None + + +class WorkloadClassifier(ProxyResource): + """Workload classifier operations for a data warehouse. + + 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 member_name: Required. The workload classifier member name. + :type member_name: str + :param label: The workload classifier label. + :type label: str + :param context: The workload classifier context. + :type context: str + :param start_time: The workload classifier start time for classification. + :type start_time: str + :param end_time: The workload classifier end time for classification. + :type end_time: str + :param importance: The workload classifier importance. + :type importance: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'member_name': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'member_name': {'key': 'properties.memberName', 'type': 'str'}, + 'label': {'key': 'properties.label', 'type': 'str'}, + 'context': {'key': 'properties.context', 'type': 'str'}, + 'start_time': {'key': 'properties.startTime', 'type': 'str'}, + 'end_time': {'key': 'properties.endTime', 'type': 'str'}, + 'importance': {'key': 'properties.importance', 'type': 'str'}, + } + + def __init__(self, *, member_name: str, label: str=None, context: str=None, start_time: str=None, end_time: str=None, importance: str=None, **kwargs) -> None: + super(WorkloadClassifier, self).__init__(**kwargs) + self.member_name = member_name + self.label = label + self.context = context + self.start_time = start_time + self.end_time = end_time + self.importance = importance + + +class WorkloadGroup(ProxyResource): + """Workload group operations for a data warehouse. + + 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 min_resource_percent: Required. The workload group minimum + percentage resource. + :type min_resource_percent: int + :param max_resource_percent: Required. The workload group cap percentage + resource. + :type max_resource_percent: int + :param min_resource_percent_per_request: Required. The workload group + request minimum grant percentage. + :type min_resource_percent_per_request: float + :param max_resource_percent_per_request: The workload group request + maximum grant percentage. + :type max_resource_percent_per_request: float + :param importance: The workload group importance level. + :type importance: str + :param query_execution_timeout: The workload group query execution + timeout. + :type query_execution_timeout: int + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'min_resource_percent': {'required': True}, + 'max_resource_percent': {'required': True}, + 'min_resource_percent_per_request': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'min_resource_percent': {'key': 'properties.minResourcePercent', 'type': 'int'}, + 'max_resource_percent': {'key': 'properties.maxResourcePercent', 'type': 'int'}, + 'min_resource_percent_per_request': {'key': 'properties.minResourcePercentPerRequest', 'type': 'float'}, + 'max_resource_percent_per_request': {'key': 'properties.maxResourcePercentPerRequest', 'type': 'float'}, + 'importance': {'key': 'properties.importance', 'type': 'str'}, + 'query_execution_timeout': {'key': 'properties.queryExecutionTimeout', 'type': 'int'}, + } + + def __init__(self, *, min_resource_percent: int, max_resource_percent: int, min_resource_percent_per_request: float, max_resource_percent_per_request: float=None, importance: str=None, query_execution_timeout: int=None, **kwargs) -> None: + super(WorkloadGroup, self).__init__(**kwargs) + self.min_resource_percent = min_resource_percent + self.max_resource_percent = max_resource_percent + self.min_resource_percent_per_request = min_resource_percent_per_request + self.max_resource_percent_per_request = max_resource_percent_per_request + self.importance = importance + self.query_execution_timeout = query_execution_timeout 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 75381a28f519..8b5d9a2a8e24 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 @@ -181,19 +181,6 @@ class ReplicationLinkPaged(Paged): def __init__(self, *args, **kwargs): super(ReplicationLinkPaged, self).__init__(*args, **kwargs) -class ServerAzureADAdministratorPaged(Paged): - """ - A paging container for iterating over a list of :class:`ServerAzureADAdministrator ` object - """ - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'current_page': {'key': 'value', 'type': '[ServerAzureADAdministrator]'} - } - - def __init__(self, *args, **kwargs): - - super(ServerAzureADAdministratorPaged, self).__init__(*args, **kwargs) class ServerCommunicationLinkPaged(Paged): """ A paging container for iterating over a list of :class:`ServerCommunicationLink ` object @@ -948,3 +935,42 @@ class PrivateLinkResourcePaged(Paged): def __init__(self, *args, **kwargs): super(PrivateLinkResourcePaged, self).__init__(*args, **kwargs) +class ServerAzureADAdministratorPaged(Paged): + """ + A paging container for iterating over a list of :class:`ServerAzureADAdministrator ` object + """ + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'current_page': {'key': 'value', 'type': '[ServerAzureADAdministrator]'} + } + + def __init__(self, *args, **kwargs): + + super(ServerAzureADAdministratorPaged, self).__init__(*args, **kwargs) +class WorkloadGroupPaged(Paged): + """ + A paging container for iterating over a list of :class:`WorkloadGroup ` object + """ + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'current_page': {'key': 'value', 'type': '[WorkloadGroup]'} + } + + def __init__(self, *args, **kwargs): + + super(WorkloadGroupPaged, self).__init__(*args, **kwargs) +class WorkloadClassifierPaged(Paged): + """ + A paging container for iterating over a list of :class:`WorkloadClassifier ` object + """ + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'current_page': {'key': 'value', 'type': '[WorkloadClassifier]'} + } + + def __init__(self, *args, **kwargs): + + super(WorkloadClassifierPaged, 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 306f66028ce5..dda3e3d1aed2 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 @@ -22,7 +22,6 @@ from ._elastic_pools_operations import ElasticPoolsOperations from ._recommended_elastic_pools_operations import RecommendedElasticPoolsOperations from ._replication_links_operations import ReplicationLinksOperations -from ._server_azure_ad_administrators_operations import ServerAzureADAdministratorsOperations from ._server_communication_links_operations import ServerCommunicationLinksOperations from ._service_objectives_operations import ServiceObjectivesOperations from ._elastic_pool_activities_operations import ElasticPoolActivitiesOperations @@ -95,6 +94,9 @@ from ._managed_databases_operations import ManagedDatabasesOperations from ._private_endpoint_connections_operations import PrivateEndpointConnectionsOperations from ._private_link_resources_operations import PrivateLinkResourcesOperations +from ._server_azure_ad_administrators_operations import ServerAzureADAdministratorsOperations +from ._workload_groups_operations import WorkloadGroupsOperations +from ._workload_classifiers_operations import WorkloadClassifiersOperations __all__ = [ 'RecoverableDatabasesOperations', @@ -110,7 +112,6 @@ 'ElasticPoolsOperations', 'RecommendedElasticPoolsOperations', 'ReplicationLinksOperations', - 'ServerAzureADAdministratorsOperations', 'ServerCommunicationLinksOperations', 'ServiceObjectivesOperations', 'ElasticPoolActivitiesOperations', @@ -183,4 +184,7 @@ 'ManagedDatabasesOperations', 'PrivateEndpointConnectionsOperations', 'PrivateLinkResourcesOperations', + 'ServerAzureADAdministratorsOperations', + 'WorkloadGroupsOperations', + 'WorkloadClassifiersOperations', ] diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_azure_ad_administrators_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_azure_ad_administrators_operations.py index 7fdf686673b7..26bc6441d307 100644 --- a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_azure_ad_administrators_operations.py +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_server_azure_ad_administrators_operations.py @@ -27,8 +27,8 @@ class ServerAzureADAdministratorsOperations(object): :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: "2014-04-01". - :ivar administrator_name: Name of the server administrator resource. Constant value: "activeDirectory". + :ivar api_version: The API version to use for the request. Constant value: "2018-06-01-preview". + :ivar administrator_name: The name of server active directory administrator. Constant value: "ActiveDirectory". """ models = models @@ -38,14 +38,78 @@ def __init__(self, client, config, serializer, deserializer): self._client = client self._serialize = serializer self._deserialize = deserializer - self.api_version = "2014-04-01" - self.administrator_name = "activeDirectory" + self.api_version = "2018-06-01-preview" + self.administrator_name = "ActiveDirectory" self.config = config + def get( + self, resource_group_name, server_name, custom_headers=None, raw=False, **operation_config): + """Gets a server Administrator. + + :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: ServerAzureADAdministrator or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.sql.models.ServerAzureADAdministrator or + ~msrest.pipeline.ClientRawResponse + :raises: :class:`CloudError` + """ + # Construct URL + url = self.get.metadata['url'] + path_format_arguments = { + 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), + 'serverName': self._serialize.url("server_name", server_name, 'str'), + 'administratorName': self._serialize.url("self.administrator_name", self.administrator_name, '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('ServerAzureADAdministrator', 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}/administrators/{administratorName}'} + def _create_or_update_initial( - self, resource_group_name, server_name, properties, custom_headers=None, raw=False, **operation_config): + self, resource_group_name, server_name, parameters, custom_headers=None, raw=False, **operation_config): # Construct URL url = self.create_or_update.metadata['url'] path_format_arguments = { @@ -72,7 +136,7 @@ def _create_or_update_initial( header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') # Construct body - body_content = self._serialize.body(properties, 'ServerAzureADAdministrator') + body_content = self._serialize.body(parameters, 'ServerAzureADAdministrator') # Construct and send request request = self._client.put(url, query_parameters, header_parameters, body_content) @@ -89,8 +153,6 @@ def _create_or_update_initial( deserialized = self._deserialize('ServerAzureADAdministrator', response) if response.status_code == 201: deserialized = self._deserialize('ServerAzureADAdministrator', response) - if response.status_code == 202: - deserialized = self._deserialize('ServerAzureADAdministrator', response) if raw: client_raw_response = ClientRawResponse(deserialized, response) @@ -99,7 +161,7 @@ def _create_or_update_initial( return deserialized def create_or_update( - self, resource_group_name, server_name, properties, custom_headers=None, raw=False, polling=True, **operation_config): + self, resource_group_name, server_name, parameters, custom_headers=None, raw=False, polling=True, **operation_config): """Creates a new Server Active Directory Administrator or updates an existing server Active Directory Administrator. @@ -109,9 +171,9 @@ def create_or_update( :type resource_group_name: str :param server_name: The name of the server. :type server_name: str - :param properties: The required parameters for creating or updating an + :param parameters: The required parameters for creating or updating an Active Directory Administrator. - :type properties: ~azure.mgmt.sql.models.ServerAzureADAdministrator + :type parameters: ~azure.mgmt.sql.models.ServerAzureADAdministrator :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 @@ -129,7 +191,7 @@ def create_or_update( raw_result = self._create_or_update_initial( resource_group_name=resource_group_name, server_name=server_name, - properties=properties, + parameters=parameters, custom_headers=custom_headers, raw=True, **operation_config @@ -172,7 +234,6 @@ def _delete_initial( # 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: @@ -189,21 +250,10 @@ def _delete_initial( exp.request_id = response.headers.get('x-ms-request-id') raise exp - deserialized = None - - if response.status_code == 200: - deserialized = self._deserialize('ServerAzureADAdministrator', response) - if response.status_code == 202: - deserialized = self._deserialize('ServerAzureADAdministrator', response) - if response.status_code == 204: - deserialized = self._deserialize('ServerAzureADAdministrator', response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) + client_raw_response = ClientRawResponse(None, response) return client_raw_response - return deserialized - def delete( self, resource_group_name, server_name, custom_headers=None, raw=False, polling=True, **operation_config): """Deletes an existing server Active Directory Administrator. @@ -219,13 +269,10 @@ def delete( 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 - ServerAzureADAdministrator or - ClientRawResponse if raw==True - :rtype: - ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.sql.models.ServerAzureADAdministrator] - or - ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.sql.models.ServerAzureADAdministrator]] + :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( @@ -237,14 +284,10 @@ def delete( ) def get_long_running_output(response): - deserialized = self._deserialize('ServerAzureADAdministrator', response) - if raw: - client_raw_response = ClientRawResponse(deserialized, response) + client_raw_response = ClientRawResponse(None, response) return client_raw_response - return deserialized - lro_delay = operation_config.get( 'long_running_operation_timeout', self.config.long_running_operation_timeout) @@ -254,73 +297,9 @@ def get_long_running_output(response): return LROPoller(self._client, raw_result, get_long_running_output, polling_method) delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/administrators/{administratorName}'} - def get( - self, resource_group_name, server_name, custom_headers=None, raw=False, **operation_config): - """Returns an server Administrator. - - :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: ServerAzureADAdministrator or ClientRawResponse if raw=true - :rtype: ~azure.mgmt.sql.models.ServerAzureADAdministrator or - ~msrest.pipeline.ClientRawResponse - :raises: :class:`CloudError` - """ - # Construct URL - url = self.get.metadata['url'] - path_format_arguments = { - 'subscriptionId': self._serialize.url("self.config.subscription_id", self.config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'serverName': self._serialize.url("server_name", server_name, 'str'), - 'administratorName': self._serialize.url("self.administrator_name", self.administrator_name, '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('ServerAzureADAdministrator', 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}/administrators/{administratorName}'} - def list_by_server( self, resource_group_name, server_name, custom_headers=None, raw=False, **operation_config): - """Returns a list of server Administrators. + """Gets a list of server Administrators. :param resource_group_name: The name of the resource group that contains the resource. You can obtain this value from the Azure diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_workload_classifiers_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_workload_classifiers_operations.py new file mode 100644 index 000000000000..c1e2c5ea728b --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_workload_classifiers_operations.py @@ -0,0 +1,409 @@ +# 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 WorkloadClassifiersOperations(object): + """WorkloadClassifiersOperations 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: "2019-06-01-preview". + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self.api_version = "2019-06-01-preview" + + self.config = config + + def get( + self, resource_group_name, server_name, database_name, workload_group_name, workload_classifier_name, custom_headers=None, raw=False, **operation_config): + """Gets a workload classifier. + + :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 database_name: The name of the database. + :type database_name: str + :param workload_group_name: The name of the workload group from which + to receive the classifier from. + :type workload_group_name: str + :param workload_classifier_name: The name of the workload classifier. + :type workload_classifier_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: WorkloadClassifier or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.sql.models.WorkloadClassifier 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'), + 'databaseName': self._serialize.url("database_name", database_name, 'str'), + 'workloadGroupName': self._serialize.url("workload_group_name", workload_group_name, 'str'), + 'workloadClassifierName': self._serialize.url("workload_classifier_name", workload_classifier_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('WorkloadClassifier', 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}/databases/{databaseName}/workloadGroups/{workloadGroupName}/workloadClassifiers/{workloadClassifierName}'} + + + def _create_or_update_initial( + self, resource_group_name, server_name, database_name, workload_group_name, workload_classifier_name, parameters, custom_headers=None, raw=False, **operation_config): + # Construct URL + url = self.create_or_update.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'), + 'databaseName': self._serialize.url("database_name", database_name, 'str'), + 'workloadGroupName': self._serialize.url("workload_group_name", workload_group_name, 'str'), + 'workloadClassifierName': self._serialize.url("workload_classifier_name", workload_classifier_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, 'WorkloadClassifier') + + # 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('WorkloadClassifier', response) + if response.status_code == 201: + deserialized = self._deserialize('WorkloadClassifier', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + def create_or_update( + self, resource_group_name, server_name, database_name, workload_group_name, workload_classifier_name, parameters, custom_headers=None, raw=False, polling=True, **operation_config): + """Creates or updates a workload classifier. + + :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 database_name: The name of the database. + :type database_name: str + :param workload_group_name: The name of the workload group from which + to receive the classifier from. + :type workload_group_name: str + :param workload_classifier_name: The name of the workload classifier + to create/update. + :type workload_classifier_name: str + :param parameters: The properties of the workload classifier. + :type parameters: ~azure.mgmt.sql.models.WorkloadClassifier + :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 WorkloadClassifier or + ClientRawResponse if raw==True + :rtype: + ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.sql.models.WorkloadClassifier] + or + ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.sql.models.WorkloadClassifier]] + :raises: :class:`CloudError` + """ + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + workload_group_name=workload_group_name, + workload_classifier_name=workload_classifier_name, + parameters=parameters, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + + def get_long_running_output(response): + deserialized = self._deserialize('WorkloadClassifier', 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/servers/{serverName}/databases/{databaseName}/workloadGroups/{workloadGroupName}/workloadClassifiers/{workloadClassifierName}'} + + + def _delete_initial( + self, resource_group_name, server_name, database_name, workload_group_name, workload_classifier_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'), + 'serverName': self._serialize.url("server_name", server_name, 'str'), + 'databaseName': self._serialize.url("database_name", database_name, 'str'), + 'workloadGroupName': self._serialize.url("workload_group_name", workload_group_name, 'str'), + 'workloadClassifierName': self._serialize.url("workload_classifier_name", workload_classifier_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, server_name, database_name, workload_group_name, workload_classifier_name, custom_headers=None, raw=False, polling=True, **operation_config): + """Deletes a workload classifier. + + :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 database_name: The name of the database. + :type database_name: str + :param workload_group_name: The name of the workload group from which + to receive the classifier from. + :type workload_group_name: str + :param workload_classifier_name: The name of the workload classifier + to delete. + :type workload_classifier_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, + server_name=server_name, + database_name=database_name, + workload_group_name=workload_group_name, + workload_classifier_name=workload_classifier_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/servers/{serverName}/databases/{databaseName}/workloadGroups/{workloadGroupName}/workloadClassifiers/{workloadClassifierName}'} + + def list_by_workload_group( + self, resource_group_name, server_name, database_name, workload_group_name, custom_headers=None, raw=False, **operation_config): + """Gets the list of workload classifiers for a workload 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 server_name: The name of the server. + :type server_name: str + :param database_name: The name of the database. + :type database_name: str + :param workload_group_name: The name of the workload group from which + to receive the classifiers from. + :type workload_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: An iterator like instance of WorkloadClassifier + :rtype: + ~azure.mgmt.sql.models.WorkloadClassifierPaged[~azure.mgmt.sql.models.WorkloadClassifier] + :raises: :class:`CloudError` + """ + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list_by_workload_group.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'), + 'databaseName': self._serialize.url("database_name", database_name, 'str'), + 'workloadGroupName': self._serialize.url("workload_group_name", workload_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') + + 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.WorkloadClassifierPaged(internal_paging, self._deserialize.dependencies, header_dict) + + return deserialized + list_by_workload_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups/{workloadGroupName}/workloadClassifiers'} diff --git a/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_workload_groups_operations.py b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_workload_groups_operations.py new file mode 100644 index 000000000000..5f1e5e208d17 --- /dev/null +++ b/sdk/sql/azure-mgmt-sql/azure/mgmt/sql/operations/_workload_groups_operations.py @@ -0,0 +1,389 @@ +# 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 WorkloadGroupsOperations(object): + """WorkloadGroupsOperations 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: "2019-06-01-preview". + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self.api_version = "2019-06-01-preview" + + self.config = config + + def get( + self, resource_group_name, server_name, database_name, workload_group_name, custom_headers=None, raw=False, **operation_config): + """Gets a workload 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 server_name: The name of the server. + :type server_name: str + :param database_name: The name of the database. + :type database_name: str + :param workload_group_name: The name of the workload group. + :type workload_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: WorkloadGroup or ClientRawResponse if raw=true + :rtype: ~azure.mgmt.sql.models.WorkloadGroup 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'), + 'databaseName': self._serialize.url("database_name", database_name, 'str'), + 'workloadGroupName': self._serialize.url("workload_group_name", workload_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('WorkloadGroup', 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}/databases/{databaseName}/workloadGroups/{workloadGroupName}'} + + + def _create_or_update_initial( + self, resource_group_name, server_name, database_name, workload_group_name, parameters, custom_headers=None, raw=False, **operation_config): + # Construct URL + url = self.create_or_update.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'), + 'databaseName': self._serialize.url("database_name", database_name, 'str'), + 'workloadGroupName': self._serialize.url("workload_group_name", workload_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, 'WorkloadGroup') + + # 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('WorkloadGroup', response) + if response.status_code == 201: + deserialized = self._deserialize('WorkloadGroup', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + + def create_or_update( + self, resource_group_name, server_name, database_name, workload_group_name, parameters, custom_headers=None, raw=False, polling=True, **operation_config): + """Creates or updates a workload 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 server_name: The name of the server. + :type server_name: str + :param database_name: The name of the database. + :type database_name: str + :param workload_group_name: The name of the workload group. + :type workload_group_name: str + :param parameters: The requested workload group state. + :type parameters: ~azure.mgmt.sql.models.WorkloadGroup + :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 WorkloadGroup or + ClientRawResponse if raw==True + :rtype: + ~msrestazure.azure_operation.AzureOperationPoller[~azure.mgmt.sql.models.WorkloadGroup] + or + ~msrestazure.azure_operation.AzureOperationPoller[~msrest.pipeline.ClientRawResponse[~azure.mgmt.sql.models.WorkloadGroup]] + :raises: :class:`CloudError` + """ + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + server_name=server_name, + database_name=database_name, + workload_group_name=workload_group_name, + parameters=parameters, + custom_headers=custom_headers, + raw=True, + **operation_config + ) + + def get_long_running_output(response): + deserialized = self._deserialize('WorkloadGroup', 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/servers/{serverName}/databases/{databaseName}/workloadGroups/{workloadGroupName}'} + + + def _delete_initial( + self, resource_group_name, server_name, database_name, workload_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'), + 'serverName': self._serialize.url("server_name", server_name, 'str'), + 'databaseName': self._serialize.url("database_name", database_name, 'str'), + 'workloadGroupName': self._serialize.url("workload_group_name", workload_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, server_name, database_name, workload_group_name, custom_headers=None, raw=False, polling=True, **operation_config): + """Deletes a workload 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 server_name: The name of the server. + :type server_name: str + :param database_name: The name of the database. + :type database_name: str + :param workload_group_name: The name of the workload group to delete. + :type workload_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, + server_name=server_name, + database_name=database_name, + workload_group_name=workload_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/servers/{serverName}/databases/{databaseName}/workloadGroups/{workloadGroupName}'} + + def list_by_database( + self, resource_group_name, server_name, database_name, custom_headers=None, raw=False, **operation_config): + """Gets the list of workload groups. + + :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 database_name: The name of the database. + :type database_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 WorkloadGroup + :rtype: + ~azure.mgmt.sql.models.WorkloadGroupPaged[~azure.mgmt.sql.models.WorkloadGroup] + :raises: :class:`CloudError` + """ + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list_by_database.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'), + 'databaseName': self._serialize.url("database_name", database_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.WorkloadGroupPaged(internal_paging, self._deserialize.dependencies, header_dict) + + return deserialized + list_by_database.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Sql/servers/{serverName}/databases/{databaseName}/workloadGroups'}