From f2f7f617c348e76d6fcc4ba4a3e86b3a815110e7 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Fri, 8 Apr 2022 08:22:55 +0000 Subject: [PATCH] CodeGen from PR 18619 in Azure/azure-rest-api-specs Update readme.python.md (#18619) --- sdk/rdbms/azure-mgmt-rdbms/_meta.json | 6 +- .../mgmt/rdbms/postgresqlhsc/__init__.py | 18 + .../rdbms/postgresqlhsc/_configuration.py | 68 + .../mgmt/rdbms/postgresqlhsc/_metadata.json | 107 + .../_microsoft_postgre_sql_hyperscale.py | 108 + .../azure/mgmt/rdbms/postgresqlhsc/_patch.py | 31 + .../azure/mgmt/rdbms/postgresqlhsc/_vendor.py | 27 + .../mgmt/rdbms/postgresqlhsc/_version.py | 9 + .../mgmt/rdbms/postgresqlhsc/aio/__init__.py | 15 + .../rdbms/postgresqlhsc/aio/_configuration.py | 67 + .../aio/_microsoft_postgre_sql_hyperscale.py | 105 + .../mgmt/rdbms/postgresqlhsc/aio/_patch.py | 31 + .../postgresqlhsc/aio/operations/__init__.py | 23 + .../operations/_configurations_operations.py | 384 ++++ .../operations/_firewall_rules_operations.py | 408 ++++ .../aio/operations/_operations.py | 109 + .../aio/operations/_roles_operations.py | 351 ++++ .../operations/_server_groups_operations.py | 911 ++++++++ .../aio/operations/_servers_operations.py | 177 ++ .../rdbms/postgresqlhsc/models/__init__.py | 99 + ..._microsoft_postgre_sql_hyperscale_enums.py | 111 + .../rdbms/postgresqlhsc/models/_models_py3.py | 1850 +++++++++++++++++ .../postgresqlhsc/operations/__init__.py | 23 + .../operations/_configurations_operations.py | 541 +++++ .../operations/_firewall_rules_operations.py | 565 +++++ .../postgresqlhsc/operations/_operations.py | 135 ++ .../operations/_roles_operations.py | 470 +++++ .../operations/_server_groups_operations.py | 1280 ++++++++++++ .../operations/_servers_operations.py | 250 +++ .../azure/mgmt/rdbms/postgresqlhsc/py.typed | 1 + 30 files changed, 8277 insertions(+), 3 deletions(-) create mode 100644 sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/__init__.py create mode 100644 sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/_configuration.py create mode 100644 sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/_metadata.json create mode 100644 sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/_microsoft_postgre_sql_hyperscale.py create mode 100644 sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/_patch.py create mode 100644 sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/_vendor.py create mode 100644 sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/_version.py create mode 100644 sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/aio/__init__.py create mode 100644 sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/aio/_configuration.py create mode 100644 sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/aio/_microsoft_postgre_sql_hyperscale.py create mode 100644 sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/aio/_patch.py create mode 100644 sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/aio/operations/__init__.py create mode 100644 sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/aio/operations/_configurations_operations.py create mode 100644 sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/aio/operations/_firewall_rules_operations.py create mode 100644 sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/aio/operations/_operations.py create mode 100644 sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/aio/operations/_roles_operations.py create mode 100644 sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/aio/operations/_server_groups_operations.py create mode 100644 sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/aio/operations/_servers_operations.py create mode 100644 sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/models/__init__.py create mode 100644 sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/models/_microsoft_postgre_sql_hyperscale_enums.py create mode 100644 sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/models/_models_py3.py create mode 100644 sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/operations/__init__.py create mode 100644 sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/operations/_configurations_operations.py create mode 100644 sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/operations/_firewall_rules_operations.py create mode 100644 sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/operations/_operations.py create mode 100644 sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/operations/_roles_operations.py create mode 100644 sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/operations/_server_groups_operations.py create mode 100644 sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/operations/_servers_operations.py create mode 100644 sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/py.typed diff --git a/sdk/rdbms/azure-mgmt-rdbms/_meta.json b/sdk/rdbms/azure-mgmt-rdbms/_meta.json index db9196a798d2..1c14852bb5f7 100644 --- a/sdk/rdbms/azure-mgmt-rdbms/_meta.json +++ b/sdk/rdbms/azure-mgmt-rdbms/_meta.json @@ -4,8 +4,8 @@ "@autorest/python@5.12.0", "@autorest/modelerfour@4.19.3" ], - "commit": "6b29b8552671eded065f51ee1b291582ab8cc149", + "commit": "c995aec6c64982c15a1c334fb7d0e33d15d4f751", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/mysql/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --python3-only --track2 --use=@autorest/python@5.12.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", - "readme": "specification/mysql/resource-manager/readme.md" + "autorest_command": "autorest specification/postgresqlhsc/resource-manager/readme.md --multiapi --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --python3-only --use=@autorest/python@5.12.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", + "readme": "specification/postgresqlhsc/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/__init__.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/__init__.py new file mode 100644 index 000000000000..984e1e801fdf --- /dev/null +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/__init__.py @@ -0,0 +1,18 @@ +# 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 ._microsoft_postgre_sql_hyperscale import MicrosoftPostgreSQLHyperscale +from ._version import VERSION + +__version__ = VERSION +__all__ = ['MicrosoftPostgreSQLHyperscale'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/_configuration.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/_configuration.py new file mode 100644 index 000000000000..192bad1f66e3 --- /dev/null +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/_configuration.py @@ -0,0 +1,68 @@ +# 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 typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy + +from ._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + + +class MicrosoftPostgreSQLHyperscaleConfiguration(Configuration): + """Configuration for MicrosoftPostgreSQLHyperscale. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(MicrosoftPostgreSQLHyperscaleConfiguration, self).__init__(**kwargs) + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = "2020-10-05-privatepreview" + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-rdbms/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs # type: Any + ): + # type: (...) -> None + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/_metadata.json b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/_metadata.json new file mode 100644 index 000000000000..8676f0d9ed2e --- /dev/null +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/_metadata.json @@ -0,0 +1,107 @@ +{ + "chosen_version": "2020-10-05-privatepreview", + "total_api_version_list": ["2020-10-05-privatepreview"], + "client": { + "name": "MicrosoftPostgreSQLHyperscale", + "filename": "_microsoft_postgre_sql_hyperscale", + "description": "The Microsoft Azure management API provides create, read, update, and delete functionality for Azure PostgreSQL Hyperscale (Citus) resources including server groups, servers, databases, firewall rules, VNET rules, security alert policies, log files and configurations.", + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, + "azure_arm": true, + "has_lro_operations": true, + "client_side_validation": false, + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MicrosoftPostgreSQLHyperscaleConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MicrosoftPostgreSQLHyperscaleConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" + }, + "global_parameters": { + "sync": { + "credential": { + "signature": "credential, # type: \"TokenCredential\"", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials.TokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id, # type: str", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "async": { + "credential": { + "signature": "credential: \"AsyncTokenCredential\",", + "description": "Credential needed for the client to connect to Azure.", + "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", + "required": true + }, + "subscription_id": { + "signature": "subscription_id: str,", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id", + "service_client_specific": { + "sync": { + "api_version": { + "signature": "api_version=None, # type: Optional[str]", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url=\"https://management.azure.com\", # type: str", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile=KnownProfiles.default, # type: KnownProfiles", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + }, + "async": { + "api_version": { + "signature": "api_version: Optional[str] = None,", + "description": "API version to use if no profile is provided, or if missing in profile.", + "docstring_type": "str", + "required": false + }, + "base_url": { + "signature": "base_url: str = \"https://management.azure.com\",", + "description": "Service URL", + "docstring_type": "str", + "required": false + }, + "profile": { + "signature": "profile: KnownProfiles = KnownProfiles.default,", + "description": "A profile definition, from KnownProfiles to dict.", + "docstring_type": "azure.profiles.KnownProfiles", + "required": false + } + } + } + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"], + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + }, + "operation_groups": { + "server_groups": "ServerGroupsOperations", + "servers": "ServersOperations", + "configurations": "ConfigurationsOperations", + "firewall_rules": "FirewallRulesOperations", + "roles": "RolesOperations", + "operations": "Operations" + } +} \ No newline at end of file diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/_microsoft_postgre_sql_hyperscale.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/_microsoft_postgre_sql_hyperscale.py new file mode 100644 index 000000000000..d1c68793f0c4 --- /dev/null +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/_microsoft_postgre_sql_hyperscale.py @@ -0,0 +1,108 @@ +# 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 copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING + +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +from . import models +from ._configuration import MicrosoftPostgreSQLHyperscaleConfiguration +from .operations import ConfigurationsOperations, FirewallRulesOperations, Operations, RolesOperations, ServerGroupsOperations, ServersOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential + +class MicrosoftPostgreSQLHyperscale: + """The Microsoft Azure management API provides create, read, update, and delete functionality for Azure PostgreSQL Hyperscale (Citus) resources including server groups, servers, databases, firewall rules, VNET rules, security alert policies, log files and configurations. + + :ivar server_groups: ServerGroupsOperations operations + :vartype server_groups: azure.mgmt.rdbms.postgresqlhsc.operations.ServerGroupsOperations + :ivar servers: ServersOperations operations + :vartype servers: azure.mgmt.rdbms.postgresqlhsc.operations.ServersOperations + :ivar configurations: ConfigurationsOperations operations + :vartype configurations: azure.mgmt.rdbms.postgresqlhsc.operations.ConfigurationsOperations + :ivar firewall_rules: FirewallRulesOperations operations + :vartype firewall_rules: azure.mgmt.rdbms.postgresqlhsc.operations.FirewallRulesOperations + :ivar roles: RolesOperations operations + :vartype roles: azure.mgmt.rdbms.postgresqlhsc.operations.RolesOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.rdbms.postgresqlhsc.operations.Operations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials.TokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = MicrosoftPostgreSQLHyperscaleConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.server_groups = ServerGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.servers = ServersOperations(self._client, self._config, self._serialize, self._deserialize) + self.configurations = ConfigurationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.firewall_rules = FirewallRulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.roles = RolesOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + + + def _send_request( + self, + request, # type: HttpRequest + **kwargs: Any + ) -> HttpResponse: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.HttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + def close(self): + # type: () -> None + self._client.close() + + def __enter__(self): + # type: () -> MicrosoftPostgreSQLHyperscale + self._client.__enter__() + return self + + def __exit__(self, *exc_details): + # type: (Any) -> None + self._client.__exit__(*exc_details) diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/_patch.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/_vendor.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# 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 azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/_version.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/_version.py new file mode 100644 index 000000000000..e5754a47ce68 --- /dev/null +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/_version.py @@ -0,0 +1,9 @@ +# 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. +# -------------------------------------------------------------------------- + +VERSION = "1.0.0b1" diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/aio/__init__.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/aio/__init__.py new file mode 100644 index 000000000000..7bb0df127fea --- /dev/null +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/aio/__init__.py @@ -0,0 +1,15 @@ +# 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 ._microsoft_postgre_sql_hyperscale import MicrosoftPostgreSQLHyperscale +__all__ = ['MicrosoftPostgreSQLHyperscale'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/aio/_configuration.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/aio/_configuration.py new file mode 100644 index 000000000000..873f166e8913 --- /dev/null +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/aio/_configuration.py @@ -0,0 +1,67 @@ +# 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 typing import Any, TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy + +from .._version import VERSION + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + + +class MicrosoftPostgreSQLHyperscaleConfiguration(Configuration): + """Configuration for MicrosoftPostgreSQLHyperscale. + + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(MicrosoftPostgreSQLHyperscaleConfiguration, self).__init__(**kwargs) + if credential is None: + raise ValueError("Parameter 'credential' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + + self.credential = credential + self.subscription_id = subscription_id + self.api_version = "2020-10-05-privatepreview" + self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) + kwargs.setdefault('sdk_moniker', 'mgmt-rdbms/{}'.format(VERSION)) + self._configure(**kwargs) + + def _configure( + self, + **kwargs: Any + ) -> None: + self.user_agent_policy = kwargs.get('user_agent_policy') or policies.UserAgentPolicy(**kwargs) + self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) + self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) + self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) + self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) + self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) + self.authentication_policy = kwargs.get('authentication_policy') + if self.credential and not self.authentication_policy: + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/aio/_microsoft_postgre_sql_hyperscale.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/aio/_microsoft_postgre_sql_hyperscale.py new file mode 100644 index 000000000000..15fc0d5608ca --- /dev/null +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/aio/_microsoft_postgre_sql_hyperscale.py @@ -0,0 +1,105 @@ +# 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 copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING + +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +from .. import models +from ._configuration import MicrosoftPostgreSQLHyperscaleConfiguration +from .operations import ConfigurationsOperations, FirewallRulesOperations, Operations, RolesOperations, ServerGroupsOperations, ServersOperations + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +class MicrosoftPostgreSQLHyperscale: + """The Microsoft Azure management API provides create, read, update, and delete functionality for Azure PostgreSQL Hyperscale (Citus) resources including server groups, servers, databases, firewall rules, VNET rules, security alert policies, log files and configurations. + + :ivar server_groups: ServerGroupsOperations operations + :vartype server_groups: azure.mgmt.rdbms.postgresqlhsc.aio.operations.ServerGroupsOperations + :ivar servers: ServersOperations operations + :vartype servers: azure.mgmt.rdbms.postgresqlhsc.aio.operations.ServersOperations + :ivar configurations: ConfigurationsOperations operations + :vartype configurations: azure.mgmt.rdbms.postgresqlhsc.aio.operations.ConfigurationsOperations + :ivar firewall_rules: FirewallRulesOperations operations + :vartype firewall_rules: azure.mgmt.rdbms.postgresqlhsc.aio.operations.FirewallRulesOperations + :ivar roles: RolesOperations operations + :vartype roles: azure.mgmt.rdbms.postgresqlhsc.aio.operations.RolesOperations + :ivar operations: Operations operations + :vartype operations: azure.mgmt.rdbms.postgresqlhsc.aio.operations.Operations + :param credential: Credential needed for the client to connect to Azure. + :type credential: ~azure.core.credentials_async.AsyncTokenCredential + :param subscription_id: The ID of the target subscription. + :type subscription_id: str + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + """ + + def __init__( + self, + credential: "AsyncTokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = MicrosoftPostgreSQLHyperscaleConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) + self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.server_groups = ServerGroupsOperations(self._client, self._config, self._serialize, self._deserialize) + self.servers = ServersOperations(self._client, self._config, self._serialize, self._deserialize) + self.configurations = ConfigurationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.firewall_rules = FirewallRulesOperations(self._client, self._config, self._serialize, self._deserialize) + self.roles = RolesOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + + + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: + """Runs the network request through the client's chained policies. + + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. + :return: The response of your network call. Does not do error handling on your response. + :rtype: ~azure.core.rest.AsyncHttpResponse + """ + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) + + async def close(self) -> None: + await self._client.close() + + async def __aenter__(self) -> "MicrosoftPostgreSQLHyperscale": + await self._client.__aenter__() + return self + + async def __aexit__(self, *exc_details) -> None: + await self._client.__aexit__(*exc_details) diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/aio/_patch.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/aio/operations/__init__.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/aio/operations/__init__.py new file mode 100644 index 000000000000..9bd9cd11bf46 --- /dev/null +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/aio/operations/__init__.py @@ -0,0 +1,23 @@ +# 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 ._server_groups_operations import ServerGroupsOperations +from ._servers_operations import ServersOperations +from ._configurations_operations import ConfigurationsOperations +from ._firewall_rules_operations import FirewallRulesOperations +from ._roles_operations import RolesOperations +from ._operations import Operations + +__all__ = [ + 'ServerGroupsOperations', + 'ServersOperations', + 'ConfigurationsOperations', + 'FirewallRulesOperations', + 'RolesOperations', + 'Operations', +] diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/aio/operations/_configurations_operations.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/aio/operations/_configurations_operations.py new file mode 100644 index 000000000000..67afd412583c --- /dev/null +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/aio/operations/_configurations_operations.py @@ -0,0 +1,384 @@ +# 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 functools +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._configurations_operations import build_get_request, build_list_by_server_group_request, build_list_by_server_request, build_update_request_initial +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ConfigurationsOperations: + """ConfigurationsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.rdbms.postgresqlhsc.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list_by_server( + self, + resource_group_name: str, + server_group_name: str, + server_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.ServerConfigurationListResult"]: + """List all the configurations of a server in server group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param server_group_name: The name of the server group. + :type server_group_name: str + :param server_name: The name of the server. + :type server_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ServerConfigurationListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.rdbms.postgresqlhsc.models.ServerConfigurationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerConfigurationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_server_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_group_name=server_group_name, + server_name=server_name, + template_url=self.list_by_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_server_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_group_name=server_group_name, + server_name=server_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ServerConfigurationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_server.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}/servers/{serverName}/configurations'} # type: ignore + + @distributed_trace + def list_by_server_group( + self, + resource_group_name: str, + server_group_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.ServerGroupConfigurationListResult"]: + """List all the configurations of a server group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param server_group_name: The name of the server group. + :type server_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ServerGroupConfigurationListResult or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.rdbms.postgresqlhsc.models.ServerGroupConfigurationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerGroupConfigurationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_server_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_group_name=server_group_name, + template_url=self.list_by_server_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_server_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_group_name=server_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ServerGroupConfigurationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_server_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}/configurations'} # type: ignore + + async def _update_initial( + self, + resource_group_name: str, + server_group_name: str, + configuration_name: str, + parameters: "_models.ServerGroupConfiguration", + **kwargs: Any + ) -> Optional["_models.ServerGroupConfiguration"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ServerGroupConfiguration"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ServerGroupConfiguration') + + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_group_name=server_group_name, + configuration_name=configuration_name, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ServerGroupConfiguration', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}/configurations/{configurationName}'} # type: ignore + + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + server_group_name: str, + configuration_name: str, + parameters: "_models.ServerGroupConfiguration", + **kwargs: Any + ) -> AsyncLROPoller["_models.ServerGroupConfiguration"]: + """Updates configuration of server role groups in a server group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param server_group_name: The name of the server group. + :type server_group_name: str + :param configuration_name: The name of the server group configuration. + :type configuration_name: str + :param parameters: The required parameters for updating a server group configuration. + :type parameters: ~azure.mgmt.rdbms.postgresqlhsc.models.ServerGroupConfiguration + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ServerGroupConfiguration or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.rdbms.postgresqlhsc.models.ServerGroupConfiguration] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerGroupConfiguration"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + server_group_name=server_group_name, + configuration_name=configuration_name, + parameters=parameters, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('ServerGroupConfiguration', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}/configurations/{configurationName}'} # type: ignore + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + server_group_name: str, + configuration_name: str, + **kwargs: Any + ) -> "_models.ServerGroupConfiguration": + """Gets information about single server group configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param server_group_name: The name of the server group. + :type server_group_name: str + :param configuration_name: The name of the server group configuration. + :type configuration_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ServerGroupConfiguration, or the result of cls(response) + :rtype: ~azure.mgmt.rdbms.postgresqlhsc.models.ServerGroupConfiguration + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerGroupConfiguration"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_group_name=server_group_name, + configuration_name=configuration_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ServerGroupConfiguration', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}/configurations/{configurationName}'} # type: ignore + diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/aio/operations/_firewall_rules_operations.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/aio/operations/_firewall_rules_operations.py new file mode 100644 index 000000000000..7e54cab756d6 --- /dev/null +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/aio/operations/_firewall_rules_operations.py @@ -0,0 +1,408 @@ +# 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 functools +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._firewall_rules_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_server_group_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class FirewallRulesOperations: + """FirewallRulesOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.rdbms.postgresqlhsc.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def _create_or_update_initial( + self, + resource_group_name: str, + server_group_name: str, + firewall_rule_name: str, + parameters: "_models.FirewallRule", + **kwargs: Any + ) -> Optional["_models.FirewallRule"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.FirewallRule"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'FirewallRule') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_group_name=server_group_name, + firewall_rule_name=firewall_rule_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('FirewallRule', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('FirewallRule', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}/firewallRules/{firewallRuleName}'} # type: ignore + + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + server_group_name: str, + firewall_rule_name: str, + parameters: "_models.FirewallRule", + **kwargs: Any + ) -> AsyncLROPoller["_models.FirewallRule"]: + """Creates a new firewall rule or updates an existing firewall rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param server_group_name: The name of the server group. + :type server_group_name: str + :param firewall_rule_name: The name of the server group firewall rule. + :type firewall_rule_name: str + :param parameters: The required parameters for creating or updating a firewall rule. + :type parameters: ~azure.mgmt.rdbms.postgresqlhsc.models.FirewallRule + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either FirewallRule or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.rdbms.postgresqlhsc.models.FirewallRule] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.FirewallRule"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + server_group_name=server_group_name, + firewall_rule_name=firewall_rule_name, + parameters=parameters, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('FirewallRule', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}/firewallRules/{firewallRuleName}'} # type: ignore + + async def _delete_initial( + self, + resource_group_name: str, + server_group_name: str, + firewall_rule_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_group_name=server_group_name, + firewall_rule_name=firewall_rule_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}/firewallRules/{firewallRuleName}'} # type: ignore + + + @distributed_trace_async + async def begin_delete( + self, + resource_group_name: str, + server_group_name: str, + firewall_rule_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a server group firewall rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param server_group_name: The name of the server group. + :type server_group_name: str + :param firewall_rule_name: The name of the server group firewall rule. + :type firewall_rule_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + server_group_name=server_group_name, + firewall_rule_name=firewall_rule_name, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}/firewallRules/{firewallRuleName}'} # type: ignore + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + server_group_name: str, + firewall_rule_name: str, + **kwargs: Any + ) -> "_models.FirewallRule": + """Gets information about a server group firewall rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param server_group_name: The name of the server group. + :type server_group_name: str + :param firewall_rule_name: The name of the server group firewall rule. + :type firewall_rule_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FirewallRule, or the result of cls(response) + :rtype: ~azure.mgmt.rdbms.postgresqlhsc.models.FirewallRule + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.FirewallRule"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_group_name=server_group_name, + firewall_rule_name=firewall_rule_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('FirewallRule', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}/firewallRules/{firewallRuleName}'} # type: ignore + + + @distributed_trace + def list_by_server_group( + self, + resource_group_name: str, + server_group_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.FirewallRuleListResult"]: + """List all the firewall rules in a given server group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param server_group_name: The name of the server group. + :type server_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either FirewallRuleListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.rdbms.postgresqlhsc.models.FirewallRuleListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.FirewallRuleListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_server_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_group_name=server_group_name, + template_url=self.list_by_server_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_server_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_group_name=server_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("FirewallRuleListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_server_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}/firewallRules'} # type: ignore diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/aio/operations/_operations.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/aio/operations/_operations.py new file mode 100644 index 000000000000..33c618d12b8d --- /dev/null +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/aio/operations/_operations.py @@ -0,0 +1,109 @@ +# 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 functools +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._operations import build_list_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class Operations: + """Operations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.rdbms.postgresqlhsc.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> AsyncIterable["_models.OperationListResult"]: + """Lists all of the available REST API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.rdbms.postgresqlhsc.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("OperationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.DBForPostgreSql/operations'} # type: ignore diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/aio/operations/_roles_operations.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/aio/operations/_roles_operations.py new file mode 100644 index 000000000000..70292e6364c4 --- /dev/null +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/aio/operations/_roles_operations.py @@ -0,0 +1,351 @@ +# 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 functools +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._roles_operations import build_create_request_initial, build_delete_request_initial, build_list_by_server_group_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class RolesOperations: + """RolesOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.rdbms.postgresqlhsc.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + async def _create_initial( + self, + resource_group_name: str, + server_group_name: str, + role_name: str, + parameters: "_models.Role", + **kwargs: Any + ) -> Optional["_models.Role"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Role"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Role') + + request = build_create_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_group_name=server_group_name, + role_name=role_name, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Role', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Role', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}/roles/{roleName}'} # type: ignore + + + @distributed_trace_async + async def begin_create( + self, + resource_group_name: str, + server_group_name: str, + role_name: str, + parameters: "_models.Role", + **kwargs: Any + ) -> AsyncLROPoller["_models.Role"]: + """Creates a new role or updates an existing role. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param server_group_name: The name of the server group. + :type server_group_name: str + :param role_name: The name of the server group role name. + :type role_name: str + :param parameters: The required parameters for creating or updating a role. + :type parameters: ~azure.mgmt.rdbms.postgresqlhsc.models.Role + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either Role or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.rdbms.postgresqlhsc.models.Role] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.Role"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_initial( + resource_group_name=resource_group_name, + server_group_name=server_group_name, + role_name=role_name, + parameters=parameters, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('Role', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}/roles/{roleName}'} # type: ignore + + async def _delete_initial( + self, + resource_group_name: str, + server_group_name: str, + role_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_group_name=server_group_name, + role_name=role_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}/roles/{roleName}'} # type: ignore + + + @distributed_trace_async + async def begin_delete( + self, + resource_group_name: str, + server_group_name: str, + role_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a server group role. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param server_group_name: The name of the server group. + :type server_group_name: str + :param role_name: The name of the server group role name. + :type role_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + server_group_name=server_group_name, + role_name=role_name, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}/roles/{roleName}'} # type: ignore + + @distributed_trace + def list_by_server_group( + self, + resource_group_name: str, + server_group_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.RoleListResult"]: + """List all the roles in a given server group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param server_group_name: The name of the server group. + :type server_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either RoleListResult or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.rdbms.postgresqlhsc.models.RoleListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_server_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_group_name=server_group_name, + template_url=self.list_by_server_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_server_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_group_name=server_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("RoleListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_server_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}/roles'} # type: ignore diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/aio/operations/_server_groups_operations.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/aio/operations/_server_groups_operations.py new file mode 100644 index 000000000000..8b018388f95a --- /dev/null +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/aio/operations/_server_groups_operations.py @@ -0,0 +1,911 @@ +# 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 functools +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._server_groups_operations import build_check_name_availability_request, build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_request, build_restart_request_initial, build_start_request_initial, build_stop_request_initial, build_update_request_initial +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ServerGroupsOperations: + """ServerGroupsOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.rdbms.postgresqlhsc.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> AsyncIterable["_models.ServerGroupListResult"]: + """List all the server groups in a given subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ServerGroupListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.rdbms.postgresqlhsc.models.ServerGroupListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerGroupListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ServerGroupListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DBForPostgreSql/serverGroupsv2'} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.ServerGroupListResult"]: + """List all the server groups in a given resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ServerGroupListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.rdbms.postgresqlhsc.models.ServerGroupListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerGroupListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ServerGroupListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2'} # type: ignore + + async def _create_or_update_initial( + self, + resource_group_name: str, + server_group_name: str, + parameters: "_models.ServerGroup", + **kwargs: Any + ) -> Optional["_models.ServerGroup"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ServerGroup"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ServerGroup') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_group_name=server_group_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ServerGroup', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ServerGroup', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}'} # type: ignore + + + @distributed_trace_async + async def begin_create_or_update( + self, + resource_group_name: str, + server_group_name: str, + parameters: "_models.ServerGroup", + **kwargs: Any + ) -> AsyncLROPoller["_models.ServerGroup"]: + """Creates a new server group with servers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param server_group_name: The name of the server group. + :type server_group_name: str + :param parameters: The required parameters for creating or updating a server group. + :type parameters: ~azure.mgmt.rdbms.postgresqlhsc.models.ServerGroup + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ServerGroup or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.rdbms.postgresqlhsc.models.ServerGroup] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerGroup"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._create_or_update_initial( + resource_group_name=resource_group_name, + server_group_name=server_group_name, + parameters=parameters, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('ServerGroup', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}'} # type: ignore + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + server_group_name: str, + **kwargs: Any + ) -> "_models.ServerGroup": + """Gets information about a server group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param server_group_name: The name of the server group. + :type server_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ServerGroup, or the result of cls(response) + :rtype: ~azure.mgmt.rdbms.postgresqlhsc.models.ServerGroup + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerGroup"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_group_name=server_group_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ServerGroup', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}'} # type: ignore + + + async def _delete_initial( + self, + resource_group_name: str, + server_group_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_group_name=server_group_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}'} # type: ignore + + + @distributed_trace_async + async def begin_delete( + self, + resource_group_name: str, + server_group_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Deletes a server group together with servers in it. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param server_group_name: The name of the server group. + :type server_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._delete_initial( + resource_group_name=resource_group_name, + server_group_name=server_group_name, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}'} # type: ignore + + async def _update_initial( + self, + resource_group_name: str, + server_group_name: str, + parameters: "_models.ServerGroupForUpdate", + **kwargs: Any + ) -> Optional["_models.ServerGroup"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ServerGroup"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ServerGroupForUpdate') + + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_group_name=server_group_name, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ServerGroup', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}'} # type: ignore + + + @distributed_trace_async + async def begin_update( + self, + resource_group_name: str, + server_group_name: str, + parameters: "_models.ServerGroupForUpdate", + **kwargs: Any + ) -> AsyncLROPoller["_models.ServerGroup"]: + """Updates an existing server group. The request body can contain one to many of the properties + present in the normal server group definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param server_group_name: The name of the server group. + :type server_group_name: str + :param parameters: The parameters for updating a server group. + :type parameters: ~azure.mgmt.rdbms.postgresqlhsc.models.ServerGroupForUpdate + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either ServerGroup or the result of + cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.rdbms.postgresqlhsc.models.ServerGroup] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerGroup"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._update_initial( + resource_group_name=resource_group_name, + server_group_name=server_group_name, + parameters=parameters, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('ServerGroup', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}'} # type: ignore + + async def _restart_initial( + self, + resource_group_name: str, + server_group_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_restart_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_group_name=server_group_name, + template_url=self._restart_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _restart_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}/restart'} # type: ignore + + + @distributed_trace_async + async def begin_restart( + self, + resource_group_name: str, + server_group_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Restarts the server group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param server_group_name: The name of the server group. + :type server_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._restart_initial( + resource_group_name=resource_group_name, + server_group_name=server_group_name, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_restart.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}/restart'} # type: ignore + + async def _start_initial( + self, + resource_group_name: str, + server_group_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_start_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_group_name=server_group_name, + template_url=self._start_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _start_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}/start'} # type: ignore + + + @distributed_trace_async + async def begin_start( + self, + resource_group_name: str, + server_group_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Starts the server group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param server_group_name: The name of the server group. + :type server_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._start_initial( + resource_group_name=resource_group_name, + server_group_name=server_group_name, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_start.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}/start'} # type: ignore + + async def _stop_initial( + self, + resource_group_name: str, + server_group_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_stop_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_group_name=server_group_name, + template_url=self._stop_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _stop_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}/stop'} # type: ignore + + + @distributed_trace_async + async def begin_stop( + self, + resource_group_name: str, + server_group_name: str, + **kwargs: Any + ) -> AsyncLROPoller[None]: + """Stops the server group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param server_group_name: The name of the server group. + :type server_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. + :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.AsyncLROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = await self._stop_initial( + resource_group_name=resource_group_name, + server_group_name=server_group_name, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = AsyncNoPolling() + else: polling_method = polling + if cont_token: + return AsyncLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_stop.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}/stop'} # type: ignore + + @distributed_trace_async + async def check_name_availability( + self, + name_availability_request: "_models.NameAvailabilityRequest", + **kwargs: Any + ) -> "_models.NameAvailability": + """Check the availability of name for resource. + + :param name_availability_request: The required parameters for checking if resource name is + available. + :type name_availability_request: ~azure.mgmt.rdbms.postgresqlhsc.models.NameAvailabilityRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: NameAvailability, or the result of cls(response) + :rtype: ~azure.mgmt.rdbms.postgresqlhsc.models.NameAvailability + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.NameAvailability"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(name_availability_request, 'NameAvailabilityRequest') + + request = build_check_name_availability_request( + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.check_name_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('NameAvailability', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DBForPostgreSql/checkNameAvailability'} # type: ignore + diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/aio/operations/_servers_operations.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/aio/operations/_servers_operations.py new file mode 100644 index 000000000000..9569816df1bc --- /dev/null +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/aio/operations/_servers_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 functools +from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.async_paging import AsyncItemPaged, AsyncList +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._servers_operations import build_get_request, build_list_by_server_group_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ServersOperations: + """ServersOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.rdbms.postgresqlhsc.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list_by_server_group( + self, + resource_group_name: str, + server_group_name: str, + **kwargs: Any + ) -> AsyncIterable["_models.ServerGroupServerListResult"]: + """Lists servers of a server group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param server_group_name: The name of the server group. + :type server_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ServerGroupServerListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.rdbms.postgresqlhsc.models.ServerGroupServerListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerGroupServerListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_server_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_group_name=server_group_name, + template_url=self.list_by_server_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_server_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_group_name=server_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + async def extract_data(pipeline_response): + deserialized = self._deserialize("ServerGroupServerListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return AsyncItemPaged( + get_next, extract_data + ) + list_by_server_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}/servers'} # type: ignore + + @distributed_trace_async + async def get( + self, + resource_group_name: str, + server_group_name: str, + server_name: str, + **kwargs: Any + ) -> "_models.ServerGroupServer": + """Gets information about a server in server group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param server_group_name: The name of the server group. + :type server_group_name: str + :param server_name: The name of the server. + :type server_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ServerGroupServer, or the result of cls(response) + :rtype: ~azure.mgmt.rdbms.postgresqlhsc.models.ServerGroupServer + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerGroupServer"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_group_name=server_group_name, + server_name=server_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ServerGroupServer', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}/servers/{serverName}'} # type: ignore + diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/models/__init__.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/models/__init__.py new file mode 100644 index 000000000000..2607beeeb84c --- /dev/null +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/models/__init__.py @@ -0,0 +1,99 @@ +# 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 ._models_py3 import CloudErrorBody +from ._models_py3 import FirewallRule +from ._models_py3 import FirewallRuleListResult +from ._models_py3 import MaintenanceWindow +from ._models_py3 import NameAvailability +from ._models_py3 import NameAvailabilityRequest +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationListResult +from ._models_py3 import ProxyResource +from ._models_py3 import Resource +from ._models_py3 import Role +from ._models_py3 import RoleListResult +from ._models_py3 import ServerConfiguration +from ._models_py3 import ServerConfigurationListResult +from ._models_py3 import ServerGroup +from ._models_py3 import ServerGroupConfiguration +from ._models_py3 import ServerGroupConfigurationListResult +from ._models_py3 import ServerGroupForUpdate +from ._models_py3 import ServerGroupListResult +from ._models_py3 import ServerGroupPropertiesDelegatedSubnetArguments +from ._models_py3 import ServerGroupPropertiesPrivateDnsZoneArguments +from ._models_py3 import ServerGroupServer +from ._models_py3 import ServerGroupServerListResult +from ._models_py3 import ServerGroupServerProperties +from ._models_py3 import ServerNameItem +from ._models_py3 import ServerProperties +from ._models_py3 import ServerRoleGroup +from ._models_py3 import ServerRoleGroupConfiguration +from ._models_py3 import SystemData +from ._models_py3 import TrackedResource + + +from ._microsoft_postgre_sql_hyperscale_enums import ( + CitusVersion, + ConfigurationDataType, + CreateMode, + CreatedByType, + OperationOrigin, + PostgreSQLVersion, + ResourceProviderType, + ServerEdition, + ServerHaState, + ServerRole, + ServerState, +) + +__all__ = [ + 'CloudErrorBody', + 'FirewallRule', + 'FirewallRuleListResult', + 'MaintenanceWindow', + 'NameAvailability', + 'NameAvailabilityRequest', + 'Operation', + 'OperationDisplay', + 'OperationListResult', + 'ProxyResource', + 'Resource', + 'Role', + 'RoleListResult', + 'ServerConfiguration', + 'ServerConfigurationListResult', + 'ServerGroup', + 'ServerGroupConfiguration', + 'ServerGroupConfigurationListResult', + 'ServerGroupForUpdate', + 'ServerGroupListResult', + 'ServerGroupPropertiesDelegatedSubnetArguments', + 'ServerGroupPropertiesPrivateDnsZoneArguments', + 'ServerGroupServer', + 'ServerGroupServerListResult', + 'ServerGroupServerProperties', + 'ServerNameItem', + 'ServerProperties', + 'ServerRoleGroup', + 'ServerRoleGroupConfiguration', + 'SystemData', + 'TrackedResource', + 'CitusVersion', + 'ConfigurationDataType', + 'CreateMode', + 'CreatedByType', + 'OperationOrigin', + 'PostgreSQLVersion', + 'ResourceProviderType', + 'ServerEdition', + 'ServerHaState', + 'ServerRole', + 'ServerState', +] diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/models/_microsoft_postgre_sql_hyperscale_enums.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/models/_microsoft_postgre_sql_hyperscale_enums.py new file mode 100644 index 000000000000..85cad7a032da --- /dev/null +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/models/_microsoft_postgre_sql_hyperscale_enums.py @@ -0,0 +1,111 @@ +# 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 enum import Enum +from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta + + +class CitusVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The Citus version. + """ + + EIGHT3 = "8.3" + NINE0 = "9.0" + NINE1 = "9.1" + NINE2 = "9.2" + NINE3 = "9.3" + NINE4 = "9.4" + NINE5 = "9.5" + +class ConfigurationDataType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """Data type of the configuration. + """ + + BOOLEAN = "Boolean" + NUMERIC = "Numeric" + INTEGER = "Integer" + ENUMERATION = "Enumeration" + +class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The type of identity that created the resource. + """ + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + +class CreateMode(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The mode to create a new server group. + """ + + DEFAULT = "Default" + POINT_IN_TIME_RESTORE = "PointInTimeRestore" + READ_REPLICA = "ReadReplica" + +class OperationOrigin(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The intended executor of the operation. + """ + + NOT_SPECIFIED = "NotSpecified" + USER = "user" + SYSTEM = "system" + +class PostgreSQLVersion(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The PostgreSQL version. + """ + + ELEVEN = "11" + TWELVE = "12" + +class ResourceProviderType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The resource provider type of server group. + """ + + MERU = "Meru" + MARLIN = "Marlin" + +class ServerEdition(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The edition of a server (default: GeneralPurpose). + """ + + GENERAL_PURPOSE = "GeneralPurpose" + MEMORY_OPTIMIZED = "MemoryOptimized" + +class ServerHaState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """A state of a server role group/server that is visible to user for HA feature. + """ + + NOT_ENABLED = "NotEnabled" + CREATING_STANDBY = "CreatingStandby" + REPLICATING_DATA = "ReplicatingData" + FAILING_OVER = "FailingOver" + HEALTHY = "Healthy" + REMOVING_STANDBY = "RemovingStandby" + NOT_SYNC = "NotSync" + +class ServerRole(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The role of a server. + """ + + COORDINATOR = "Coordinator" + WORKER = "Worker" + +class ServerState(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """A state of a server group/server that is visible to user. + """ + + READY = "Ready" + DROPPING = "Dropping" + DISABLED = "Disabled" + STARTING = "Starting" + STOPPING = "Stopping" + STOPPED = "Stopped" + UPDATING = "Updating" + PROVISIONING = "Provisioning" diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/models/_models_py3.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/models/_models_py3.py new file mode 100644 index 000000000000..fa707bdd9725 --- /dev/null +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/models/_models_py3.py @@ -0,0 +1,1850 @@ +# 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 datetime +from typing import Dict, List, Optional, Union + +import msrest.serialization + +from ._microsoft_postgre_sql_hyperscale_enums import * + + +class CloudErrorBody(msrest.serialization.Model): + """An error response from the Batch service. + + :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed + programmatically. + :vartype code: str + :ivar message: A message describing the error, intended to be suitable for display in a user + interface. + :vartype message: str + :ivar target: The target of the particular error. For example, the name of the property in + error. + :vartype target: str + :ivar details: A list of additional details about the error. + :vartype details: list[~azure.mgmt.rdbms.postgresqlhsc.models.CloudErrorBody] + """ + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + 'details': {'key': 'details', 'type': '[CloudErrorBody]'}, + } + + def __init__( + self, + *, + code: Optional[str] = None, + message: Optional[str] = None, + target: Optional[str] = None, + details: Optional[List["CloudErrorBody"]] = None, + **kwargs + ): + """ + :keyword code: An identifier for the error. Codes are invariant and are intended to be consumed + programmatically. + :paramtype code: str + :keyword message: A message describing the error, intended to be suitable for display in a user + interface. + :paramtype message: str + :keyword target: The target of the particular error. For example, the name of the property in + error. + :paramtype target: str + :keyword details: A list of additional details about the error. + :paramtype details: list[~azure.mgmt.rdbms.postgresqlhsc.models.CloudErrorBody] + """ + super(CloudErrorBody, self).__init__(**kwargs) + self.code = code + self.message = message + self.target = target + self.details = details + + +class Resource(msrest.serialization.Model): + """Common fields that are returned in the response for all Azure Resource Manager resources. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(Resource, self).__init__(**kwargs) + self.id = None + self.name = None + self.type = None + + +class ProxyResource(Resource): + """The resource model definition for a Azure Resource Manager proxy resource. It will not have tags and a location. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(ProxyResource, self).__init__(**kwargs) + + +class FirewallRule(ProxyResource): + """Represents a server group firewall rule. + + 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: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: The system metadata relating to this resource. + :vartype system_data: ~azure.mgmt.rdbms.postgresqlhsc.models.SystemData + :ivar start_ip_address: Required. The start IP address of the server group firewall rule. Must + be IPv4 format. + :vartype start_ip_address: str + :ivar end_ip_address: Required. The end IP address of the server group firewall rule. Must be + IPv4 format. + :vartype end_ip_address: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + 'start_ip_address': {'required': True, 'pattern': r'^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$'}, + 'end_ip_address': {'required': True, 'pattern': r'^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$'}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'start_ip_address': {'key': 'properties.startIpAddress', 'type': 'str'}, + 'end_ip_address': {'key': 'properties.endIpAddress', 'type': 'str'}, + } + + def __init__( + self, + *, + start_ip_address: str, + end_ip_address: str, + **kwargs + ): + """ + :keyword start_ip_address: Required. The start IP address of the server group firewall rule. + Must be IPv4 format. + :paramtype start_ip_address: str + :keyword end_ip_address: Required. The end IP address of the server group firewall rule. Must + be IPv4 format. + :paramtype end_ip_address: str + """ + super(FirewallRule, self).__init__(**kwargs) + self.system_data = None + self.start_ip_address = start_ip_address + self.end_ip_address = end_ip_address + + +class FirewallRuleListResult(msrest.serialization.Model): + """A list of firewall rules. + + :ivar value: The list of firewall rules in a server group. + :vartype value: list[~azure.mgmt.rdbms.postgresqlhsc.models.FirewallRule] + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[FirewallRule]'}, + } + + def __init__( + self, + *, + value: Optional[List["FirewallRule"]] = None, + **kwargs + ): + """ + :keyword value: The list of firewall rules in a server group. + :paramtype value: list[~azure.mgmt.rdbms.postgresqlhsc.models.FirewallRule] + """ + super(FirewallRuleListResult, self).__init__(**kwargs) + self.value = value + + +class MaintenanceWindow(msrest.serialization.Model): + """Maintenance window of a server group. + + :ivar custom_window: indicates whether custom window is enabled or disabled. + :vartype custom_window: str + :ivar start_hour: start hour for maintenance window. + :vartype start_hour: int + :ivar start_minute: start minute for maintenance window. + :vartype start_minute: int + :ivar day_of_week: day of week for maintenance window. + :vartype day_of_week: int + """ + + _attribute_map = { + 'custom_window': {'key': 'customWindow', 'type': 'str'}, + 'start_hour': {'key': 'startHour', 'type': 'int'}, + 'start_minute': {'key': 'startMinute', 'type': 'int'}, + 'day_of_week': {'key': 'dayOfWeek', 'type': 'int'}, + } + + def __init__( + self, + *, + custom_window: Optional[str] = None, + start_hour: Optional[int] = None, + start_minute: Optional[int] = None, + day_of_week: Optional[int] = None, + **kwargs + ): + """ + :keyword custom_window: indicates whether custom window is enabled or disabled. + :paramtype custom_window: str + :keyword start_hour: start hour for maintenance window. + :paramtype start_hour: int + :keyword start_minute: start minute for maintenance window. + :paramtype start_minute: int + :keyword day_of_week: day of week for maintenance window. + :paramtype day_of_week: int + """ + super(MaintenanceWindow, self).__init__(**kwargs) + self.custom_window = custom_window + self.start_hour = start_hour + self.start_minute = start_minute + self.day_of_week = day_of_week + + +class NameAvailability(msrest.serialization.Model): + """Represents a resource name availability. + + :ivar message: Error Message. + :vartype message: str + :ivar name_available: Indicates whether the resource name is available. + :vartype name_available: bool + :ivar name: name of the PostgreSQL server. + :vartype name: str + :ivar type: type of the server. + :vartype type: str + """ + + _attribute_map = { + 'message': {'key': 'message', 'type': 'str'}, + 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + *, + message: Optional[str] = None, + name_available: Optional[bool] = None, + name: Optional[str] = None, + type: Optional[str] = None, + **kwargs + ): + """ + :keyword message: Error Message. + :paramtype message: str + :keyword name_available: Indicates whether the resource name is available. + :paramtype name_available: bool + :keyword name: name of the PostgreSQL server. + :paramtype name: str + :keyword type: type of the server. + :paramtype type: str + """ + super(NameAvailability, self).__init__(**kwargs) + self.message = message + self.name_available = name_available + self.name = name + self.type = type + + +class NameAvailabilityRequest(msrest.serialization.Model): + """Request from client to check resource name availability. + + 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 name: Required. Resource name to verify. + :vartype name: str + :ivar type: Resource type used for verification. Has constant value: + "Microsoft.DBforPostgreSQL/serverGroupsv2". + :vartype type: str + """ + + _validation = { + 'name': {'required': True}, + 'type': {'required': True, 'constant': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + type = "Microsoft.DBforPostgreSQL/serverGroupsv2" + + def __init__( + self, + *, + name: str, + **kwargs + ): + """ + :keyword name: Required. Resource name to verify. + :paramtype name: str + """ + super(NameAvailabilityRequest, self).__init__(**kwargs) + self.name = name + + +class Operation(msrest.serialization.Model): + """REST API operation definition. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The name of the operation being performed on this particular object. + :vartype name: str + :ivar display: The localized display information for this particular operation or action. + :vartype display: ~azure.mgmt.rdbms.postgresqlhsc.models.OperationDisplay + :ivar is_data_action: Indicates whether the operation is a data action. + :vartype is_data_action: bool + :ivar origin: The intended executor of the operation. Possible values include: "NotSpecified", + "user", "system". + :vartype origin: str or ~azure.mgmt.rdbms.postgresqlhsc.models.OperationOrigin + :ivar properties: Additional descriptions for the operation. + :vartype properties: dict[str, any] + """ + + _validation = { + 'name': {'readonly': True}, + 'display': {'readonly': True}, + 'origin': {'readonly': True}, + 'properties': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'display': {'key': 'display', 'type': 'OperationDisplay'}, + 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, + 'origin': {'key': 'origin', 'type': 'str'}, + 'properties': {'key': 'properties', 'type': '{object}'}, + } + + def __init__( + self, + *, + is_data_action: Optional[bool] = None, + **kwargs + ): + """ + :keyword is_data_action: Indicates whether the operation is a data action. + :paramtype is_data_action: bool + """ + super(Operation, self).__init__(**kwargs) + self.name = None + self.display = None + self.is_data_action = is_data_action + self.origin = None + self.properties = None + + +class OperationDisplay(msrest.serialization.Model): + """Display metadata associated with the operation. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar provider: Operation resource provider name. + :vartype provider: str + :ivar resource: Resource on which the operation is performed. + :vartype resource: str + :ivar operation: Localized friendly name for the operation. + :vartype operation: str + :ivar description: Operation description. + :vartype description: str + """ + + _validation = { + 'provider': {'readonly': True}, + 'resource': {'readonly': True}, + 'operation': {'readonly': True}, + 'description': {'readonly': True}, + } + + _attribute_map = { + 'provider': {'key': 'provider', 'type': 'str'}, + 'resource': {'key': 'resource', 'type': 'str'}, + 'operation': {'key': 'operation', 'type': 'str'}, + 'description': {'key': 'description', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + """ + super(OperationDisplay, self).__init__(**kwargs) + self.provider = None + self.resource = None + self.operation = None + self.description = None + + +class OperationListResult(msrest.serialization.Model): + """A list of resource provider operations. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: Collection of available operation details. + :vartype value: list[~azure.mgmt.rdbms.postgresqlhsc.models.Operation] + :ivar next_link: URL client should use to fetch the next page (per server side paging). + It's null for now, added for future use. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Operation]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["Operation"]] = None, + **kwargs + ): + """ + :keyword value: Collection of available operation details. + :paramtype value: list[~azure.mgmt.rdbms.postgresqlhsc.models.Operation] + """ + super(OperationListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class Role(ProxyResource): + """Represents a server group role. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: The system metadata relating to this resource. + :vartype system_data: ~azure.mgmt.rdbms.postgresqlhsc.models.SystemData + :ivar password: The password of the server group role. + :vartype password: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'password': {'key': 'properties.password', 'type': 'str'}, + } + + def __init__( + self, + *, + password: Optional[str] = None, + **kwargs + ): + """ + :keyword password: The password of the server group role. + :paramtype password: str + """ + super(Role, self).__init__(**kwargs) + self.system_data = None + self.password = password + + +class RoleListResult(msrest.serialization.Model): + """A list of roles. + + :ivar value: The list of roles in a server group. + :vartype value: list[~azure.mgmt.rdbms.postgresqlhsc.models.Role] + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Role]'}, + } + + def __init__( + self, + *, + value: Optional[List["Role"]] = None, + **kwargs + ): + """ + :keyword value: The list of roles in a server group. + :paramtype value: list[~azure.mgmt.rdbms.postgresqlhsc.models.Role] + """ + super(RoleListResult, self).__init__(**kwargs) + self.value = value + + +class ServerConfiguration(ProxyResource): + """Represents a configuration. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: The system metadata relating to this resource. + :vartype system_data: ~azure.mgmt.rdbms.postgresqlhsc.models.SystemData + :ivar value: Value of the configuration. + :vartype value: str + :ivar source: Source of the configuration. + :vartype source: str + :ivar description: Description of the configuration. + :vartype description: str + :ivar default_value: Default value of the configuration. + :vartype default_value: str + :ivar data_type: Data type of the configuration. Possible values include: "Boolean", "Numeric", + "Integer", "Enumeration". + :vartype data_type: str or ~azure.mgmt.rdbms.postgresqlhsc.models.ConfigurationDataType + :ivar allowed_values: Allowed values of the configuration. + :vartype allowed_values: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + 'source': {'readonly': True}, + 'description': {'readonly': True}, + 'default_value': {'readonly': True}, + 'data_type': {'readonly': True}, + 'allowed_values': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'value': {'key': 'properties.value', 'type': 'str'}, + 'source': {'key': 'properties.source', 'type': 'str'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + 'default_value': {'key': 'properties.defaultValue', 'type': 'str'}, + 'data_type': {'key': 'properties.dataType', 'type': 'str'}, + 'allowed_values': {'key': 'properties.allowedValues', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[str] = None, + **kwargs + ): + """ + :keyword value: Value of the configuration. + :paramtype value: str + """ + super(ServerConfiguration, self).__init__(**kwargs) + self.system_data = None + self.value = value + self.source = None + self.description = None + self.default_value = None + self.data_type = None + self.allowed_values = None + + +class ServerConfigurationListResult(msrest.serialization.Model): + """A list of server configurations. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The list of server configurations. + :vartype value: list[~azure.mgmt.rdbms.postgresqlhsc.models.ServerConfiguration] + :ivar next_link: Link to retrieve next page of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ServerConfiguration]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["ServerConfiguration"]] = None, + **kwargs + ): + """ + :keyword value: The list of server configurations. + :paramtype value: list[~azure.mgmt.rdbms.postgresqlhsc.models.ServerConfiguration] + """ + super(ServerConfigurationListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class TrackedResource(Resource): + """The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location'. + + 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: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar location: Required. The geo-location where the resource lives. + :vartype location: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'location': {'required': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'location': {'key': 'location', 'type': 'str'}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword location: Required. The geo-location where the resource lives. + :paramtype location: str + """ + super(TrackedResource, self).__init__(**kwargs) + self.tags = tags + self.location = location + + +class ServerGroup(TrackedResource): + """Represents a server group for create. + + 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: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar location: Required. The geo-location where the resource lives. + :vartype location: str + :ivar system_data: The system metadata relating to this resource. + :vartype system_data: ~azure.mgmt.rdbms.postgresqlhsc.models.SystemData + :ivar create_mode: The mode to create a new server group. Possible values include: "Default", + "PointInTimeRestore", "ReadReplica". + :vartype create_mode: str or ~azure.mgmt.rdbms.postgresqlhsc.models.CreateMode + :ivar administrator_login: The administrator's login name of servers in server group. Can only + be specified when the server is being created (and is required for creation). + :vartype administrator_login: str + :ivar administrator_login_password: The password of the administrator login. + :vartype administrator_login_password: str + :ivar backup_retention_days: The backup retention days for server group. + :vartype backup_retention_days: int + :ivar postgresql_version: The PostgreSQL version of server group. Possible values include: + "11", "12". + :vartype postgresql_version: str or ~azure.mgmt.rdbms.postgresqlhsc.models.PostgreSQLVersion + :ivar citus_version: The Citus version of server group. Possible values include: "8.3", "9.0", + "9.1", "9.2", "9.3", "9.4", "9.5". + :vartype citus_version: str or ~azure.mgmt.rdbms.postgresqlhsc.models.CitusVersion + :ivar enable_mx: If Citus MX is enabled or not for the server group. + :vartype enable_mx: bool + :ivar enable_zfs: If ZFS compression is enabled or not for the server group. + :vartype enable_zfs: bool + :ivar enable_shards_on_coordinator: If shards on coordinator is enabled or not for the server + group. + :vartype enable_shards_on_coordinator: bool + :ivar state: A state of a server group that is visible to user. Possible values include: + "Ready", "Dropping", "Disabled", "Starting", "Stopping", "Stopped", "Updating", "Provisioning". + :vartype state: str or ~azure.mgmt.rdbms.postgresqlhsc.models.ServerState + :ivar earliest_restore_time: The earliest restore point time (ISO8601 format) for server group. + :vartype earliest_restore_time: ~datetime.datetime + :ivar resource_provider_type: The resource provider type of server group. Possible values + include: "Meru", "Marlin". + :vartype resource_provider_type: str or + ~azure.mgmt.rdbms.postgresqlhsc.models.ResourceProviderType + :ivar server_role_groups: The list of server role groups. + :vartype server_role_groups: list[~azure.mgmt.rdbms.postgresqlhsc.models.ServerRoleGroup] + :ivar maintenance_window: Maintenance window of a server group. + :vartype maintenance_window: ~azure.mgmt.rdbms.postgresqlhsc.models.MaintenanceWindow + :ivar availability_zone: Availability Zone information of the server group. + :vartype availability_zone: str + :ivar standby_availability_zone: Standby Availability Zone information of the server group. + :vartype standby_availability_zone: str + :ivar delegated_subnet_arguments: The delegated subnet arguments for a server group. + :vartype delegated_subnet_arguments: + ~azure.mgmt.rdbms.postgresqlhsc.models.ServerGroupPropertiesDelegatedSubnetArguments + :ivar private_dns_zone_arguments: The private dns zone arguments for a server group. + :vartype private_dns_zone_arguments: + ~azure.mgmt.rdbms.postgresqlhsc.models.ServerGroupPropertiesPrivateDnsZoneArguments + :ivar read_replicas: The array of read replica server groups. + :vartype read_replicas: list[str] + :ivar source_server_group: The source server group id for read replica server groups. + :vartype source_server_group: str + :ivar source_subscription_id: The source subscription id to restore from. It's required when + 'createMode' is 'PointInTimeRestore' or 'ReadReplica'. + :vartype source_subscription_id: str + :ivar source_resource_group_name: The source resource group name to restore from. It's required + when 'createMode' is 'PointInTimeRestore' or 'ReadReplica'. + :vartype source_resource_group_name: str + :ivar source_server_group_name: The source server group name to restore from. It's required + when 'createMode' is 'PointInTimeRestore' or 'ReadReplica'. + :vartype source_server_group_name: str + :ivar source_location: The source server group location to restore from. It's required when + 'createMode' is 'PointInTimeRestore' or 'ReadReplica'. + :vartype source_location: str + :ivar point_in_time_utc: Restore point creation time (ISO8601 format), specifying the time to + restore from. It's required when 'createMode' is 'PointInTimeRestore'. + :vartype point_in_time_utc: ~datetime.datetime + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'location': {'required': True}, + 'system_data': {'readonly': True}, + 'state': {'readonly': True}, + 'earliest_restore_time': {'readonly': True}, + 'resource_provider_type': {'readonly': True}, + 'server_role_groups': {'max_items': 2, 'min_items': 1, 'unique': True}, + 'read_replicas': {'readonly': True, 'unique': True}, + 'source_server_group': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'location': {'key': 'location', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'create_mode': {'key': 'properties.createMode', 'type': 'str'}, + 'administrator_login': {'key': 'properties.administratorLogin', 'type': 'str'}, + 'administrator_login_password': {'key': 'properties.administratorLoginPassword', 'type': 'str'}, + 'backup_retention_days': {'key': 'properties.backupRetentionDays', 'type': 'int'}, + 'postgresql_version': {'key': 'properties.postgresqlVersion', 'type': 'str'}, + 'citus_version': {'key': 'properties.citusVersion', 'type': 'str'}, + 'enable_mx': {'key': 'properties.enableMx', 'type': 'bool'}, + 'enable_zfs': {'key': 'properties.enableZfs', 'type': 'bool'}, + 'enable_shards_on_coordinator': {'key': 'properties.enableShardsOnCoordinator', 'type': 'bool'}, + 'state': {'key': 'properties.state', 'type': 'str'}, + 'earliest_restore_time': {'key': 'properties.earliestRestoreTime', 'type': 'iso-8601'}, + 'resource_provider_type': {'key': 'properties.resourceProviderType', 'type': 'str'}, + 'server_role_groups': {'key': 'properties.serverRoleGroups', 'type': '[ServerRoleGroup]'}, + 'maintenance_window': {'key': 'properties.maintenanceWindow', 'type': 'MaintenanceWindow'}, + 'availability_zone': {'key': 'properties.availabilityZone', 'type': 'str'}, + 'standby_availability_zone': {'key': 'properties.standbyAvailabilityZone', 'type': 'str'}, + 'delegated_subnet_arguments': {'key': 'properties.delegatedSubnetArguments', 'type': 'ServerGroupPropertiesDelegatedSubnetArguments'}, + 'private_dns_zone_arguments': {'key': 'properties.privateDnsZoneArguments', 'type': 'ServerGroupPropertiesPrivateDnsZoneArguments'}, + 'read_replicas': {'key': 'properties.readReplicas', 'type': '[str]'}, + 'source_server_group': {'key': 'properties.sourceServerGroup', 'type': 'str'}, + 'source_subscription_id': {'key': 'properties.sourceSubscriptionId', 'type': 'str'}, + 'source_resource_group_name': {'key': 'properties.sourceResourceGroupName', 'type': 'str'}, + 'source_server_group_name': {'key': 'properties.sourceServerGroupName', 'type': 'str'}, + 'source_location': {'key': 'properties.sourceLocation', 'type': 'str'}, + 'point_in_time_utc': {'key': 'properties.pointInTimeUTC', 'type': 'iso-8601'}, + } + + def __init__( + self, + *, + location: str, + tags: Optional[Dict[str, str]] = None, + create_mode: Optional[Union[str, "CreateMode"]] = None, + administrator_login: Optional[str] = None, + administrator_login_password: Optional[str] = None, + backup_retention_days: Optional[int] = None, + postgresql_version: Optional[Union[str, "PostgreSQLVersion"]] = None, + citus_version: Optional[Union[str, "CitusVersion"]] = None, + enable_mx: Optional[bool] = None, + enable_zfs: Optional[bool] = None, + enable_shards_on_coordinator: Optional[bool] = None, + server_role_groups: Optional[List["ServerRoleGroup"]] = None, + maintenance_window: Optional["MaintenanceWindow"] = None, + availability_zone: Optional[str] = None, + standby_availability_zone: Optional[str] = None, + delegated_subnet_arguments: Optional["ServerGroupPropertiesDelegatedSubnetArguments"] = None, + private_dns_zone_arguments: Optional["ServerGroupPropertiesPrivateDnsZoneArguments"] = None, + source_subscription_id: Optional[str] = None, + source_resource_group_name: Optional[str] = None, + source_server_group_name: Optional[str] = None, + source_location: Optional[str] = None, + point_in_time_utc: Optional[datetime.datetime] = None, + **kwargs + ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword location: Required. The geo-location where the resource lives. + :paramtype location: str + :keyword create_mode: The mode to create a new server group. Possible values include: + "Default", "PointInTimeRestore", "ReadReplica". + :paramtype create_mode: str or ~azure.mgmt.rdbms.postgresqlhsc.models.CreateMode + :keyword administrator_login: The administrator's login name of servers in server group. Can + only be specified when the server is being created (and is required for creation). + :paramtype administrator_login: str + :keyword administrator_login_password: The password of the administrator login. + :paramtype administrator_login_password: str + :keyword backup_retention_days: The backup retention days for server group. + :paramtype backup_retention_days: int + :keyword postgresql_version: The PostgreSQL version of server group. Possible values include: + "11", "12". + :paramtype postgresql_version: str or ~azure.mgmt.rdbms.postgresqlhsc.models.PostgreSQLVersion + :keyword citus_version: The Citus version of server group. Possible values include: "8.3", + "9.0", "9.1", "9.2", "9.3", "9.4", "9.5". + :paramtype citus_version: str or ~azure.mgmt.rdbms.postgresqlhsc.models.CitusVersion + :keyword enable_mx: If Citus MX is enabled or not for the server group. + :paramtype enable_mx: bool + :keyword enable_zfs: If ZFS compression is enabled or not for the server group. + :paramtype enable_zfs: bool + :keyword enable_shards_on_coordinator: If shards on coordinator is enabled or not for the + server group. + :paramtype enable_shards_on_coordinator: bool + :keyword server_role_groups: The list of server role groups. + :paramtype server_role_groups: list[~azure.mgmt.rdbms.postgresqlhsc.models.ServerRoleGroup] + :keyword maintenance_window: Maintenance window of a server group. + :paramtype maintenance_window: ~azure.mgmt.rdbms.postgresqlhsc.models.MaintenanceWindow + :keyword availability_zone: Availability Zone information of the server group. + :paramtype availability_zone: str + :keyword standby_availability_zone: Standby Availability Zone information of the server group. + :paramtype standby_availability_zone: str + :keyword delegated_subnet_arguments: The delegated subnet arguments for a server group. + :paramtype delegated_subnet_arguments: + ~azure.mgmt.rdbms.postgresqlhsc.models.ServerGroupPropertiesDelegatedSubnetArguments + :keyword private_dns_zone_arguments: The private dns zone arguments for a server group. + :paramtype private_dns_zone_arguments: + ~azure.mgmt.rdbms.postgresqlhsc.models.ServerGroupPropertiesPrivateDnsZoneArguments + :keyword source_subscription_id: The source subscription id to restore from. It's required when + 'createMode' is 'PointInTimeRestore' or 'ReadReplica'. + :paramtype source_subscription_id: str + :keyword source_resource_group_name: The source resource group name to restore from. It's + required when 'createMode' is 'PointInTimeRestore' or 'ReadReplica'. + :paramtype source_resource_group_name: str + :keyword source_server_group_name: The source server group name to restore from. It's required + when 'createMode' is 'PointInTimeRestore' or 'ReadReplica'. + :paramtype source_server_group_name: str + :keyword source_location: The source server group location to restore from. It's required when + 'createMode' is 'PointInTimeRestore' or 'ReadReplica'. + :paramtype source_location: str + :keyword point_in_time_utc: Restore point creation time (ISO8601 format), specifying the time + to restore from. It's required when 'createMode' is 'PointInTimeRestore'. + :paramtype point_in_time_utc: ~datetime.datetime + """ + super(ServerGroup, self).__init__(tags=tags, location=location, **kwargs) + self.system_data = None + self.create_mode = create_mode + self.administrator_login = administrator_login + self.administrator_login_password = administrator_login_password + self.backup_retention_days = backup_retention_days + self.postgresql_version = postgresql_version + self.citus_version = citus_version + self.enable_mx = enable_mx + self.enable_zfs = enable_zfs + self.enable_shards_on_coordinator = enable_shards_on_coordinator + self.state = None + self.earliest_restore_time = None + self.resource_provider_type = None + self.server_role_groups = server_role_groups + self.maintenance_window = maintenance_window + self.availability_zone = availability_zone + self.standby_availability_zone = standby_availability_zone + self.delegated_subnet_arguments = delegated_subnet_arguments + self.private_dns_zone_arguments = private_dns_zone_arguments + self.read_replicas = None + self.source_server_group = None + self.source_subscription_id = source_subscription_id + self.source_resource_group_name = source_resource_group_name + self.source_server_group_name = source_server_group_name + self.source_location = source_location + self.point_in_time_utc = point_in_time_utc + + +class ServerGroupConfiguration(ProxyResource): + """Represents the configuration list of server role groups in a server group. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: The system metadata relating to this resource. + :vartype system_data: ~azure.mgmt.rdbms.postgresqlhsc.models.SystemData + :ivar description: Description of the configuration. + :vartype description: str + :ivar data_type: Data type of the configuration. Possible values include: "Boolean", "Numeric", + "Integer", "Enumeration". + :vartype data_type: str or ~azure.mgmt.rdbms.postgresqlhsc.models.ConfigurationDataType + :ivar allowed_values: Allowed values of the configuration. + :vartype allowed_values: str + :ivar server_role_group_configurations: The list of server role group configuration values. + :vartype server_role_group_configurations: + list[~azure.mgmt.rdbms.postgresqlhsc.models.ServerRoleGroupConfiguration] + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + 'description': {'readonly': True}, + 'data_type': {'readonly': True}, + 'allowed_values': {'readonly': True}, + 'server_role_group_configurations': {'unique': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'description': {'key': 'properties.description', 'type': 'str'}, + 'data_type': {'key': 'properties.dataType', 'type': 'str'}, + 'allowed_values': {'key': 'properties.allowedValues', 'type': 'str'}, + 'server_role_group_configurations': {'key': 'properties.serverRoleGroupConfigurations', 'type': '[ServerRoleGroupConfiguration]'}, + } + + def __init__( + self, + *, + server_role_group_configurations: Optional[List["ServerRoleGroupConfiguration"]] = None, + **kwargs + ): + """ + :keyword server_role_group_configurations: The list of server role group configuration values. + :paramtype server_role_group_configurations: + list[~azure.mgmt.rdbms.postgresqlhsc.models.ServerRoleGroupConfiguration] + """ + super(ServerGroupConfiguration, self).__init__(**kwargs) + self.system_data = None + self.description = None + self.data_type = None + self.allowed_values = None + self.server_role_group_configurations = server_role_group_configurations + + +class ServerGroupConfigurationListResult(msrest.serialization.Model): + """A list of server group configurations. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The list of server group configurations. + :vartype value: list[~azure.mgmt.rdbms.postgresqlhsc.models.ServerGroupConfiguration] + :ivar next_link: Link to retrieve next page of results. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ServerGroupConfiguration]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["ServerGroupConfiguration"]] = None, + **kwargs + ): + """ + :keyword value: The list of server group configurations. + :paramtype value: list[~azure.mgmt.rdbms.postgresqlhsc.models.ServerGroupConfiguration] + """ + super(ServerGroupConfigurationListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class ServerGroupForUpdate(msrest.serialization.Model): + """Represents a server group for update. + + :ivar location: The location the resource resides in. + :vartype location: str + :ivar tags: A set of tags. Application-specific metadata in the form of key-value pairs. + :vartype tags: dict[str, str] + :ivar administrator_login_password: The password of the administrator login. + :vartype administrator_login_password: str + :ivar backup_retention_days: The backup retention days for server group. + :vartype backup_retention_days: int + :ivar postgresql_version: The PostgreSQL version of server group. Possible values include: + "11", "12". + :vartype postgresql_version: str or ~azure.mgmt.rdbms.postgresqlhsc.models.PostgreSQLVersion + :ivar citus_version: The Citus version of server group. Possible values include: "8.3", "9.0", + "9.1", "9.2", "9.3", "9.4", "9.5". + :vartype citus_version: str or ~azure.mgmt.rdbms.postgresqlhsc.models.CitusVersion + :ivar enable_shards_on_coordinator: If shards on coordinator is enabled or not for the server + group. + :vartype enable_shards_on_coordinator: bool + :ivar server_role_groups: The list of server role groups. + :vartype server_role_groups: list[~azure.mgmt.rdbms.postgresqlhsc.models.ServerRoleGroup] + :ivar maintenance_window: Maintenance window of a server group. + :vartype maintenance_window: ~azure.mgmt.rdbms.postgresqlhsc.models.MaintenanceWindow + :ivar availability_zone: Availability Zone information of the server group. + :vartype availability_zone: str + :ivar standby_availability_zone: Standby Availability Zone information of the server group. + :vartype standby_availability_zone: str + """ + + _validation = { + 'server_role_groups': {'max_items': 2, 'min_items': 1, 'unique': True}, + } + + _attribute_map = { + 'location': {'key': 'location', 'type': 'str'}, + 'tags': {'key': 'tags', 'type': '{str}'}, + 'administrator_login_password': {'key': 'properties.administratorLoginPassword', 'type': 'str'}, + 'backup_retention_days': {'key': 'properties.backupRetentionDays', 'type': 'int'}, + 'postgresql_version': {'key': 'properties.postgresqlVersion', 'type': 'str'}, + 'citus_version': {'key': 'properties.citusVersion', 'type': 'str'}, + 'enable_shards_on_coordinator': {'key': 'properties.enableShardsOnCoordinator', 'type': 'bool'}, + 'server_role_groups': {'key': 'properties.serverRoleGroups', 'type': '[ServerRoleGroup]'}, + 'maintenance_window': {'key': 'properties.maintenanceWindow', 'type': 'MaintenanceWindow'}, + 'availability_zone': {'key': 'properties.availabilityZone', 'type': 'str'}, + 'standby_availability_zone': {'key': 'properties.standbyAvailabilityZone', 'type': 'str'}, + } + + def __init__( + self, + *, + location: Optional[str] = None, + tags: Optional[Dict[str, str]] = None, + administrator_login_password: Optional[str] = None, + backup_retention_days: Optional[int] = None, + postgresql_version: Optional[Union[str, "PostgreSQLVersion"]] = None, + citus_version: Optional[Union[str, "CitusVersion"]] = None, + enable_shards_on_coordinator: Optional[bool] = None, + server_role_groups: Optional[List["ServerRoleGroup"]] = None, + maintenance_window: Optional["MaintenanceWindow"] = None, + availability_zone: Optional[str] = None, + standby_availability_zone: Optional[str] = None, + **kwargs + ): + """ + :keyword location: The location the resource resides in. + :paramtype location: str + :keyword tags: A set of tags. Application-specific metadata in the form of key-value pairs. + :paramtype tags: dict[str, str] + :keyword administrator_login_password: The password of the administrator login. + :paramtype administrator_login_password: str + :keyword backup_retention_days: The backup retention days for server group. + :paramtype backup_retention_days: int + :keyword postgresql_version: The PostgreSQL version of server group. Possible values include: + "11", "12". + :paramtype postgresql_version: str or ~azure.mgmt.rdbms.postgresqlhsc.models.PostgreSQLVersion + :keyword citus_version: The Citus version of server group. Possible values include: "8.3", + "9.0", "9.1", "9.2", "9.3", "9.4", "9.5". + :paramtype citus_version: str or ~azure.mgmt.rdbms.postgresqlhsc.models.CitusVersion + :keyword enable_shards_on_coordinator: If shards on coordinator is enabled or not for the + server group. + :paramtype enable_shards_on_coordinator: bool + :keyword server_role_groups: The list of server role groups. + :paramtype server_role_groups: list[~azure.mgmt.rdbms.postgresqlhsc.models.ServerRoleGroup] + :keyword maintenance_window: Maintenance window of a server group. + :paramtype maintenance_window: ~azure.mgmt.rdbms.postgresqlhsc.models.MaintenanceWindow + :keyword availability_zone: Availability Zone information of the server group. + :paramtype availability_zone: str + :keyword standby_availability_zone: Standby Availability Zone information of the server group. + :paramtype standby_availability_zone: str + """ + super(ServerGroupForUpdate, self).__init__(**kwargs) + self.location = location + self.tags = tags + self.administrator_login_password = administrator_login_password + self.backup_retention_days = backup_retention_days + self.postgresql_version = postgresql_version + self.citus_version = citus_version + self.enable_shards_on_coordinator = enable_shards_on_coordinator + self.server_role_groups = server_role_groups + self.maintenance_window = maintenance_window + self.availability_zone = availability_zone + self.standby_availability_zone = standby_availability_zone + + +class ServerGroupListResult(msrest.serialization.Model): + """A list of server groups. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar value: The list of server groups. + :vartype value: list[~azure.mgmt.rdbms.postgresqlhsc.models.ServerGroup] + :ivar next_link: The link used to get the next page of operations. + :vartype next_link: str + """ + + _validation = { + 'next_link': {'readonly': True}, + } + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ServerGroup]'}, + 'next_link': {'key': 'nextLink', 'type': 'str'}, + } + + def __init__( + self, + *, + value: Optional[List["ServerGroup"]] = None, + **kwargs + ): + """ + :keyword value: The list of server groups. + :paramtype value: list[~azure.mgmt.rdbms.postgresqlhsc.models.ServerGroup] + """ + super(ServerGroupListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class ServerGroupPropertiesDelegatedSubnetArguments(msrest.serialization.Model): + """The delegated subnet arguments for a server group. + + :ivar subnet_arm_resource_id: delegated subnet arm resource id. + :vartype subnet_arm_resource_id: str + """ + + _attribute_map = { + 'subnet_arm_resource_id': {'key': 'subnetArmResourceId', 'type': 'str'}, + } + + def __init__( + self, + *, + subnet_arm_resource_id: Optional[str] = None, + **kwargs + ): + """ + :keyword subnet_arm_resource_id: delegated subnet arm resource id. + :paramtype subnet_arm_resource_id: str + """ + super(ServerGroupPropertiesDelegatedSubnetArguments, self).__init__(**kwargs) + self.subnet_arm_resource_id = subnet_arm_resource_id + + +class ServerGroupPropertiesPrivateDnsZoneArguments(msrest.serialization.Model): + """The private dns zone arguments for a server group. + + :ivar private_dns_zone_arm_resource_id: private dns zone arm resource id. + :vartype private_dns_zone_arm_resource_id: str + """ + + _attribute_map = { + 'private_dns_zone_arm_resource_id': {'key': 'privateDnsZoneArmResourceId', 'type': 'str'}, + } + + def __init__( + self, + *, + private_dns_zone_arm_resource_id: Optional[str] = None, + **kwargs + ): + """ + :keyword private_dns_zone_arm_resource_id: private dns zone arm resource id. + :paramtype private_dns_zone_arm_resource_id: str + """ + super(ServerGroupPropertiesPrivateDnsZoneArguments, self).__init__(**kwargs) + self.private_dns_zone_arm_resource_id = private_dns_zone_arm_resource_id + + +class ServerGroupServer(ProxyResource): + """Represents a server in a server group. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar id: Fully qualified resource ID for the resource. Ex - + /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. + :vartype id: str + :ivar name: The name of the resource. + :vartype name: str + :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or + "Microsoft.Storage/storageAccounts". + :vartype type: str + :ivar system_data: The system metadata relating to this resource. + :vartype system_data: ~azure.mgmt.rdbms.postgresqlhsc.models.SystemData + :ivar server_edition: The edition of a server (default: GeneralPurpose). Possible values + include: "GeneralPurpose", "MemoryOptimized". + :vartype server_edition: str or ~azure.mgmt.rdbms.postgresqlhsc.models.ServerEdition + :ivar storage_quota_in_mb: The storage of a server in MB (max: 2097152 = 2TiB). + :vartype storage_quota_in_mb: long + :ivar v_cores: The vCores count of a server (max: 64). + :vartype v_cores: long + :ivar enable_ha: If high availability is enabled or not for the server. + :vartype enable_ha: bool + :ivar enable_public_ip: If public IP is requested or not for a server. + :vartype enable_public_ip: bool + :ivar fully_qualified_domain_name: The fully qualified domain name of a server. + :vartype fully_qualified_domain_name: str + :ivar role: The role of server in the server group. Possible values include: "Coordinator", + "Worker". + :vartype role: str or ~azure.mgmt.rdbms.postgresqlhsc.models.ServerRole + :ivar state: A state of a server that is visible to user. Possible values include: "Ready", + "Dropping", "Disabled", "Starting", "Stopping", "Stopped", "Updating", "Provisioning". + :vartype state: str or ~azure.mgmt.rdbms.postgresqlhsc.models.ServerState + :ivar ha_state: A state of a server group that is visible to user for HA feature. Possible + values include: "NotEnabled", "CreatingStandby", "ReplicatingData", "FailingOver", "Healthy", + "RemovingStandby", "NotSync". + :vartype ha_state: str or ~azure.mgmt.rdbms.postgresqlhsc.models.ServerHaState + :ivar administrator_login: The administrator's login name of a servers in server group. + :vartype administrator_login: str + :ivar postgresql_version: The PostgreSQL version of server. Possible values include: "11", + "12". + :vartype postgresql_version: str or ~azure.mgmt.rdbms.postgresqlhsc.models.PostgreSQLVersion + :ivar citus_version: The Citus version of server. Possible values include: "8.3", "9.0", "9.1", + "9.2", "9.3", "9.4", "9.5". + :vartype citus_version: str or ~azure.mgmt.rdbms.postgresqlhsc.models.CitusVersion + :ivar availability_zone: Availability Zone information of the server group. + :vartype availability_zone: str + :ivar standby_availability_zone: Standby Availability Zone information of the server group. + :vartype standby_availability_zone: str + """ + + _validation = { + 'id': {'readonly': True}, + 'name': {'readonly': True}, + 'type': {'readonly': True}, + 'system_data': {'readonly': True}, + 'enable_public_ip': {'readonly': True}, + 'fully_qualified_domain_name': {'readonly': True}, + 'state': {'readonly': True}, + 'ha_state': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, + 'server_edition': {'key': 'properties.serverEdition', 'type': 'str'}, + 'storage_quota_in_mb': {'key': 'properties.storageQuotaInMb', 'type': 'long'}, + 'v_cores': {'key': 'properties.vCores', 'type': 'long'}, + 'enable_ha': {'key': 'properties.enableHa', 'type': 'bool'}, + 'enable_public_ip': {'key': 'properties.enablePublicIp', 'type': 'bool'}, + 'fully_qualified_domain_name': {'key': 'properties.fullyQualifiedDomainName', 'type': 'str'}, + 'role': {'key': 'properties.role', 'type': 'str'}, + 'state': {'key': 'properties.state', 'type': 'str'}, + 'ha_state': {'key': 'properties.haState', 'type': 'str'}, + 'administrator_login': {'key': 'properties.administratorLogin', 'type': 'str'}, + 'postgresql_version': {'key': 'properties.postgresqlVersion', 'type': 'str'}, + 'citus_version': {'key': 'properties.citusVersion', 'type': 'str'}, + 'availability_zone': {'key': 'properties.availabilityZone', 'type': 'str'}, + 'standby_availability_zone': {'key': 'properties.standbyAvailabilityZone', 'type': 'str'}, + } + + def __init__( + self, + *, + server_edition: Optional[Union[str, "ServerEdition"]] = None, + storage_quota_in_mb: Optional[int] = None, + v_cores: Optional[int] = None, + enable_ha: Optional[bool] = None, + role: Optional[Union[str, "ServerRole"]] = None, + administrator_login: Optional[str] = None, + postgresql_version: Optional[Union[str, "PostgreSQLVersion"]] = None, + citus_version: Optional[Union[str, "CitusVersion"]] = None, + availability_zone: Optional[str] = None, + standby_availability_zone: Optional[str] = None, + **kwargs + ): + """ + :keyword server_edition: The edition of a server (default: GeneralPurpose). Possible values + include: "GeneralPurpose", "MemoryOptimized". + :paramtype server_edition: str or ~azure.mgmt.rdbms.postgresqlhsc.models.ServerEdition + :keyword storage_quota_in_mb: The storage of a server in MB (max: 2097152 = 2TiB). + :paramtype storage_quota_in_mb: long + :keyword v_cores: The vCores count of a server (max: 64). + :paramtype v_cores: long + :keyword enable_ha: If high availability is enabled or not for the server. + :paramtype enable_ha: bool + :keyword role: The role of server in the server group. Possible values include: "Coordinator", + "Worker". + :paramtype role: str or ~azure.mgmt.rdbms.postgresqlhsc.models.ServerRole + :keyword administrator_login: The administrator's login name of a servers in server group. + :paramtype administrator_login: str + :keyword postgresql_version: The PostgreSQL version of server. Possible values include: "11", + "12". + :paramtype postgresql_version: str or ~azure.mgmt.rdbms.postgresqlhsc.models.PostgreSQLVersion + :keyword citus_version: The Citus version of server. Possible values include: "8.3", "9.0", + "9.1", "9.2", "9.3", "9.4", "9.5". + :paramtype citus_version: str or ~azure.mgmt.rdbms.postgresqlhsc.models.CitusVersion + :keyword availability_zone: Availability Zone information of the server group. + :paramtype availability_zone: str + :keyword standby_availability_zone: Standby Availability Zone information of the server group. + :paramtype standby_availability_zone: str + """ + super(ServerGroupServer, self).__init__(**kwargs) + self.system_data = None + self.server_edition = server_edition + self.storage_quota_in_mb = storage_quota_in_mb + self.v_cores = v_cores + self.enable_ha = enable_ha + self.enable_public_ip = None + self.fully_qualified_domain_name = None + self.role = role + self.state = None + self.ha_state = None + self.administrator_login = administrator_login + self.postgresql_version = postgresql_version + self.citus_version = citus_version + self.availability_zone = availability_zone + self.standby_availability_zone = standby_availability_zone + + +class ServerGroupServerListResult(msrest.serialization.Model): + """A list of servers in a server group. + + :ivar value: The list of servers in a server group. + :vartype value: list[~azure.mgmt.rdbms.postgresqlhsc.models.ServerGroupServer] + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ServerGroupServer]'}, + } + + def __init__( + self, + *, + value: Optional[List["ServerGroupServer"]] = None, + **kwargs + ): + """ + :keyword value: The list of servers in a server group. + :paramtype value: list[~azure.mgmt.rdbms.postgresqlhsc.models.ServerGroupServer] + """ + super(ServerGroupServerListResult, self).__init__(**kwargs) + self.value = value + + +class ServerProperties(msrest.serialization.Model): + """The properties of a server. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar server_edition: The edition of a server (default: GeneralPurpose). Possible values + include: "GeneralPurpose", "MemoryOptimized". + :vartype server_edition: str or ~azure.mgmt.rdbms.postgresqlhsc.models.ServerEdition + :ivar storage_quota_in_mb: The storage of a server in MB (max: 2097152 = 2TiB). + :vartype storage_quota_in_mb: long + :ivar v_cores: The vCores count of a server (max: 64). + :vartype v_cores: long + :ivar enable_ha: If high availability is enabled or not for the server. + :vartype enable_ha: bool + :ivar enable_public_ip: If public IP is requested or not for a server. + :vartype enable_public_ip: bool + """ + + _validation = { + 'enable_public_ip': {'readonly': True}, + } + + _attribute_map = { + 'server_edition': {'key': 'serverEdition', 'type': 'str'}, + 'storage_quota_in_mb': {'key': 'storageQuotaInMb', 'type': 'long'}, + 'v_cores': {'key': 'vCores', 'type': 'long'}, + 'enable_ha': {'key': 'enableHa', 'type': 'bool'}, + 'enable_public_ip': {'key': 'enablePublicIp', 'type': 'bool'}, + } + + def __init__( + self, + *, + server_edition: Optional[Union[str, "ServerEdition"]] = None, + storage_quota_in_mb: Optional[int] = None, + v_cores: Optional[int] = None, + enable_ha: Optional[bool] = None, + **kwargs + ): + """ + :keyword server_edition: The edition of a server (default: GeneralPurpose). Possible values + include: "GeneralPurpose", "MemoryOptimized". + :paramtype server_edition: str or ~azure.mgmt.rdbms.postgresqlhsc.models.ServerEdition + :keyword storage_quota_in_mb: The storage of a server in MB (max: 2097152 = 2TiB). + :paramtype storage_quota_in_mb: long + :keyword v_cores: The vCores count of a server (max: 64). + :paramtype v_cores: long + :keyword enable_ha: If high availability is enabled or not for the server. + :paramtype enable_ha: bool + """ + super(ServerProperties, self).__init__(**kwargs) + self.server_edition = server_edition + self.storage_quota_in_mb = storage_quota_in_mb + self.v_cores = v_cores + self.enable_ha = enable_ha + self.enable_public_ip = None + + +class ServerGroupServerProperties(ServerProperties): + """The properties of a server in server group. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar server_edition: The edition of a server (default: GeneralPurpose). Possible values + include: "GeneralPurpose", "MemoryOptimized". + :vartype server_edition: str or ~azure.mgmt.rdbms.postgresqlhsc.models.ServerEdition + :ivar storage_quota_in_mb: The storage of a server in MB (max: 2097152 = 2TiB). + :vartype storage_quota_in_mb: long + :ivar v_cores: The vCores count of a server (max: 64). + :vartype v_cores: long + :ivar enable_ha: If high availability is enabled or not for the server. + :vartype enable_ha: bool + :ivar enable_public_ip: If public IP is requested or not for a server. + :vartype enable_public_ip: bool + :ivar fully_qualified_domain_name: The fully qualified domain name of a server. + :vartype fully_qualified_domain_name: str + :ivar role: The role of server in the server group. Possible values include: "Coordinator", + "Worker". + :vartype role: str or ~azure.mgmt.rdbms.postgresqlhsc.models.ServerRole + :ivar state: A state of a server that is visible to user. Possible values include: "Ready", + "Dropping", "Disabled", "Starting", "Stopping", "Stopped", "Updating", "Provisioning". + :vartype state: str or ~azure.mgmt.rdbms.postgresqlhsc.models.ServerState + :ivar ha_state: A state of a server group that is visible to user for HA feature. Possible + values include: "NotEnabled", "CreatingStandby", "ReplicatingData", "FailingOver", "Healthy", + "RemovingStandby", "NotSync". + :vartype ha_state: str or ~azure.mgmt.rdbms.postgresqlhsc.models.ServerHaState + :ivar administrator_login: The administrator's login name of a servers in server group. + :vartype administrator_login: str + :ivar postgresql_version: The PostgreSQL version of server. Possible values include: "11", + "12". + :vartype postgresql_version: str or ~azure.mgmt.rdbms.postgresqlhsc.models.PostgreSQLVersion + :ivar citus_version: The Citus version of server. Possible values include: "8.3", "9.0", "9.1", + "9.2", "9.3", "9.4", "9.5". + :vartype citus_version: str or ~azure.mgmt.rdbms.postgresqlhsc.models.CitusVersion + :ivar availability_zone: Availability Zone information of the server group. + :vartype availability_zone: str + :ivar standby_availability_zone: Standby Availability Zone information of the server group. + :vartype standby_availability_zone: str + """ + + _validation = { + 'enable_public_ip': {'readonly': True}, + 'fully_qualified_domain_name': {'readonly': True}, + 'state': {'readonly': True}, + 'ha_state': {'readonly': True}, + } + + _attribute_map = { + 'server_edition': {'key': 'serverEdition', 'type': 'str'}, + 'storage_quota_in_mb': {'key': 'storageQuotaInMb', 'type': 'long'}, + 'v_cores': {'key': 'vCores', 'type': 'long'}, + 'enable_ha': {'key': 'enableHa', 'type': 'bool'}, + 'enable_public_ip': {'key': 'enablePublicIp', 'type': 'bool'}, + 'fully_qualified_domain_name': {'key': 'fullyQualifiedDomainName', 'type': 'str'}, + 'role': {'key': 'role', 'type': 'str'}, + 'state': {'key': 'state', 'type': 'str'}, + 'ha_state': {'key': 'haState', 'type': 'str'}, + 'administrator_login': {'key': 'administratorLogin', 'type': 'str'}, + 'postgresql_version': {'key': 'postgresqlVersion', 'type': 'str'}, + 'citus_version': {'key': 'citusVersion', 'type': 'str'}, + 'availability_zone': {'key': 'availabilityZone', 'type': 'str'}, + 'standby_availability_zone': {'key': 'standbyAvailabilityZone', 'type': 'str'}, + } + + def __init__( + self, + *, + server_edition: Optional[Union[str, "ServerEdition"]] = None, + storage_quota_in_mb: Optional[int] = None, + v_cores: Optional[int] = None, + enable_ha: Optional[bool] = None, + role: Optional[Union[str, "ServerRole"]] = None, + administrator_login: Optional[str] = None, + postgresql_version: Optional[Union[str, "PostgreSQLVersion"]] = None, + citus_version: Optional[Union[str, "CitusVersion"]] = None, + availability_zone: Optional[str] = None, + standby_availability_zone: Optional[str] = None, + **kwargs + ): + """ + :keyword server_edition: The edition of a server (default: GeneralPurpose). Possible values + include: "GeneralPurpose", "MemoryOptimized". + :paramtype server_edition: str or ~azure.mgmt.rdbms.postgresqlhsc.models.ServerEdition + :keyword storage_quota_in_mb: The storage of a server in MB (max: 2097152 = 2TiB). + :paramtype storage_quota_in_mb: long + :keyword v_cores: The vCores count of a server (max: 64). + :paramtype v_cores: long + :keyword enable_ha: If high availability is enabled or not for the server. + :paramtype enable_ha: bool + :keyword role: The role of server in the server group. Possible values include: "Coordinator", + "Worker". + :paramtype role: str or ~azure.mgmt.rdbms.postgresqlhsc.models.ServerRole + :keyword administrator_login: The administrator's login name of a servers in server group. + :paramtype administrator_login: str + :keyword postgresql_version: The PostgreSQL version of server. Possible values include: "11", + "12". + :paramtype postgresql_version: str or ~azure.mgmt.rdbms.postgresqlhsc.models.PostgreSQLVersion + :keyword citus_version: The Citus version of server. Possible values include: "8.3", "9.0", + "9.1", "9.2", "9.3", "9.4", "9.5". + :paramtype citus_version: str or ~azure.mgmt.rdbms.postgresqlhsc.models.CitusVersion + :keyword availability_zone: Availability Zone information of the server group. + :paramtype availability_zone: str + :keyword standby_availability_zone: Standby Availability Zone information of the server group. + :paramtype standby_availability_zone: str + """ + super(ServerGroupServerProperties, self).__init__(server_edition=server_edition, storage_quota_in_mb=storage_quota_in_mb, v_cores=v_cores, enable_ha=enable_ha, **kwargs) + self.fully_qualified_domain_name = None + self.role = role + self.state = None + self.ha_state = None + self.administrator_login = administrator_login + self.postgresql_version = postgresql_version + self.citus_version = citus_version + self.availability_zone = availability_zone + self.standby_availability_zone = standby_availability_zone + + +class ServerNameItem(msrest.serialization.Model): + """The name object for a server. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name: The name of a server. + :vartype name: str + :ivar fully_qualified_domain_name: The fully qualified domain name of a server. + :vartype fully_qualified_domain_name: str + """ + + _validation = { + 'fully_qualified_domain_name': {'readonly': True}, + } + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'fully_qualified_domain_name': {'key': 'fullyQualifiedDomainName', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + **kwargs + ): + """ + :keyword name: The name of a server. + :paramtype name: str + """ + super(ServerNameItem, self).__init__(**kwargs) + self.name = name + self.fully_qualified_domain_name = None + + +class ServerRoleGroup(ServerProperties): + """Represents a server role group. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar server_edition: The edition of a server (default: GeneralPurpose). Possible values + include: "GeneralPurpose", "MemoryOptimized". + :vartype server_edition: str or ~azure.mgmt.rdbms.postgresqlhsc.models.ServerEdition + :ivar storage_quota_in_mb: The storage of a server in MB (max: 2097152 = 2TiB). + :vartype storage_quota_in_mb: long + :ivar v_cores: The vCores count of a server (max: 64). + :vartype v_cores: long + :ivar enable_ha: If high availability is enabled or not for the server. + :vartype enable_ha: bool + :ivar enable_public_ip: If public IP is requested or not for a server. + :vartype enable_public_ip: bool + :ivar name: The name of the server role group. + :vartype name: str + :ivar role: The role of servers in the server role group. Possible values include: + "Coordinator", "Worker". + :vartype role: str or ~azure.mgmt.rdbms.postgresqlhsc.models.ServerRole + :ivar server_count: The number of servers in the server role group. + :vartype server_count: int + :ivar server_names: The list of server names in the server role group. + :vartype server_names: list[~azure.mgmt.rdbms.postgresqlhsc.models.ServerNameItem] + """ + + _validation = { + 'enable_public_ip': {'readonly': True}, + 'server_names': {'readonly': True, 'unique': True}, + } + + _attribute_map = { + 'server_edition': {'key': 'serverEdition', 'type': 'str'}, + 'storage_quota_in_mb': {'key': 'storageQuotaInMb', 'type': 'long'}, + 'v_cores': {'key': 'vCores', 'type': 'long'}, + 'enable_ha': {'key': 'enableHa', 'type': 'bool'}, + 'enable_public_ip': {'key': 'enablePublicIp', 'type': 'bool'}, + 'name': {'key': 'name', 'type': 'str'}, + 'role': {'key': 'role', 'type': 'str'}, + 'server_count': {'key': 'serverCount', 'type': 'int'}, + 'server_names': {'key': 'serverNames', 'type': '[ServerNameItem]'}, + } + + def __init__( + self, + *, + server_edition: Optional[Union[str, "ServerEdition"]] = None, + storage_quota_in_mb: Optional[int] = None, + v_cores: Optional[int] = None, + enable_ha: Optional[bool] = None, + name: Optional[str] = None, + role: Optional[Union[str, "ServerRole"]] = None, + server_count: Optional[int] = None, + **kwargs + ): + """ + :keyword server_edition: The edition of a server (default: GeneralPurpose). Possible values + include: "GeneralPurpose", "MemoryOptimized". + :paramtype server_edition: str or ~azure.mgmt.rdbms.postgresqlhsc.models.ServerEdition + :keyword storage_quota_in_mb: The storage of a server in MB (max: 2097152 = 2TiB). + :paramtype storage_quota_in_mb: long + :keyword v_cores: The vCores count of a server (max: 64). + :paramtype v_cores: long + :keyword enable_ha: If high availability is enabled or not for the server. + :paramtype enable_ha: bool + :keyword name: The name of the server role group. + :paramtype name: str + :keyword role: The role of servers in the server role group. Possible values include: + "Coordinator", "Worker". + :paramtype role: str or ~azure.mgmt.rdbms.postgresqlhsc.models.ServerRole + :keyword server_count: The number of servers in the server role group. + :paramtype server_count: int + """ + super(ServerRoleGroup, self).__init__(server_edition=server_edition, storage_quota_in_mb=storage_quota_in_mb, v_cores=v_cores, enable_ha=enable_ha, **kwargs) + self.name = name + self.role = role + self.server_count = server_count + self.server_names = None + + +class ServerRoleGroupConfiguration(msrest.serialization.Model): + """Represents server role group configuration value. + + 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 role: Required. The role of servers in the server role group. Possible values include: + "Coordinator", "Worker". + :vartype role: str or ~azure.mgmt.rdbms.postgresqlhsc.models.ServerRole + :ivar value: Required. Value of the configuration. + :vartype value: str + :ivar default_value: Default value of the configuration. + :vartype default_value: str + :ivar source: Source of the configuration. + :vartype source: str + """ + + _validation = { + 'role': {'required': True}, + 'value': {'required': True}, + 'default_value': {'readonly': True}, + 'source': {'readonly': True}, + } + + _attribute_map = { + 'role': {'key': 'role', 'type': 'str'}, + 'value': {'key': 'value', 'type': 'str'}, + 'default_value': {'key': 'defaultValue', 'type': 'str'}, + 'source': {'key': 'source', 'type': 'str'}, + } + + def __init__( + self, + *, + role: Union[str, "ServerRole"], + value: str, + **kwargs + ): + """ + :keyword role: Required. The role of servers in the server role group. Possible values include: + "Coordinator", "Worker". + :paramtype role: str or ~azure.mgmt.rdbms.postgresqlhsc.models.ServerRole + :keyword value: Required. Value of the configuration. + :paramtype value: str + """ + super(ServerRoleGroupConfiguration, self).__init__(**kwargs) + self.role = role + self.value = value + self.default_value = None + self.source = None + + +class SystemData(msrest.serialization.Model): + """Metadata pertaining to creation and last modification of the resource. + + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Possible values include: + "User", "Application", "ManagedIdentity", "Key". + :vartype created_by_type: str or ~azure.mgmt.rdbms.postgresqlhsc.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :vartype last_modified_by_type: str or ~azure.mgmt.rdbms.postgresqlhsc.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime + """ + + _attribute_map = { + 'created_by': {'key': 'createdBy', 'type': 'str'}, + 'created_by_type': {'key': 'createdByType', 'type': 'str'}, + 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, + 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, + 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, + 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, + } + + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + **kwargs + ): + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Possible values + include: "User", "Application", "ManagedIdentity", "Key". + :paramtype created_by_type: str or ~azure.mgmt.rdbms.postgresqlhsc.models.CreatedByType + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: The identity that last modified the resource. + :paramtype last_modified_by: str + :keyword last_modified_by_type: The type of identity that last modified the resource. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :paramtype last_modified_by_type: str or ~azure.mgmt.rdbms.postgresqlhsc.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + """ + super(SystemData, self).__init__(**kwargs) + self.created_by = created_by + self.created_by_type = created_by_type + self.created_at = created_at + self.last_modified_by = last_modified_by + self.last_modified_by_type = last_modified_by_type + self.last_modified_at = last_modified_at diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/operations/__init__.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/operations/__init__.py new file mode 100644 index 000000000000..9bd9cd11bf46 --- /dev/null +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/operations/__init__.py @@ -0,0 +1,23 @@ +# 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 ._server_groups_operations import ServerGroupsOperations +from ._servers_operations import ServersOperations +from ._configurations_operations import ConfigurationsOperations +from ._firewall_rules_operations import FirewallRulesOperations +from ._roles_operations import RolesOperations +from ._operations import Operations + +__all__ = [ + 'ServerGroupsOperations', + 'ServersOperations', + 'ConfigurationsOperations', + 'FirewallRulesOperations', + 'RolesOperations', + 'Operations', +] diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/operations/_configurations_operations.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/operations/_configurations_operations.py new file mode 100644 index 000000000000..5df6bbcbb0b7 --- /dev/null +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/operations/_configurations_operations.py @@ -0,0 +1,541 @@ +# 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_server_request( + subscription_id: str, + resource_group_name: str, + server_group_name: str, + server_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-05-privatepreview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}/servers/{serverName}/configurations') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "serverGroupName": _SERIALIZER.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + "serverName": _SERIALIZER.url("server_name", server_name, 'str', max_length=90, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_server_group_request( + subscription_id: str, + resource_group_name: str, + server_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-05-privatepreview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}/configurations') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "serverGroupName": _SERIALIZER.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_update_request_initial( + subscription_id: str, + resource_group_name: str, + server_group_name: str, + configuration_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-05-privatepreview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}/configurations/{configurationName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "serverGroupName": _SERIALIZER.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + "configurationName": _SERIALIZER.url("configuration_name", configuration_name, 'str', max_length=90, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + server_group_name: str, + configuration_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-05-privatepreview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}/configurations/{configurationName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "serverGroupName": _SERIALIZER.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + "configurationName": _SERIALIZER.url("configuration_name", configuration_name, 'str', max_length=90, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +class ConfigurationsOperations(object): + """ConfigurationsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.rdbms.postgresqlhsc.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list_by_server( + self, + resource_group_name: str, + server_group_name: str, + server_name: str, + **kwargs: Any + ) -> Iterable["_models.ServerConfigurationListResult"]: + """List all the configurations of a server in server group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param server_group_name: The name of the server group. + :type server_group_name: str + :param server_name: The name of the server. + :type server_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ServerConfigurationListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.rdbms.postgresqlhsc.models.ServerConfigurationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerConfigurationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_server_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_group_name=server_group_name, + server_name=server_name, + template_url=self.list_by_server.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_server_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_group_name=server_group_name, + server_name=server_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ServerConfigurationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_server.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}/servers/{serverName}/configurations'} # type: ignore + + @distributed_trace + def list_by_server_group( + self, + resource_group_name: str, + server_group_name: str, + **kwargs: Any + ) -> Iterable["_models.ServerGroupConfigurationListResult"]: + """List all the configurations of a server group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param server_group_name: The name of the server group. + :type server_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ServerGroupConfigurationListResult or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.rdbms.postgresqlhsc.models.ServerGroupConfigurationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerGroupConfigurationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_server_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_group_name=server_group_name, + template_url=self.list_by_server_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_server_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_group_name=server_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ServerGroupConfigurationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_server_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}/configurations'} # type: ignore + + def _update_initial( + self, + resource_group_name: str, + server_group_name: str, + configuration_name: str, + parameters: "_models.ServerGroupConfiguration", + **kwargs: Any + ) -> Optional["_models.ServerGroupConfiguration"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ServerGroupConfiguration"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ServerGroupConfiguration') + + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_group_name=server_group_name, + configuration_name=configuration_name, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ServerGroupConfiguration', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}/configurations/{configurationName}'} # type: ignore + + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + server_group_name: str, + configuration_name: str, + parameters: "_models.ServerGroupConfiguration", + **kwargs: Any + ) -> LROPoller["_models.ServerGroupConfiguration"]: + """Updates configuration of server role groups in a server group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param server_group_name: The name of the server group. + :type server_group_name: str + :param configuration_name: The name of the server group configuration. + :type configuration_name: str + :param parameters: The required parameters for updating a server group configuration. + :type parameters: ~azure.mgmt.rdbms.postgresqlhsc.models.ServerGroupConfiguration + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ServerGroupConfiguration or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.rdbms.postgresqlhsc.models.ServerGroupConfiguration] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerGroupConfiguration"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + server_group_name=server_group_name, + configuration_name=configuration_name, + parameters=parameters, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('ServerGroupConfiguration', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}/configurations/{configurationName}'} # type: ignore + + @distributed_trace + def get( + self, + resource_group_name: str, + server_group_name: str, + configuration_name: str, + **kwargs: Any + ) -> "_models.ServerGroupConfiguration": + """Gets information about single server group configuration. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param server_group_name: The name of the server group. + :type server_group_name: str + :param configuration_name: The name of the server group configuration. + :type configuration_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ServerGroupConfiguration, or the result of cls(response) + :rtype: ~azure.mgmt.rdbms.postgresqlhsc.models.ServerGroupConfiguration + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerGroupConfiguration"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_group_name=server_group_name, + configuration_name=configuration_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ServerGroupConfiguration', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}/configurations/{configurationName}'} # type: ignore + diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/operations/_firewall_rules_operations.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/operations/_firewall_rules_operations.py new file mode 100644 index 000000000000..b79dc40cb405 --- /dev/null +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/operations/_firewall_rules_operations.py @@ -0,0 +1,565 @@ +# 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_or_update_request_initial( + subscription_id: str, + resource_group_name: str, + server_group_name: str, + firewall_rule_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-05-privatepreview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}/firewallRules/{firewallRuleName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "serverGroupName": _SERIALIZER.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + "firewallRuleName": _SERIALIZER.url("firewall_rule_name", firewall_rule_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id: str, + resource_group_name: str, + server_group_name: str, + firewall_rule_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-05-privatepreview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}/firewallRules/{firewallRuleName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "serverGroupName": _SERIALIZER.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + "firewallRuleName": _SERIALIZER.url("firewall_rule_name", firewall_rule_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + server_group_name: str, + firewall_rule_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-05-privatepreview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}/firewallRules/{firewallRuleName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "serverGroupName": _SERIALIZER.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + "firewallRuleName": _SERIALIZER.url("firewall_rule_name", firewall_rule_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_server_group_request( + subscription_id: str, + resource_group_name: str, + server_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-05-privatepreview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}/firewallRules') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "serverGroupName": _SERIALIZER.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +class FirewallRulesOperations(object): + """FirewallRulesOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.rdbms.postgresqlhsc.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def _create_or_update_initial( + self, + resource_group_name: str, + server_group_name: str, + firewall_rule_name: str, + parameters: "_models.FirewallRule", + **kwargs: Any + ) -> Optional["_models.FirewallRule"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.FirewallRule"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'FirewallRule') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_group_name=server_group_name, + firewall_rule_name=firewall_rule_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('FirewallRule', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('FirewallRule', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}/firewallRules/{firewallRuleName}'} # type: ignore + + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + server_group_name: str, + firewall_rule_name: str, + parameters: "_models.FirewallRule", + **kwargs: Any + ) -> LROPoller["_models.FirewallRule"]: + """Creates a new firewall rule or updates an existing firewall rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param server_group_name: The name of the server group. + :type server_group_name: str + :param firewall_rule_name: The name of the server group firewall rule. + :type firewall_rule_name: str + :param parameters: The required parameters for creating or updating a firewall rule. + :type parameters: ~azure.mgmt.rdbms.postgresqlhsc.models.FirewallRule + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either FirewallRule or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.rdbms.postgresqlhsc.models.FirewallRule] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.FirewallRule"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + server_group_name=server_group_name, + firewall_rule_name=firewall_rule_name, + parameters=parameters, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('FirewallRule', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}/firewallRules/{firewallRuleName}'} # type: ignore + + def _delete_initial( + self, + resource_group_name: str, + server_group_name: str, + firewall_rule_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_group_name=server_group_name, + firewall_rule_name=firewall_rule_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}/firewallRules/{firewallRuleName}'} # type: ignore + + + @distributed_trace + def begin_delete( + self, + resource_group_name: str, + server_group_name: str, + firewall_rule_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Deletes a server group firewall rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param server_group_name: The name of the server group. + :type server_group_name: str + :param firewall_rule_name: The name of the server group firewall rule. + :type firewall_rule_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + server_group_name=server_group_name, + firewall_rule_name=firewall_rule_name, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}/firewallRules/{firewallRuleName}'} # type: ignore + + @distributed_trace + def get( + self, + resource_group_name: str, + server_group_name: str, + firewall_rule_name: str, + **kwargs: Any + ) -> "_models.FirewallRule": + """Gets information about a server group firewall rule. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param server_group_name: The name of the server group. + :type server_group_name: str + :param firewall_rule_name: The name of the server group firewall rule. + :type firewall_rule_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: FirewallRule, or the result of cls(response) + :rtype: ~azure.mgmt.rdbms.postgresqlhsc.models.FirewallRule + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.FirewallRule"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_group_name=server_group_name, + firewall_rule_name=firewall_rule_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('FirewallRule', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}/firewallRules/{firewallRuleName}'} # type: ignore + + + @distributed_trace + def list_by_server_group( + self, + resource_group_name: str, + server_group_name: str, + **kwargs: Any + ) -> Iterable["_models.FirewallRuleListResult"]: + """List all the firewall rules in a given server group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param server_group_name: The name of the server group. + :type server_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either FirewallRuleListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.rdbms.postgresqlhsc.models.FirewallRuleListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.FirewallRuleListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_server_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_group_name=server_group_name, + template_url=self.list_by_server_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_server_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_group_name=server_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("FirewallRuleListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_server_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}/firewallRules'} # type: ignore diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/operations/_operations.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/operations/_operations.py new file mode 100644 index 000000000000..cdfced13b6f0 --- /dev/null +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/operations/_operations.py @@ -0,0 +1,135 @@ +# 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer + +from .. import models as _models +from .._vendor import _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-05-privatepreview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.DBForPostgreSql/operations') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +class Operations(object): + """Operations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.rdbms.postgresqlhsc.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> Iterable["_models.OperationListResult"]: + """Lists all of the available REST API operations. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either OperationListResult or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.rdbms.postgresqlhsc.models.OperationListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("OperationListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/providers/Microsoft.DBForPostgreSql/operations'} # type: ignore diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/operations/_roles_operations.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/operations/_roles_operations.py new file mode 100644 index 000000000000..9871fd8d8e59 --- /dev/null +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/operations/_roles_operations.py @@ -0,0 +1,470 @@ +# 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_create_request_initial( + subscription_id: str, + resource_group_name: str, + server_group_name: str, + role_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-05-privatepreview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}/roles/{roleName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "serverGroupName": _SERIALIZER.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + "roleName": _SERIALIZER.url("role_name", role_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id: str, + resource_group_name: str, + server_group_name: str, + role_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-05-privatepreview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}/roles/{roleName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "serverGroupName": _SERIALIZER.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + "roleName": _SERIALIZER.url("role_name", role_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_server_group_request( + subscription_id: str, + resource_group_name: str, + server_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-05-privatepreview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}/roles') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "serverGroupName": _SERIALIZER.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +class RolesOperations(object): + """RolesOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.rdbms.postgresqlhsc.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + def _create_initial( + self, + resource_group_name: str, + server_group_name: str, + role_name: str, + parameters: "_models.Role", + **kwargs: Any + ) -> Optional["_models.Role"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.Role"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'Role') + + request = build_create_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_group_name=server_group_name, + role_name=role_name, + content_type=content_type, + json=_json, + template_url=self._create_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('Role', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('Role', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}/roles/{roleName}'} # type: ignore + + + @distributed_trace + def begin_create( + self, + resource_group_name: str, + server_group_name: str, + role_name: str, + parameters: "_models.Role", + **kwargs: Any + ) -> LROPoller["_models.Role"]: + """Creates a new role or updates an existing role. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param server_group_name: The name of the server group. + :type server_group_name: str + :param role_name: The name of the server group role name. + :type role_name: str + :param parameters: The required parameters for creating or updating a role. + :type parameters: ~azure.mgmt.rdbms.postgresqlhsc.models.Role + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either Role or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.rdbms.postgresqlhsc.models.Role] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.Role"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_initial( + resource_group_name=resource_group_name, + server_group_name=server_group_name, + role_name=role_name, + parameters=parameters, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('Role', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}/roles/{roleName}'} # type: ignore + + def _delete_initial( + self, + resource_group_name: str, + server_group_name: str, + role_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_group_name=server_group_name, + role_name=role_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}/roles/{roleName}'} # type: ignore + + + @distributed_trace + def begin_delete( + self, + resource_group_name: str, + server_group_name: str, + role_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Deletes a server group role. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param server_group_name: The name of the server group. + :type server_group_name: str + :param role_name: The name of the server group role name. + :type role_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + server_group_name=server_group_name, + role_name=role_name, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}/roles/{roleName}'} # type: ignore + + @distributed_trace + def list_by_server_group( + self, + resource_group_name: str, + server_group_name: str, + **kwargs: Any + ) -> Iterable["_models.RoleListResult"]: + """List all the roles in a given server group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param server_group_name: The name of the server group. + :type server_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either RoleListResult or the result of cls(response) + :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.rdbms.postgresqlhsc.models.RoleListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.RoleListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_server_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_group_name=server_group_name, + template_url=self.list_by_server_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_server_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_group_name=server_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("RoleListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_server_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}/roles'} # type: ignore diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/operations/_server_groups_operations.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/operations/_server_groups_operations.py new file mode 100644 index 000000000000..5526e476b742 --- /dev/null +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/operations/_server_groups_operations.py @@ -0,0 +1,1280 @@ +# 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-05-privatepreview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.DBForPostgreSql/serverGroupsv2') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-05-privatepreview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + subscription_id: str, + resource_group_name: str, + server_group_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-05-privatepreview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "serverGroupName": _SERIALIZER.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + server_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-05-privatepreview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "serverGroupName": _SERIALIZER.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id: str, + resource_group_name: str, + server_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-05-privatepreview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "serverGroupName": _SERIALIZER.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_update_request_initial( + subscription_id: str, + resource_group_name: str, + server_group_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-05-privatepreview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "serverGroupName": _SERIALIZER.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_restart_request_initial( + subscription_id: str, + resource_group_name: str, + server_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-05-privatepreview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}/restart') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "serverGroupName": _SERIALIZER.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_start_request_initial( + subscription_id: str, + resource_group_name: str, + server_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-05-privatepreview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}/start') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "serverGroupName": _SERIALIZER.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_stop_request_initial( + subscription_id: str, + resource_group_name: str, + server_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-05-privatepreview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}/stop') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "serverGroupName": _SERIALIZER.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_check_name_availability_request( + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-10-05-privatepreview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.DBForPostgreSql/checkNameAvailability') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + +class ServerGroupsOperations(object): + """ServerGroupsOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.rdbms.postgresqlhsc.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list( + self, + **kwargs: Any + ) -> Iterable["_models.ServerGroupListResult"]: + """List all the server groups in a given subscription. + + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ServerGroupListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.rdbms.postgresqlhsc.models.ServerGroupListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerGroupListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ServerGroupListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DBForPostgreSql/serverGroupsv2'} # type: ignore + + @distributed_trace + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.ServerGroupListResult"]: + """List all the server groups in a given resource group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ServerGroupListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.rdbms.postgresqlhsc.models.ServerGroupListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerGroupListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ServerGroupListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return deserialized.next_link or None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2'} # type: ignore + + def _create_or_update_initial( + self, + resource_group_name: str, + server_group_name: str, + parameters: "_models.ServerGroup", + **kwargs: Any + ) -> Optional["_models.ServerGroup"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ServerGroup"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ServerGroup') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_group_name=server_group_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 201, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ServerGroup', pipeline_response) + + if response.status_code == 201: + deserialized = self._deserialize('ServerGroup', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}'} # type: ignore + + + @distributed_trace + def begin_create_or_update( + self, + resource_group_name: str, + server_group_name: str, + parameters: "_models.ServerGroup", + **kwargs: Any + ) -> LROPoller["_models.ServerGroup"]: + """Creates a new server group with servers. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param server_group_name: The name of the server group. + :type server_group_name: str + :param parameters: The required parameters for creating or updating a server group. + :type parameters: ~azure.mgmt.rdbms.postgresqlhsc.models.ServerGroup + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ServerGroup or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.rdbms.postgresqlhsc.models.ServerGroup] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerGroup"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._create_or_update_initial( + resource_group_name=resource_group_name, + server_group_name=server_group_name, + parameters=parameters, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('ServerGroup', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}'} # type: ignore + + @distributed_trace + def get( + self, + resource_group_name: str, + server_group_name: str, + **kwargs: Any + ) -> "_models.ServerGroup": + """Gets information about a server group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param server_group_name: The name of the server group. + :type server_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ServerGroup, or the result of cls(response) + :rtype: ~azure.mgmt.rdbms.postgresqlhsc.models.ServerGroup + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerGroup"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_group_name=server_group_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ServerGroup', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}'} # type: ignore + + + def _delete_initial( + self, + resource_group_name: str, + server_group_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_group_name=server_group_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}'} # type: ignore + + + @distributed_trace + def begin_delete( + self, + resource_group_name: str, + server_group_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Deletes a server group together with servers in it. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param server_group_name: The name of the server group. + :type server_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._delete_initial( + resource_group_name=resource_group_name, + server_group_name=server_group_name, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}'} # type: ignore + + def _update_initial( + self, + resource_group_name: str, + server_group_name: str, + parameters: "_models.ServerGroupForUpdate", + **kwargs: Any + ) -> Optional["_models.ServerGroup"]: + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ServerGroup"]] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(parameters, 'ServerGroupForUpdate') + + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_group_name=server_group_name, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('ServerGroup', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}'} # type: ignore + + + @distributed_trace + def begin_update( + self, + resource_group_name: str, + server_group_name: str, + parameters: "_models.ServerGroupForUpdate", + **kwargs: Any + ) -> LROPoller["_models.ServerGroup"]: + """Updates an existing server group. The request body can contain one to many of the properties + present in the normal server group definition. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param server_group_name: The name of the server group. + :type server_group_name: str + :param parameters: The parameters for updating a server group. + :type parameters: ~azure.mgmt.rdbms.postgresqlhsc.models.ServerGroupForUpdate + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either ServerGroup or the result of + cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.rdbms.postgresqlhsc.models.ServerGroup] + :raises: ~azure.core.exceptions.HttpResponseError + """ + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerGroup"] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._update_initial( + resource_group_name=resource_group_name, + server_group_name=server_group_name, + parameters=parameters, + content_type=content_type, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + response = pipeline_response.http_response + deserialized = self._deserialize('ServerGroup', pipeline_response) + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}'} # type: ignore + + def _restart_initial( + self, + resource_group_name: str, + server_group_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_restart_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_group_name=server_group_name, + template_url=self._restart_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _restart_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}/restart'} # type: ignore + + + @distributed_trace + def begin_restart( + self, + resource_group_name: str, + server_group_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Restarts the server group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param server_group_name: The name of the server group. + :type server_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._restart_initial( + resource_group_name=resource_group_name, + server_group_name=server_group_name, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_restart.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}/restart'} # type: ignore + + def _start_initial( + self, + resource_group_name: str, + server_group_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_start_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_group_name=server_group_name, + template_url=self._start_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _start_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}/start'} # type: ignore + + + @distributed_trace + def begin_start( + self, + resource_group_name: str, + server_group_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Starts the server group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param server_group_name: The name of the server group. + :type server_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._start_initial( + resource_group_name=resource_group_name, + server_group_name=server_group_name, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_start.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}/start'} # type: ignore + + def _stop_initial( + self, + resource_group_name: str, + server_group_name: str, + **kwargs: Any + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_stop_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_group_name=server_group_name, + template_url=self._stop_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200, 202]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + if cls: + return cls(pipeline_response, None, {}) + + _stop_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}/stop'} # type: ignore + + + @distributed_trace + def begin_stop( + self, + resource_group_name: str, + server_group_name: str, + **kwargs: Any + ) -> LROPoller[None]: + """Stops the server group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param server_group_name: The name of the server group. + :type server_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :keyword str continuation_token: A continuation token to restart a poller from a saved state. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. + :paramtype polling: bool or ~azure.core.polling.PollingMethod + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either None or the result of cls(response) + :rtype: ~azure.core.polling.LROPoller[None] + :raises: ~azure.core.exceptions.HttpResponseError + """ + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] + cls = kwargs.pop('cls', None) # type: ClsType[None] + lro_delay = kwargs.pop( + 'polling_interval', + self._config.polling_interval + ) + cont_token = kwargs.pop('continuation_token', None) # type: Optional[str] + if cont_token is None: + raw_result = self._stop_initial( + resource_group_name=resource_group_name, + server_group_name=server_group_name, + cls=lambda x,y,z: x, + **kwargs + ) + kwargs.pop('error_map', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) + elif polling is False: polling_method = NoPolling() + else: polling_method = polling + if cont_token: + return LROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output + ) + else: + return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + + begin_stop.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}/stop'} # type: ignore + + @distributed_trace + def check_name_availability( + self, + name_availability_request: "_models.NameAvailabilityRequest", + **kwargs: Any + ) -> "_models.NameAvailability": + """Check the availability of name for resource. + + :param name_availability_request: The required parameters for checking if resource name is + available. + :type name_availability_request: ~azure.mgmt.rdbms.postgresqlhsc.models.NameAvailabilityRequest + :keyword callable cls: A custom type or function that will be passed the direct response + :return: NameAvailability, or the result of cls(response) + :rtype: ~azure.mgmt.rdbms.postgresqlhsc.models.NameAvailability + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.NameAvailability"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(name_availability_request, 'NameAvailabilityRequest') + + request = build_check_name_availability_request( + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.check_name_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('NameAvailability', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.DBForPostgreSql/checkNameAvailability'} # type: ignore + diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/operations/_servers_operations.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/operations/_servers_operations.py new file mode 100644 index 000000000000..cd7297a7aa11 --- /dev/null +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/operations/_servers_operations.py @@ -0,0 +1,250 @@ +# 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 functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.paging import ItemPaged +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_server_group_request( + subscription_id: str, + resource_group_name: str, + server_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-05-privatepreview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}/servers') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "serverGroupName": _SERIALIZER.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + server_group_name: str, + server_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-10-05-privatepreview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}/servers/{serverName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "serverGroupName": _SERIALIZER.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + "serverName": _SERIALIZER.url("server_name", server_name, 'str', max_length=90, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + +class ServersOperations(object): + """ServersOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.rdbms.postgresqlhsc.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def list_by_server_group( + self, + resource_group_name: str, + server_group_name: str, + **kwargs: Any + ) -> Iterable["_models.ServerGroupServerListResult"]: + """Lists servers of a server group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param server_group_name: The name of the server group. + :type server_group_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: An iterator like instance of either ServerGroupServerListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.rdbms.postgresqlhsc.models.ServerGroupServerListResult] + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerGroupServerListResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + def prepare_request(next_link=None): + if not next_link: + + request = build_list_by_server_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_group_name=server_group_name, + template_url=self.list_by_server_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + else: + + request = build_list_by_server_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_group_name=server_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" + return request + + def extract_data(pipeline_response): + deserialized = self._deserialize("ServerGroupServerListResult", pipeline_response) + list_of_elem = deserialized.value + if cls: + list_of_elem = cls(list_of_elem) + return None, iter(list_of_elem) + + def get_next(next_link=None): + request = prepare_request(next_link) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + return pipeline_response + + + return ItemPaged( + get_next, extract_data + ) + list_by_server_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}/servers'} # type: ignore + + @distributed_trace + def get( + self, + resource_group_name: str, + server_group_name: str, + server_name: str, + **kwargs: Any + ) -> "_models.ServerGroupServer": + """Gets information about a server in server group. + + :param resource_group_name: The name of the resource group. The name is case insensitive. + :type resource_group_name: str + :param server_group_name: The name of the server group. + :type server_group_name: str + :param server_name: The name of the server. + :type server_name: str + :keyword callable cls: A custom type or function that will be passed the direct response + :return: ServerGroupServer, or the result of cls(response) + :rtype: ~azure.mgmt.rdbms.postgresqlhsc.models.ServerGroupServer + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.ServerGroupServer"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + server_group_name=server_group_name, + server_name=server_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) + + deserialized = self._deserialize('ServerGroupServer', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBForPostgreSql/serverGroupsv2/{serverGroupName}/servers/{serverName}'} # type: ignore + diff --git a/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/py.typed b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/py.typed new file mode 100644 index 000000000000..e5aff4f83af8 --- /dev/null +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file