From 27fc53a24b9a73510b6391a7a8fe73c071fbc830 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Mon, 14 Dec 2020 07:58:46 +0000 Subject: [PATCH] CodeGen from PR 11526 in Azure/azure-rest-api-specs Draft PR for PostgreSQLHSC (#11526) * New Readme Config File * New Go Language Readme Config File * New Typescript Language Readme Config File * New Python Language Readme Config File * New C# Language Readme Config File * New Ruby Language Readme Config File * New Swagger Spec File * New Swagger Example Spec File * initial swagger * common-types path fix * definition reference fix * Change publicIpRequested boolean with publicNetworkAccess enum * Change serverGroups to ServerGroupsv2 in path and id * Add responses to examples * Add missing location property to examples * Add missing locations to requests * Remove required name * Fix server group update * Convert some enums to boolean and renamings * Fix typo * Fix role properties problem * Add Citus to custom words * Run json prettier * Change responce for put server group * Fix role empty properties * Add state to server group * Update readmes * Add resourceProviderType to server group * Add sourceLocation to server group PITR * Change backup retention minutes to days * Fix linter errors * Add EarliestRestoreTime to server group * Fix semantic * Add Meru to custom words * Proviver name to pascal case * Add format for integers * Add 204 to delete * Add server group list endpoints * Fix listing operations * Change servers operation id * Remove haState from server role group * Add missing state to ServerState * Refactor configuration API * Add missing readOnly properties * Move ServerGroupConfig.defaultValue to ServerRoleGroupConfig * Rename serverRoleGroupConfigurationValues to serverRoleGroupConfigurations * Rename java namespace * Add systemData to all resources * Fix CheckNameAvailability warning * Run prettier * Add "fullyQualifiedDomainName" to server * Remove update from createMode * Remove createMode discriminator * Update ServerGet example * Add citusVersion to ServerGroupServer * Update descriptions for zfs and mx * Separate server group update properties * Add MMW to server group * Update sdk READMEs for namespaces * Refactor booleans with "enable..." prefix * Rename version with postgresqlVersion * Change vnetInjArgs to delegatedSubnetArguments * Add enableShardsOnCoordinator to server group * Add availability zone to server group and server group server * Add standbyAvailabilityZone to examples Co-authored-by: Enes Cakir --- .../mgmt/rdbms/postgresqlhsc/__init__.py | 16 + .../rdbms/postgresqlhsc/_configuration.py | 70 + .../mgmt/rdbms/postgresqlhsc/_metadata.json | 66 + .../_microsoft_postgre_sql_hyperscale.py | 94 + .../mgmt/rdbms/postgresqlhsc/aio/__init__.py | 10 + .../rdbms/postgresqlhsc/aio/_configuration.py | 66 + .../aio/_microsoft_postgre_sql_hyperscale.py | 88 + .../postgresqlhsc/aio/operations/__init__.py | 23 + .../operations/_configurations_operations.py | 391 +++++ .../operations/_firewall_rules_operations.py | 431 +++++ .../aio/operations/_operations.py | 104 ++ .../aio/operations/_roles_operations.py | 369 ++++ .../operations/_server_groups_operations.py | 985 +++++++++++ .../aio/operations/_servers_operations.py | 178 ++ .../rdbms/postgresqlhsc/models/__init__.py | 128 ++ ..._microsoft_postgre_sql_hyperscale_enums.py | 125 ++ .../rdbms/postgresqlhsc/models/_models.py | 1377 +++++++++++++++ .../rdbms/postgresqlhsc/models/_models_py3.py | 1510 +++++++++++++++++ .../postgresqlhsc/operations/__init__.py | 23 + .../operations/_configurations_operations.py | 400 +++++ .../operations/_firewall_rules_operations.py | 441 +++++ .../postgresqlhsc/operations/_operations.py | 109 ++ .../operations/_roles_operations.py | 378 +++++ .../operations/_server_groups_operations.py | 1005 +++++++++++ .../operations/_servers_operations.py | 184 ++ .../azure/mgmt/rdbms/postgresqlhsc/py.typed | 1 + 26 files changed, 8572 insertions(+) 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/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/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.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/azure/mgmt/rdbms/postgresqlhsc/__init__.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/__init__.py new file mode 100644 index 000000000000..6b1211b2b87b --- /dev/null +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/__init__.py @@ -0,0 +1,16 @@ +# 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'] + +try: + from ._patch import patch_sdk # type: ignore + patch_sdk() +except ImportError: + pass 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..fc2edddab41a --- /dev/null +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/_configuration.py @@ -0,0 +1,70 @@ +# 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 TYPE_CHECKING + +from azure.core.configuration import Configuration +from azure.core.pipeline import policies +from azure.mgmt.core.policies import ARMHttpLoggingPolicy + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any + + from azure.core.credentials import TokenCredential + +VERSION = "unknown" + +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, # type: "TokenCredential" + subscription_id, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + 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.") + super(MicrosoftPostgreSQLHyperscaleConfiguration, self).__init__(**kwargs) + + 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 = policies.BearerTokenCredentialPolicy(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..dace392fa091 --- /dev/null +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/_metadata.json @@ -0,0 +1,66 @@ +{ + "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.", + "base_url": "\u0027https://management.azure.com\u0027", + "custom_base_url": null, + "azure_arm": true, + "has_lro_operations": true, + "client_side_validation": true + }, + "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, # type: \"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, # type: str", + "description": "The ID of the target subscription.", + "docstring_type": "str", + "required": true + } + }, + "constant": { + }, + "call": "credential, subscription_id" + }, + "config": { + "credential": true, + "credential_scopes": ["https://management.azure.com/.default"], + "credential_default_policy_type": "BearerTokenCredentialPolicy", + "credential_default_policy_type_has_async_version": true, + "credential_key_header_name": null + }, + "operation_groups": { + "server_groups": "ServerGroupsOperations", + "servers": "ServersOperations", + "configurations": "ConfigurationsOperations", + "firewall_rules": "FirewallRulesOperations", + "roles": "RolesOperations", + "operations": "Operations" + }, + "operation_mixins": { + }, + "sync_imports": "None", + "async_imports": "None" +} \ 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..3c364b57d684 --- /dev/null +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/_microsoft_postgre_sql_hyperscale.py @@ -0,0 +1,94 @@ +# 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 TYPE_CHECKING + +from azure.mgmt.core import ARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Optional + + from azure.core.credentials import TokenCredential + +from ._configuration import MicrosoftPostgreSQLHyperscaleConfiguration +from .operations import ServerGroupsOperations +from .operations import ServersOperations +from .operations import ConfigurationsOperations +from .operations import FirewallRulesOperations +from .operations import RolesOperations +from .operations import Operations +from . import models + + +class MicrosoftPostgreSQLHyperscale(object): + """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 str base_url: Service URL + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + """ + + def __init__( + self, + credential, # type: "TokenCredential" + subscription_id, # type: str + base_url=None, # type: Optional[str] + **kwargs # type: Any + ): + # type: (...) -> None + if not base_url: + base_url = 'https://management.azure.com' + self._config = MicrosoftPostgreSQLHyperscaleConfiguration(credential, 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.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 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/aio/__init__.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/aio/__init__.py new file mode 100644 index 000000000000..e7b00ed4c213 --- /dev/null +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/aio/__init__.py @@ -0,0 +1,10 @@ +# 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'] 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..1e35766b9db5 --- /dev/null +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/aio/_configuration.py @@ -0,0 +1,66 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +VERSION = "unknown" + +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: + 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.") + super(MicrosoftPostgreSQLHyperscaleConfiguration, self).__init__(**kwargs) + + 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 = policies.AsyncBearerTokenCredentialPolicy(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..1673b7a46627 --- /dev/null +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/aio/_microsoft_postgre_sql_hyperscale.py @@ -0,0 +1,88 @@ +# 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, Optional, TYPE_CHECKING + +from azure.mgmt.core import AsyncARMPipelineClient +from msrest import Deserializer, Serializer + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential + +from ._configuration import MicrosoftPostgreSQLHyperscaleConfiguration +from .operations import ServerGroupsOperations +from .operations import ServersOperations +from .operations import ConfigurationsOperations +from .operations import FirewallRulesOperations +from .operations import RolesOperations +from .operations import Operations +from .. import models + + +class MicrosoftPostgreSQLHyperscale(object): + """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 str base_url: Service URL + :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: Optional[str] = None, + **kwargs: Any + ) -> None: + if not base_url: + base_url = 'https://management.azure.com' + self._config = MicrosoftPostgreSQLHyperscaleConfiguration(credential, 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.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) + + 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/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..27fd5b2de0c4 --- /dev/null +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/aio/operations/_configurations_operations.py @@ -0,0 +1,391 @@ +# 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, 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, HttpRequest +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models + +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 + + def list_by_server( + self, + resource_group_name: str, + server_group_name: str, + server_name: str, + **kwargs + ) -> 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', {})) + api_version = "2020-10-05-privatepreview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_server.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'serverGroupName': self._serialize.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + 'serverName': self._serialize.url("server_name", server_name, 'str', max_length=90, min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + 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 + + def list_by_server_group( + self, + resource_group_name: str, + server_group_name: str, + **kwargs + ) -> 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', {})) + api_version = "2020-10-05-privatepreview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_server_group.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'serverGroupName': self._serialize.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + 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 + ) -> 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', {})) + api_version = "2020-10-05-privatepreview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._update_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'serverGroupName': self._serialize.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + 'configurationName': self._serialize.url("configuration_name", configuration_name, 'str', max_length=90, min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'ServerGroupConfiguration') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + 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 + + async def begin_update( + self, + resource_group_name: str, + server_group_name: str, + configuration_name: str, + parameters: "_models.ServerGroupConfiguration", + **kwargs + ) -> 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: True for ARMPolling, False for no polling, or a + polling object for 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: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, 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, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ServerGroupConfiguration', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'serverGroupName': self._serialize.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + 'configurationName': self._serialize.url("configuration_name", configuration_name, 'str', max_length=90, min_length=1), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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 + + async def get( + self, + resource_group_name: str, + server_group_name: str, + configuration_name: str, + **kwargs + ) -> "_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', {})) + api_version = "2020-10-05-privatepreview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'serverGroupName': self._serialize.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + 'configurationName': self._serialize.url("configuration_name", configuration_name, 'str', max_length=90, min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + 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..39f7986e945a --- /dev/null +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/aio/operations/_firewall_rules_operations.py @@ -0,0 +1,431 @@ +# 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, 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, HttpRequest +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models + +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 + ) -> 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', {})) + api_version = "2020-10-05-privatepreview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._create_or_update_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'serverGroupName': self._serialize.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + 'firewallRuleName': self._serialize.url("firewall_rule_name", firewall_rule_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'FirewallRule') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + 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 + + async def begin_create_or_update( + self, + resource_group_name: str, + server_group_name: str, + firewall_rule_name: str, + parameters: "_models.FirewallRule", + **kwargs + ) -> 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: True for ARMPolling, False for no polling, or a + polling object for 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: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, 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, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('FirewallRule', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'serverGroupName': self._serialize.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + 'firewallRuleName': self._serialize.url("firewall_rule_name", firewall_rule_name, 'str'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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 + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-05-privatepreview" + accept = "application/json" + + # Construct URL + url = self._delete_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'serverGroupName': self._serialize.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + 'firewallRuleName': self._serialize.url("firewall_rule_name", firewall_rule_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + 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 + + async def begin_delete( + self, + resource_group_name: str, + server_group_name: str, + firewall_rule_name: str, + **kwargs + ) -> 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: True for ARMPolling, False for no polling, or a + polling object for 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, 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) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'serverGroupName': self._serialize.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + 'firewallRuleName': self._serialize.url("firewall_rule_name", firewall_rule_name, 'str'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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 + + async def get( + self, + resource_group_name: str, + server_group_name: str, + firewall_rule_name: str, + **kwargs + ) -> "_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', {})) + api_version = "2020-10-05-privatepreview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'serverGroupName': self._serialize.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + 'firewallRuleName': self._serialize.url("firewall_rule_name", firewall_rule_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + 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 + + def list_by_server_group( + self, + resource_group_name: str, + server_group_name: str, + **kwargs + ) -> 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', {})) + api_version = "2020-10-05-privatepreview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_server_group.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'serverGroupName': self._serialize.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + 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..f7af38882315 --- /dev/null +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/aio/operations/_operations.py @@ -0,0 +1,104 @@ +# 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, 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, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models + +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 + + def list( + self, + **kwargs + ) -> 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', {})) + api_version = "2020-10-05-privatepreview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + 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..fe9c6197bfcc --- /dev/null +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/aio/operations/_roles_operations.py @@ -0,0 +1,369 @@ +# 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, 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, HttpRequest +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models + +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 + ) -> 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', {})) + api_version = "2020-10-05-privatepreview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._create_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'serverGroupName': self._serialize.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + 'roleName': self._serialize.url("role_name", role_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'Role') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + 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 + + async def begin_create( + self, + resource_group_name: str, + server_group_name: str, + role_name: str, + parameters: "_models.Role", + **kwargs + ) -> 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: True for ARMPolling, False for no polling, or a + polling object for 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: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, 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, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Role', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'serverGroupName': self._serialize.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + 'roleName': self._serialize.url("role_name", role_name, 'str'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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 + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-05-privatepreview" + accept = "application/json" + + # Construct URL + url = self._delete_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'serverGroupName': self._serialize.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + 'roleName': self._serialize.url("role_name", role_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + 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 + + async def begin_delete( + self, + resource_group_name: str, + server_group_name: str, + role_name: str, + **kwargs + ) -> 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: True for ARMPolling, False for no polling, or a + polling object for 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, 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) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'serverGroupName': self._serialize.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + 'roleName': self._serialize.url("role_name", role_name, 'str'), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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 + + def list_by_server_group( + self, + resource_group_name: str, + server_group_name: str, + **kwargs + ) -> 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', {})) + api_version = "2020-10-05-privatepreview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_server_group.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'serverGroupName': self._serialize.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + 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..e805ed4b50cd --- /dev/null +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/aio/operations/_server_groups_operations.py @@ -0,0 +1,985 @@ +# 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, 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, HttpRequest +from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling + +from ... import models as _models + +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 + + def list( + self, + **kwargs + ) -> 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', {})) + api_version = "2020-10-05-privatepreview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + 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 + + def list_by_resource_group( + self, + resource_group_name: str, + **kwargs + ) -> 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', {})) + api_version = "2020-10-05-privatepreview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_resource_group.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + 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 + ) -> 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', {})) + api_version = "2020-10-05-privatepreview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._create_or_update_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'serverGroupName': self._serialize.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'ServerGroup') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + 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 + + async def begin_create_or_update( + self, + resource_group_name: str, + server_group_name: str, + parameters: "_models.ServerGroup", + **kwargs + ) -> 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: True for ARMPolling, False for no polling, or a + polling object for 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: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, 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, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ServerGroup', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'serverGroupName': self._serialize.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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 + + async def get( + self, + resource_group_name: str, + server_group_name: str, + **kwargs + ) -> "_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', {})) + api_version = "2020-10-05-privatepreview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'serverGroupName': self._serialize.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + 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 + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-05-privatepreview" + accept = "application/json" + + # Construct URL + url = self._delete_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'serverGroupName': self._serialize.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + 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 + + async def begin_delete( + self, + resource_group_name: str, + server_group_name: str, + **kwargs + ) -> 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: True for ARMPolling, False for no polling, or a + polling object for 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, 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) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'serverGroupName': self._serialize.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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 + ) -> 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', {})) + api_version = "2020-10-05-privatepreview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._update_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'serverGroupName': self._serialize.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'ServerGroupForUpdate') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + 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 + + async def begin_update( + self, + resource_group_name: str, + server_group_name: str, + parameters: "_models.ServerGroupForUpdate", + **kwargs + ) -> 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: True for ARMPolling, False for no polling, or a + polling object for 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: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, 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, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ServerGroup', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'serverGroupName': self._serialize.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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 + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-05-privatepreview" + accept = "application/json" + + # Construct URL + url = self._restart_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'serverGroupName': self._serialize.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(url, query_parameters, header_parameters) + 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 + + async def begin_restart( + self, + resource_group_name: str, + server_group_name: str, + **kwargs + ) -> 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: True for ARMPolling, False for no polling, or a + polling object for 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, 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) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'serverGroupName': self._serialize.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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 + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-05-privatepreview" + accept = "application/json" + + # Construct URL + url = self._start_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'serverGroupName': self._serialize.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(url, query_parameters, header_parameters) + 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 + + async def begin_start( + self, + resource_group_name: str, + server_group_name: str, + **kwargs + ) -> 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: True for ARMPolling, False for no polling, or a + polling object for 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, 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) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'serverGroupName': self._serialize.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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 + ) -> None: + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-05-privatepreview" + accept = "application/json" + + # Construct URL + url = self._stop_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'serverGroupName': self._serialize.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(url, query_parameters, header_parameters) + 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 + + async def begin_stop( + self, + resource_group_name: str, + server_group_name: str, + **kwargs + ) -> 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: True for ARMPolling, False for no polling, or a + polling object for 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, 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) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'serverGroupName': self._serialize.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + } + + if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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 + + async def check_name_availability( + self, + name_availability_request: "_models.NameAvailabilityRequest", + **kwargs + ) -> "_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', {})) + api_version = "2020-10-05-privatepreview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.check_name_availability.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(name_availability_request, 'NameAvailabilityRequest') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + 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..ecfbb31c0e40 --- /dev/null +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/aio/operations/_servers_operations.py @@ -0,0 +1,178 @@ +# 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, 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, HttpRequest +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models + +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 + + def list_by_server_group( + self, + resource_group_name: str, + server_group_name: str, + **kwargs + ) -> 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', {})) + api_version = "2020-10-05-privatepreview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_server_group.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'serverGroupName': self._serialize.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + 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 + + async def get( + self, + resource_group_name: str, + server_group_name: str, + server_name: str, + **kwargs + ) -> "_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', {})) + api_version = "2020-10-05-privatepreview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'serverGroupName': self._serialize.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + 'serverName': self._serialize.url("server_name", server_name, 'str', max_length=90, min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + 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..7446c68d7c36 --- /dev/null +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/models/__init__.py @@ -0,0 +1,128 @@ +# 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. +# -------------------------------------------------------------------------- + +try: + 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 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 +except (SyntaxError, ImportError): + from ._models import CloudErrorBody # type: ignore + from ._models import FirewallRule # type: ignore + from ._models import FirewallRuleListResult # type: ignore + from ._models import MaintenanceWindow # type: ignore + from ._models import NameAvailability # type: ignore + from ._models import NameAvailabilityRequest # type: ignore + from ._models import Operation # type: ignore + from ._models import OperationDisplay # type: ignore + from ._models import OperationListResult # type: ignore + from ._models import ProxyResource # type: ignore + from ._models import Resource # type: ignore + from ._models import Role # type: ignore + from ._models import RoleListResult # type: ignore + from ._models import ServerConfiguration # type: ignore + from ._models import ServerConfigurationListResult # type: ignore + from ._models import ServerGroup # type: ignore + from ._models import ServerGroupConfiguration # type: ignore + from ._models import ServerGroupConfigurationListResult # type: ignore + from ._models import ServerGroupForUpdate # type: ignore + from ._models import ServerGroupListResult # type: ignore + from ._models import ServerGroupPropertiesDelegatedSubnetArguments # type: ignore + from ._models import ServerGroupServer # type: ignore + from ._models import ServerGroupServerListResult # type: ignore + from ._models import ServerGroupServerProperties # type: ignore + from ._models import ServerNameItem # type: ignore + from ._models import ServerProperties # type: ignore + from ._models import ServerRoleGroup # type: ignore + from ._models import ServerRoleGroupConfiguration # type: ignore + from ._models import SystemData # type: ignore + from ._models import TrackedResource # type: ignore + +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', + '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..e5730047307b --- /dev/null +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/models/_microsoft_postgre_sql_hyperscale_enums.py @@ -0,0 +1,125 @@ +# 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, EnumMeta +from six import with_metaclass + +class _CaseInsensitiveEnumMeta(EnumMeta): + def __getitem__(self, name): + return super().__getitem__(name.upper()) + + def __getattr__(cls, name): + """Return the enum member matching `name` + We use __getattr__ instead of descriptors or inserting into the enum + class' __dict__ in order to support `name` and `value` being both + properties for enum members (which live in the class' __dict__) and + enum members themselves. + """ + try: + return cls._member_map_[name.upper()] + except KeyError: + raise AttributeError(name) + + +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" + +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.py b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/models/_models.py new file mode 100644 index 000000000000..b545a9f437c5 --- /dev/null +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/models/_models.py @@ -0,0 +1,1377 @@ +# 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 msrest.serialization + + +class CloudErrorBody(msrest.serialization.Model): + """An error response from the Batch service. + + :param code: An identifier for the error. Codes are invariant and are intended to be consumed + programmatically. + :type code: str + :param message: A message describing the error, intended to be suitable for display in a user + interface. + :type message: str + :param target: The target of the particular error. For example, the name of the property in + error. + :type target: str + :param details: A list of additional details about the error. + :type 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, + **kwargs + ): + super(CloudErrorBody, self).__init__(**kwargs) + self.code = kwargs.get('code', None) + self.message = kwargs.get('message', None) + self.target = kwargs.get('target', None) + self.details = kwargs.get('details', None) + + +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 FirewallRule(Resource): + """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 + :param start_ip_address: Required. The start IP address of the server group firewall rule. Must + be IPv4 format. + :type start_ip_address: str + :param end_ip_address: Required. The end IP address of the server group firewall rule. Must be + IPv4 format. + :type 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, + **kwargs + ): + super(FirewallRule, self).__init__(**kwargs) + self.system_data = None + self.start_ip_address = kwargs['start_ip_address'] + self.end_ip_address = kwargs['end_ip_address'] + + +class FirewallRuleListResult(msrest.serialization.Model): + """A list of firewall rules. + + :param value: The list of firewall rules in a server group. + :type value: list[~azure.mgmt.rdbms.postgresqlhsc.models.FirewallRule] + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[FirewallRule]'}, + } + + def __init__( + self, + **kwargs + ): + super(FirewallRuleListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + + +class MaintenanceWindow(msrest.serialization.Model): + """Maintenance window of a server group. + + :param custom_window: indicates whether custom window is enabled or disabled. + :type custom_window: str + :param start_hour: start hour for maintenance window. + :type start_hour: int + :param start_minute: start minute for maintenance window. + :type start_minute: int + :param day_of_week: day of week for maintenance window. + :type 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, + **kwargs + ): + super(MaintenanceWindow, self).__init__(**kwargs) + self.custom_window = kwargs.get('custom_window', None) + self.start_hour = kwargs.get('start_hour', None) + self.start_minute = kwargs.get('start_minute', None) + self.day_of_week = kwargs.get('day_of_week', None) + + +class NameAvailability(msrest.serialization.Model): + """Represents a resource name availability. + + :param message: Error Message. + :type message: str + :param name_available: Indicates whether the resource name is available. + :type name_available: bool + :param name: name of the PostgreSQL server. + :type name: str + :param type: type of the server. + :type 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, + **kwargs + ): + super(NameAvailability, self).__init__(**kwargs) + self.message = kwargs.get('message', None) + self.name_available = kwargs.get('name_available', None) + self.name = kwargs.get('name', None) + self.type = kwargs.get('type', None) + + +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. + + :param name: Required. Resource name to verify. + :type name: str + :ivar type: Required. Resource type used for verification. Default 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, + **kwargs + ): + super(NameAvailabilityRequest, self).__init__(**kwargs) + self.name = kwargs['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 + :param is_data_action: Indicates whether the operation is a data action. + :type 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, object] + """ + + _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, + **kwargs + ): + super(Operation, self).__init__(**kwargs) + self.name = None + self.display = None + self.is_data_action = kwargs.get('is_data_action', None) + 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. + + :param value: Collection of available operation details. + :type 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, + **kwargs + ): + super(OperationListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = 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 Role(Resource): + """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 + :param password: The password of the server group role. + :type 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, + **kwargs + ): + super(Role, self).__init__(**kwargs) + self.system_data = None + self.password = kwargs.get('password', None) + + +class RoleListResult(msrest.serialization.Model): + """A list of roles. + + :param value: The list of roles in a server group. + :type value: list[~azure.mgmt.rdbms.postgresqlhsc.models.Role] + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Role]'}, + } + + def __init__( + self, + **kwargs + ): + super(RoleListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + + +class ServerConfiguration(Resource): + """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 + :param value: Value of the configuration. + :type 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, + **kwargs + ): + super(ServerConfiguration, self).__init__(**kwargs) + self.system_data = None + self.value = kwargs.get('value', None) + 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. + + :param value: The list of server configurations. + :type 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, + **kwargs + ): + super(ServerConfigurationListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + 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 + :param tags: A set of tags. Resource tags. + :type tags: dict[str, str] + :param location: Required. The geo-location where the resource lives. + :type 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, + **kwargs + ): + super(TrackedResource, self).__init__(**kwargs) + self.tags = kwargs.get('tags', None) + self.location = kwargs['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 + :param tags: A set of tags. Resource tags. + :type tags: dict[str, str] + :param location: Required. The geo-location where the resource lives. + :type location: str + :ivar system_data: The system metadata relating to this resource. + :vartype system_data: ~azure.mgmt.rdbms.postgresqlhsc.models.SystemData + :param create_mode: The mode to create a new server group. Possible values include: "Default", + "PointInTimeRestore". + :type create_mode: str or ~azure.mgmt.rdbms.postgresqlhsc.models.CreateMode + :param 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). + :type administrator_login: str + :param administrator_login_password: The password of the administrator login. + :type administrator_login_password: str + :param backup_retention_days: The backup retention days for server group. + :type backup_retention_days: int + :param postgresql_version: The PostgreSQL version of server group. Possible values include: + "11", "12". + :type postgresql_version: str or ~azure.mgmt.rdbms.postgresqlhsc.models.PostgreSQLVersion + :param 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". + :type citus_version: str or ~azure.mgmt.rdbms.postgresqlhsc.models.CitusVersion + :param enable_mx: If Citus MX is enabled or not for the server group. + :type enable_mx: bool + :param enable_zfs: If ZFS compression is enabled or not for the server group. + :type enable_zfs: bool + :param enable_shards_on_coordinator: If shards on coordinator is enabled or not for the server + group. + :type 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 + :param server_role_groups: The list of server role groups. + :type server_role_groups: list[~azure.mgmt.rdbms.postgresqlhsc.models.ServerRoleGroup] + :param maintenance_window: Maintenance window of a server group. + :type maintenance_window: ~azure.mgmt.rdbms.postgresqlhsc.models.MaintenanceWindow + :param availability_zone: Availability Zone information of the server group. + :type availability_zone: str + :param standby_availability_zone: Standby Availability Zone information of the server group. + :type standby_availability_zone: str + :param delegated_subnet_arguments: The delegated subnet arguments for a server group. + :type delegated_subnet_arguments: + ~azure.mgmt.rdbms.postgresqlhsc.models.ServerGroupPropertiesDelegatedSubnetArguments + :param source_subscription_id: The source subscription id to restore from. It's required when + 'createMode' is 'PointInTimeRestore'. + :type source_subscription_id: str + :param source_resource_group_name: The source resource group name to restore from. It's + required when 'createMode' is 'PointInTimeRestore'. + :type source_resource_group_name: str + :param source_server_group_name: The source server group name to restore from. It's required + when 'createMode' is 'PointInTimeRestore'. + :type source_server_group_name: str + :param source_location: The source server group location to restore from. It's required when + 'createMode' is 'PointInTimeRestore'. + :type source_location: str + :param point_in_time_utc: Restore point creation time (ISO8601 format), specifying the time to + restore from. It's required when 'createMode' is 'PointInTimeRestore'. + :type 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}, + } + + _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'}, + '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, + **kwargs + ): + super(ServerGroup, self).__init__(**kwargs) + self.system_data = None + self.create_mode = kwargs.get('create_mode', None) + self.administrator_login = kwargs.get('administrator_login', None) + self.administrator_login_password = kwargs.get('administrator_login_password', None) + self.backup_retention_days = kwargs.get('backup_retention_days', None) + self.postgresql_version = kwargs.get('postgresql_version', None) + self.citus_version = kwargs.get('citus_version', None) + self.enable_mx = kwargs.get('enable_mx', None) + self.enable_zfs = kwargs.get('enable_zfs', None) + self.enable_shards_on_coordinator = kwargs.get('enable_shards_on_coordinator', None) + self.state = None + self.earliest_restore_time = None + self.resource_provider_type = None + self.server_role_groups = kwargs.get('server_role_groups', None) + self.maintenance_window = kwargs.get('maintenance_window', None) + self.availability_zone = kwargs.get('availability_zone', None) + self.standby_availability_zone = kwargs.get('standby_availability_zone', None) + self.delegated_subnet_arguments = kwargs.get('delegated_subnet_arguments', None) + self.source_subscription_id = kwargs.get('source_subscription_id', None) + self.source_resource_group_name = kwargs.get('source_resource_group_name', None) + self.source_server_group_name = kwargs.get('source_server_group_name', None) + self.source_location = kwargs.get('source_location', None) + self.point_in_time_utc = kwargs.get('point_in_time_utc', None) + + +class ServerGroupConfiguration(Resource): + """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 + :param server_role_group_configurations: The list of server role group configuration values. + :type 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, + **kwargs + ): + 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 = kwargs.get('server_role_group_configurations', None) + + +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. + + :param value: The list of server group configurations. + :type 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, + **kwargs + ): + super(ServerGroupConfigurationListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +class ServerGroupForUpdate(msrest.serialization.Model): + """Represents a server group for update. + + :param location: The location the resource resides in. + :type location: str + :param tags: A set of tags. Application-specific metadata in the form of key-value pairs. + :type tags: dict[str, str] + :param administrator_login_password: The password of the administrator login. + :type administrator_login_password: str + :param backup_retention_days: The backup retention days for server group. + :type backup_retention_days: int + :param postgresql_version: The PostgreSQL version of server group. Possible values include: + "11", "12". + :type postgresql_version: str or ~azure.mgmt.rdbms.postgresqlhsc.models.PostgreSQLVersion + :param 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". + :type citus_version: str or ~azure.mgmt.rdbms.postgresqlhsc.models.CitusVersion + :param enable_shards_on_coordinator: If shards on coordinator is enabled or not for the server + group. + :type enable_shards_on_coordinator: bool + :param server_role_groups: The list of server role groups. + :type server_role_groups: list[~azure.mgmt.rdbms.postgresqlhsc.models.ServerRoleGroup] + :param maintenance_window: Maintenance window of a server group. + :type maintenance_window: ~azure.mgmt.rdbms.postgresqlhsc.models.MaintenanceWindow + :param availability_zone: Availability Zone information of the server group. + :type availability_zone: str + :param standby_availability_zone: Standby Availability Zone information of the server group. + :type 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, + **kwargs + ): + super(ServerGroupForUpdate, self).__init__(**kwargs) + self.location = kwargs.get('location', None) + self.tags = kwargs.get('tags', None) + self.administrator_login_password = kwargs.get('administrator_login_password', None) + self.backup_retention_days = kwargs.get('backup_retention_days', None) + self.postgresql_version = kwargs.get('postgresql_version', None) + self.citus_version = kwargs.get('citus_version', None) + self.enable_shards_on_coordinator = kwargs.get('enable_shards_on_coordinator', None) + self.server_role_groups = kwargs.get('server_role_groups', None) + self.maintenance_window = kwargs.get('maintenance_window', None) + self.availability_zone = kwargs.get('availability_zone', None) + self.standby_availability_zone = kwargs.get('standby_availability_zone', None) + + +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. + + :param value: The list of server groups. + :type 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, + **kwargs + ): + super(ServerGroupListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + self.next_link = None + + +class ServerGroupPropertiesDelegatedSubnetArguments(msrest.serialization.Model): + """The delegated subnet arguments for a server group. + + :param subnet_arm_resource_id: delegated subnet arm resource id. + :type subnet_arm_resource_id: str + """ + + _attribute_map = { + 'subnet_arm_resource_id': {'key': 'subnetArmResourceId', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + super(ServerGroupPropertiesDelegatedSubnetArguments, self).__init__(**kwargs) + self.subnet_arm_resource_id = kwargs.get('subnet_arm_resource_id', None) + + +class ServerGroupServer(Resource): + """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 + :param server_edition: The edition of a server (default: GeneralPurpose). Possible values + include: "GeneralPurpose", "MemoryOptimized". + :type server_edition: str or ~azure.mgmt.rdbms.postgresqlhsc.models.ServerEdition + :param storage_quota_in_mb: The storage of a server in MB (max: 2097152 = 2TiB). + :type storage_quota_in_mb: long + :param v_cores: The vCores count of a server (max: 64). + :type v_cores: long + :param enable_ha: If high availability is enabled or not for the server. + :type 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 + :param role: The role of server in the server group. Possible values include: "Coordinator", + "Worker". + :type 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 + :param administrator_login: The administrator's login name of a servers in server group. + :type administrator_login: str + :param postgresql_version: The PostgreSQL version of server. Possible values include: "11", + "12". + :type postgresql_version: str or ~azure.mgmt.rdbms.postgresqlhsc.models.PostgreSQLVersion + :param citus_version: The Citus version of server. Possible values include: "8.3", "9.0", + "9.1", "9.2", "9.3", "9.4", "9.5". + :type citus_version: str or ~azure.mgmt.rdbms.postgresqlhsc.models.CitusVersion + :param availability_zone: Availability Zone information of the server group. + :type availability_zone: str + :param standby_availability_zone: Standby Availability Zone information of the server group. + :type 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, + **kwargs + ): + super(ServerGroupServer, self).__init__(**kwargs) + self.system_data = None + self.server_edition = kwargs.get('server_edition', None) + self.storage_quota_in_mb = kwargs.get('storage_quota_in_mb', None) + self.v_cores = kwargs.get('v_cores', None) + self.enable_ha = kwargs.get('enable_ha', None) + self.enable_public_ip = None + self.fully_qualified_domain_name = None + self.role = kwargs.get('role', None) + self.state = None + self.ha_state = None + self.administrator_login = kwargs.get('administrator_login', None) + self.postgresql_version = kwargs.get('postgresql_version', None) + self.citus_version = kwargs.get('citus_version', None) + self.availability_zone = kwargs.get('availability_zone', None) + self.standby_availability_zone = kwargs.get('standby_availability_zone', None) + + +class ServerGroupServerListResult(msrest.serialization.Model): + """A list of servers in a server group. + + :param value: The list of servers in a server group. + :type value: list[~azure.mgmt.rdbms.postgresqlhsc.models.ServerGroupServer] + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ServerGroupServer]'}, + } + + def __init__( + self, + **kwargs + ): + super(ServerGroupServerListResult, self).__init__(**kwargs) + self.value = kwargs.get('value', None) + + +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. + + :param server_edition: The edition of a server (default: GeneralPurpose). Possible values + include: "GeneralPurpose", "MemoryOptimized". + :type server_edition: str or ~azure.mgmt.rdbms.postgresqlhsc.models.ServerEdition + :param storage_quota_in_mb: The storage of a server in MB (max: 2097152 = 2TiB). + :type storage_quota_in_mb: long + :param v_cores: The vCores count of a server (max: 64). + :type v_cores: long + :param enable_ha: If high availability is enabled or not for the server. + :type 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, + **kwargs + ): + super(ServerProperties, self).__init__(**kwargs) + self.server_edition = kwargs.get('server_edition', None) + self.storage_quota_in_mb = kwargs.get('storage_quota_in_mb', None) + self.v_cores = kwargs.get('v_cores', None) + self.enable_ha = kwargs.get('enable_ha', None) + 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. + + :param server_edition: The edition of a server (default: GeneralPurpose). Possible values + include: "GeneralPurpose", "MemoryOptimized". + :type server_edition: str or ~azure.mgmt.rdbms.postgresqlhsc.models.ServerEdition + :param storage_quota_in_mb: The storage of a server in MB (max: 2097152 = 2TiB). + :type storage_quota_in_mb: long + :param v_cores: The vCores count of a server (max: 64). + :type v_cores: long + :param enable_ha: If high availability is enabled or not for the server. + :type 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 + :param role: The role of server in the server group. Possible values include: "Coordinator", + "Worker". + :type 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 + :param administrator_login: The administrator's login name of a servers in server group. + :type administrator_login: str + :param postgresql_version: The PostgreSQL version of server. Possible values include: "11", + "12". + :type postgresql_version: str or ~azure.mgmt.rdbms.postgresqlhsc.models.PostgreSQLVersion + :param citus_version: The Citus version of server. Possible values include: "8.3", "9.0", + "9.1", "9.2", "9.3", "9.4", "9.5". + :type citus_version: str or ~azure.mgmt.rdbms.postgresqlhsc.models.CitusVersion + :param availability_zone: Availability Zone information of the server group. + :type availability_zone: str + :param standby_availability_zone: Standby Availability Zone information of the server group. + :type 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, + **kwargs + ): + super(ServerGroupServerProperties, self).__init__(**kwargs) + self.fully_qualified_domain_name = None + self.role = kwargs.get('role', None) + self.state = None + self.ha_state = None + self.administrator_login = kwargs.get('administrator_login', None) + self.postgresql_version = kwargs.get('postgresql_version', None) + self.citus_version = kwargs.get('citus_version', None) + self.availability_zone = kwargs.get('availability_zone', None) + self.standby_availability_zone = kwargs.get('standby_availability_zone', None) + + +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. + + :param name: The name of a server. + :type 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, + **kwargs + ): + super(ServerNameItem, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + 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. + + :param server_edition: The edition of a server (default: GeneralPurpose). Possible values + include: "GeneralPurpose", "MemoryOptimized". + :type server_edition: str or ~azure.mgmt.rdbms.postgresqlhsc.models.ServerEdition + :param storage_quota_in_mb: The storage of a server in MB (max: 2097152 = 2TiB). + :type storage_quota_in_mb: long + :param v_cores: The vCores count of a server (max: 64). + :type v_cores: long + :param enable_ha: If high availability is enabled or not for the server. + :type enable_ha: bool + :ivar enable_public_ip: If public IP is requested or not for a server. + :vartype enable_public_ip: bool + :param name: The name of the server role group. + :type name: str + :param role: The role of servers in the server role group. Possible values include: + "Coordinator", "Worker". + :type role: str or ~azure.mgmt.rdbms.postgresqlhsc.models.ServerRole + :param server_count: The number of servers in the server role group. + :type 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, + **kwargs + ): + super(ServerRoleGroup, self).__init__(**kwargs) + self.name = kwargs.get('name', None) + self.role = kwargs.get('role', None) + self.server_count = kwargs.get('server_count', None) + 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. + + :param role: Required. The role of servers in the server role group. Possible values include: + "Coordinator", "Worker". + :type role: str or ~azure.mgmt.rdbms.postgresqlhsc.models.ServerRole + :param value: Required. Value of the configuration. + :type 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, + **kwargs + ): + super(ServerRoleGroupConfiguration, self).__init__(**kwargs) + self.role = kwargs['role'] + self.value = kwargs['value'] + self.default_value = None + self.source = None + + +class SystemData(msrest.serialization.Model): + """Metadata pertaining to creation and last modification of the resource. + + :param created_by: The identity that created the resource. + :type created_by: str + :param created_by_type: The type of identity that created the resource. Possible values + include: "User", "Application", "ManagedIdentity", "Key". + :type created_by_type: str or ~azure.mgmt.rdbms.postgresqlhsc.models.CreatedByType + :param created_at: The timestamp of resource creation (UTC). + :type created_at: ~datetime.datetime + :param last_modified_by: The identity that last modified the resource. + :type last_modified_by: str + :param last_modified_by_type: The type of identity that last modified the resource. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :type last_modified_by_type: str or ~azure.mgmt.rdbms.postgresqlhsc.models.CreatedByType + :param last_modified_at: The type of identity that last modified the resource. + :type 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, + **kwargs + ): + super(SystemData, self).__init__(**kwargs) + self.created_by = kwargs.get('created_by', None) + self.created_by_type = kwargs.get('created_by_type', None) + self.created_at = kwargs.get('created_at', None) + self.last_modified_by = kwargs.get('last_modified_by', None) + self.last_modified_by_type = kwargs.get('last_modified_by_type', None) + self.last_modified_at = kwargs.get('last_modified_at', None) 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..a3dddfe8feff --- /dev/null +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/models/_models_py3.py @@ -0,0 +1,1510 @@ +# 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. + + :param code: An identifier for the error. Codes are invariant and are intended to be consumed + programmatically. + :type code: str + :param message: A message describing the error, intended to be suitable for display in a user + interface. + :type message: str + :param target: The target of the particular error. For example, the name of the property in + error. + :type target: str + :param details: A list of additional details about the error. + :type 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 + ): + 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 FirewallRule(Resource): + """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 + :param start_ip_address: Required. The start IP address of the server group firewall rule. Must + be IPv4 format. + :type start_ip_address: str + :param end_ip_address: Required. The end IP address of the server group firewall rule. Must be + IPv4 format. + :type 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 + ): + 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. + + :param value: The list of firewall rules in a server group. + :type value: list[~azure.mgmt.rdbms.postgresqlhsc.models.FirewallRule] + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[FirewallRule]'}, + } + + def __init__( + self, + *, + value: Optional[List["FirewallRule"]] = None, + **kwargs + ): + super(FirewallRuleListResult, self).__init__(**kwargs) + self.value = value + + +class MaintenanceWindow(msrest.serialization.Model): + """Maintenance window of a server group. + + :param custom_window: indicates whether custom window is enabled or disabled. + :type custom_window: str + :param start_hour: start hour for maintenance window. + :type start_hour: int + :param start_minute: start minute for maintenance window. + :type start_minute: int + :param day_of_week: day of week for maintenance window. + :type 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 + ): + 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. + + :param message: Error Message. + :type message: str + :param name_available: Indicates whether the resource name is available. + :type name_available: bool + :param name: name of the PostgreSQL server. + :type name: str + :param type: type of the server. + :type 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 + ): + 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. + + :param name: Required. Resource name to verify. + :type name: str + :ivar type: Required. Resource type used for verification. Default 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 + ): + 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 + :param is_data_action: Indicates whether the operation is a data action. + :type 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, object] + """ + + _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 + ): + 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. + + :param value: Collection of available operation details. + :type 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 + ): + super(OperationListResult, self).__init__(**kwargs) + self.value = value + self.next_link = 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 Role(Resource): + """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 + :param password: The password of the server group role. + :type 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 + ): + super(Role, self).__init__(**kwargs) + self.system_data = None + self.password = password + + +class RoleListResult(msrest.serialization.Model): + """A list of roles. + + :param value: The list of roles in a server group. + :type value: list[~azure.mgmt.rdbms.postgresqlhsc.models.Role] + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[Role]'}, + } + + def __init__( + self, + *, + value: Optional[List["Role"]] = None, + **kwargs + ): + super(RoleListResult, self).__init__(**kwargs) + self.value = value + + +class ServerConfiguration(Resource): + """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 + :param value: Value of the configuration. + :type 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 + ): + 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. + + :param value: The list of server configurations. + :type 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 + ): + 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 + :param tags: A set of tags. Resource tags. + :type tags: dict[str, str] + :param location: Required. The geo-location where the resource lives. + :type 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 + ): + 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 + :param tags: A set of tags. Resource tags. + :type tags: dict[str, str] + :param location: Required. The geo-location where the resource lives. + :type location: str + :ivar system_data: The system metadata relating to this resource. + :vartype system_data: ~azure.mgmt.rdbms.postgresqlhsc.models.SystemData + :param create_mode: The mode to create a new server group. Possible values include: "Default", + "PointInTimeRestore". + :type create_mode: str or ~azure.mgmt.rdbms.postgresqlhsc.models.CreateMode + :param 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). + :type administrator_login: str + :param administrator_login_password: The password of the administrator login. + :type administrator_login_password: str + :param backup_retention_days: The backup retention days for server group. + :type backup_retention_days: int + :param postgresql_version: The PostgreSQL version of server group. Possible values include: + "11", "12". + :type postgresql_version: str or ~azure.mgmt.rdbms.postgresqlhsc.models.PostgreSQLVersion + :param 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". + :type citus_version: str or ~azure.mgmt.rdbms.postgresqlhsc.models.CitusVersion + :param enable_mx: If Citus MX is enabled or not for the server group. + :type enable_mx: bool + :param enable_zfs: If ZFS compression is enabled or not for the server group. + :type enable_zfs: bool + :param enable_shards_on_coordinator: If shards on coordinator is enabled or not for the server + group. + :type 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 + :param server_role_groups: The list of server role groups. + :type server_role_groups: list[~azure.mgmt.rdbms.postgresqlhsc.models.ServerRoleGroup] + :param maintenance_window: Maintenance window of a server group. + :type maintenance_window: ~azure.mgmt.rdbms.postgresqlhsc.models.MaintenanceWindow + :param availability_zone: Availability Zone information of the server group. + :type availability_zone: str + :param standby_availability_zone: Standby Availability Zone information of the server group. + :type standby_availability_zone: str + :param delegated_subnet_arguments: The delegated subnet arguments for a server group. + :type delegated_subnet_arguments: + ~azure.mgmt.rdbms.postgresqlhsc.models.ServerGroupPropertiesDelegatedSubnetArguments + :param source_subscription_id: The source subscription id to restore from. It's required when + 'createMode' is 'PointInTimeRestore'. + :type source_subscription_id: str + :param source_resource_group_name: The source resource group name to restore from. It's + required when 'createMode' is 'PointInTimeRestore'. + :type source_resource_group_name: str + :param source_server_group_name: The source server group name to restore from. It's required + when 'createMode' is 'PointInTimeRestore'. + :type source_server_group_name: str + :param source_location: The source server group location to restore from. It's required when + 'createMode' is 'PointInTimeRestore'. + :type source_location: str + :param point_in_time_utc: Restore point creation time (ISO8601 format), specifying the time to + restore from. It's required when 'createMode' is 'PointInTimeRestore'. + :type 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}, + } + + _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'}, + '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, + 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 + ): + 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.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(Resource): + """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 + :param server_role_group_configurations: The list of server role group configuration values. + :type 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 + ): + 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. + + :param value: The list of server group configurations. + :type 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 + ): + super(ServerGroupConfigurationListResult, self).__init__(**kwargs) + self.value = value + self.next_link = None + + +class ServerGroupForUpdate(msrest.serialization.Model): + """Represents a server group for update. + + :param location: The location the resource resides in. + :type location: str + :param tags: A set of tags. Application-specific metadata in the form of key-value pairs. + :type tags: dict[str, str] + :param administrator_login_password: The password of the administrator login. + :type administrator_login_password: str + :param backup_retention_days: The backup retention days for server group. + :type backup_retention_days: int + :param postgresql_version: The PostgreSQL version of server group. Possible values include: + "11", "12". + :type postgresql_version: str or ~azure.mgmt.rdbms.postgresqlhsc.models.PostgreSQLVersion + :param 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". + :type citus_version: str or ~azure.mgmt.rdbms.postgresqlhsc.models.CitusVersion + :param enable_shards_on_coordinator: If shards on coordinator is enabled or not for the server + group. + :type enable_shards_on_coordinator: bool + :param server_role_groups: The list of server role groups. + :type server_role_groups: list[~azure.mgmt.rdbms.postgresqlhsc.models.ServerRoleGroup] + :param maintenance_window: Maintenance window of a server group. + :type maintenance_window: ~azure.mgmt.rdbms.postgresqlhsc.models.MaintenanceWindow + :param availability_zone: Availability Zone information of the server group. + :type availability_zone: str + :param standby_availability_zone: Standby Availability Zone information of the server group. + :type 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 + ): + 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. + + :param value: The list of server groups. + :type 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 + ): + 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. + + :param subnet_arm_resource_id: delegated subnet arm resource id. + :type 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 + ): + super(ServerGroupPropertiesDelegatedSubnetArguments, self).__init__(**kwargs) + self.subnet_arm_resource_id = subnet_arm_resource_id + + +class ServerGroupServer(Resource): + """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 + :param server_edition: The edition of a server (default: GeneralPurpose). Possible values + include: "GeneralPurpose", "MemoryOptimized". + :type server_edition: str or ~azure.mgmt.rdbms.postgresqlhsc.models.ServerEdition + :param storage_quota_in_mb: The storage of a server in MB (max: 2097152 = 2TiB). + :type storage_quota_in_mb: long + :param v_cores: The vCores count of a server (max: 64). + :type v_cores: long + :param enable_ha: If high availability is enabled or not for the server. + :type 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 + :param role: The role of server in the server group. Possible values include: "Coordinator", + "Worker". + :type 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 + :param administrator_login: The administrator's login name of a servers in server group. + :type administrator_login: str + :param postgresql_version: The PostgreSQL version of server. Possible values include: "11", + "12". + :type postgresql_version: str or ~azure.mgmt.rdbms.postgresqlhsc.models.PostgreSQLVersion + :param citus_version: The Citus version of server. Possible values include: "8.3", "9.0", + "9.1", "9.2", "9.3", "9.4", "9.5". + :type citus_version: str or ~azure.mgmt.rdbms.postgresqlhsc.models.CitusVersion + :param availability_zone: Availability Zone information of the server group. + :type availability_zone: str + :param standby_availability_zone: Standby Availability Zone information of the server group. + :type 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 + ): + 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. + + :param value: The list of servers in a server group. + :type value: list[~azure.mgmt.rdbms.postgresqlhsc.models.ServerGroupServer] + """ + + _attribute_map = { + 'value': {'key': 'value', 'type': '[ServerGroupServer]'}, + } + + def __init__( + self, + *, + value: Optional[List["ServerGroupServer"]] = None, + **kwargs + ): + 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. + + :param server_edition: The edition of a server (default: GeneralPurpose). Possible values + include: "GeneralPurpose", "MemoryOptimized". + :type server_edition: str or ~azure.mgmt.rdbms.postgresqlhsc.models.ServerEdition + :param storage_quota_in_mb: The storage of a server in MB (max: 2097152 = 2TiB). + :type storage_quota_in_mb: long + :param v_cores: The vCores count of a server (max: 64). + :type v_cores: long + :param enable_ha: If high availability is enabled or not for the server. + :type 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 + ): + 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. + + :param server_edition: The edition of a server (default: GeneralPurpose). Possible values + include: "GeneralPurpose", "MemoryOptimized". + :type server_edition: str or ~azure.mgmt.rdbms.postgresqlhsc.models.ServerEdition + :param storage_quota_in_mb: The storage of a server in MB (max: 2097152 = 2TiB). + :type storage_quota_in_mb: long + :param v_cores: The vCores count of a server (max: 64). + :type v_cores: long + :param enable_ha: If high availability is enabled or not for the server. + :type 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 + :param role: The role of server in the server group. Possible values include: "Coordinator", + "Worker". + :type 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 + :param administrator_login: The administrator's login name of a servers in server group. + :type administrator_login: str + :param postgresql_version: The PostgreSQL version of server. Possible values include: "11", + "12". + :type postgresql_version: str or ~azure.mgmt.rdbms.postgresqlhsc.models.PostgreSQLVersion + :param citus_version: The Citus version of server. Possible values include: "8.3", "9.0", + "9.1", "9.2", "9.3", "9.4", "9.5". + :type citus_version: str or ~azure.mgmt.rdbms.postgresqlhsc.models.CitusVersion + :param availability_zone: Availability Zone information of the server group. + :type availability_zone: str + :param standby_availability_zone: Standby Availability Zone information of the server group. + :type 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 + ): + 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. + + :param name: The name of a server. + :type 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 + ): + 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. + + :param server_edition: The edition of a server (default: GeneralPurpose). Possible values + include: "GeneralPurpose", "MemoryOptimized". + :type server_edition: str or ~azure.mgmt.rdbms.postgresqlhsc.models.ServerEdition + :param storage_quota_in_mb: The storage of a server in MB (max: 2097152 = 2TiB). + :type storage_quota_in_mb: long + :param v_cores: The vCores count of a server (max: 64). + :type v_cores: long + :param enable_ha: If high availability is enabled or not for the server. + :type enable_ha: bool + :ivar enable_public_ip: If public IP is requested or not for a server. + :vartype enable_public_ip: bool + :param name: The name of the server role group. + :type name: str + :param role: The role of servers in the server role group. Possible values include: + "Coordinator", "Worker". + :type role: str or ~azure.mgmt.rdbms.postgresqlhsc.models.ServerRole + :param server_count: The number of servers in the server role group. + :type 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 + ): + 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. + + :param role: Required. The role of servers in the server role group. Possible values include: + "Coordinator", "Worker". + :type role: str or ~azure.mgmt.rdbms.postgresqlhsc.models.ServerRole + :param value: Required. Value of the configuration. + :type 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 + ): + 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. + + :param created_by: The identity that created the resource. + :type created_by: str + :param created_by_type: The type of identity that created the resource. Possible values + include: "User", "Application", "ManagedIdentity", "Key". + :type created_by_type: str or ~azure.mgmt.rdbms.postgresqlhsc.models.CreatedByType + :param created_at: The timestamp of resource creation (UTC). + :type created_at: ~datetime.datetime + :param last_modified_by: The identity that last modified the resource. + :type last_modified_by: str + :param last_modified_by_type: The type of identity that last modified the resource. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :type last_modified_by_type: str or ~azure.mgmt.rdbms.postgresqlhsc.models.CreatedByType + :param last_modified_at: The type of identity that last modified the resource. + :type 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 + ): + 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..bad9d69210c2 --- /dev/null +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/operations/_configurations_operations.py @@ -0,0 +1,400 @@ +# 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 TYPE_CHECKING +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 HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +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 + + def list_by_server( + self, + resource_group_name, # type: str + server_group_name, # type: str + server_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> 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', {})) + api_version = "2020-10-05-privatepreview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_server.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'serverGroupName': self._serialize.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + 'serverName': self._serialize.url("server_name", server_name, 'str', max_length=90, min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + 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 + + def list_by_server_group( + self, + resource_group_name, # type: str + server_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> 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', {})) + api_version = "2020-10-05-privatepreview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_server_group.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'serverGroupName': self._serialize.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + 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, # type: str + server_group_name, # type: str + configuration_name, # type: str + parameters, # type: "_models.ServerGroupConfiguration" + **kwargs # type: Any + ): + # type: (...) -> 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', {})) + api_version = "2020-10-05-privatepreview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._update_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'serverGroupName': self._serialize.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + 'configurationName': self._serialize.url("configuration_name", configuration_name, 'str', max_length=90, min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'ServerGroupConfiguration') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + 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 + + def begin_update( + self, + resource_group_name, # type: str + server_group_name, # type: str + configuration_name, # type: str + parameters, # type: "_models.ServerGroupConfiguration" + **kwargs # type: Any + ): + # type: (...) -> 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: True for ARMPolling, False for no polling, or a + polling object for 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: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, 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, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ServerGroupConfiguration', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'serverGroupName': self._serialize.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + 'configurationName': self._serialize.url("configuration_name", configuration_name, 'str', max_length=90, min_length=1), + } + + if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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 + + def get( + self, + resource_group_name, # type: str + server_group_name, # type: str + configuration_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_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', {})) + api_version = "2020-10-05-privatepreview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'serverGroupName': self._serialize.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + 'configurationName': self._serialize.url("configuration_name", configuration_name, 'str', max_length=90, min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + 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..43c11985ce91 --- /dev/null +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/operations/_firewall_rules_operations.py @@ -0,0 +1,441 @@ +# 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 TYPE_CHECKING +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 HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +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, # type: str + server_group_name, # type: str + firewall_rule_name, # type: str + parameters, # type: "_models.FirewallRule" + **kwargs # type: Any + ): + # type: (...) -> 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', {})) + api_version = "2020-10-05-privatepreview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._create_or_update_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'serverGroupName': self._serialize.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + 'firewallRuleName': self._serialize.url("firewall_rule_name", firewall_rule_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'FirewallRule') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + 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 + + def begin_create_or_update( + self, + resource_group_name, # type: str + server_group_name, # type: str + firewall_rule_name, # type: str + parameters, # type: "_models.FirewallRule" + **kwargs # type: Any + ): + # type: (...) -> 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: True for ARMPolling, False for no polling, or a + polling object for 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: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, 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, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('FirewallRule', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'serverGroupName': self._serialize.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + 'firewallRuleName': self._serialize.url("firewall_rule_name", firewall_rule_name, 'str'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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, # type: str + server_group_name, # type: str + firewall_rule_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-05-privatepreview" + accept = "application/json" + + # Construct URL + url = self._delete_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'serverGroupName': self._serialize.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + 'firewallRuleName': self._serialize.url("firewall_rule_name", firewall_rule_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + 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 + + def begin_delete( + self, + resource_group_name, # type: str + server_group_name, # type: str + firewall_rule_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> 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: True for ARMPolling, False for no polling, or a + polling object for 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, 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) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'serverGroupName': self._serialize.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + 'firewallRuleName': self._serialize.url("firewall_rule_name", firewall_rule_name, 'str'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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 + + def get( + self, + resource_group_name, # type: str + server_group_name, # type: str + firewall_rule_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_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', {})) + api_version = "2020-10-05-privatepreview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'serverGroupName': self._serialize.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + 'firewallRuleName': self._serialize.url("firewall_rule_name", firewall_rule_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + 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 + + def list_by_server_group( + self, + resource_group_name, # type: str + server_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> 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', {})) + api_version = "2020-10-05-privatepreview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_server_group.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'serverGroupName': self._serialize.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + 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..c75c9cc8d065 --- /dev/null +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/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. +# -------------------------------------------------------------------------- +from typing import TYPE_CHECKING +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 HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +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 + + def list( + self, + **kwargs # type: Any + ): + # type: (...) -> 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', {})) + api_version = "2020-10-05-privatepreview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + 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..7f85be60aa31 --- /dev/null +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/operations/_roles_operations.py @@ -0,0 +1,378 @@ +# 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 TYPE_CHECKING +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 HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +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, # type: str + server_group_name, # type: str + role_name, # type: str + parameters, # type: "_models.Role" + **kwargs # type: Any + ): + # type: (...) -> 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', {})) + api_version = "2020-10-05-privatepreview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._create_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'serverGroupName': self._serialize.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + 'roleName': self._serialize.url("role_name", role_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'Role') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + 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 + + def begin_create( + self, + resource_group_name, # type: str + server_group_name, # type: str + role_name, # type: str + parameters, # type: "_models.Role" + **kwargs # type: Any + ): + # type: (...) -> 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: True for ARMPolling, False for no polling, or a + polling object for 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: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, 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, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('Role', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'serverGroupName': self._serialize.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + 'roleName': self._serialize.url("role_name", role_name, 'str'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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, # type: str + server_group_name, # type: str + role_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-05-privatepreview" + accept = "application/json" + + # Construct URL + url = self._delete_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'serverGroupName': self._serialize.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + 'roleName': self._serialize.url("role_name", role_name, 'str'), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + 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 + + def begin_delete( + self, + resource_group_name, # type: str + server_group_name, # type: str + role_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> 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: True for ARMPolling, False for no polling, or a + polling object for 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, 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) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'serverGroupName': self._serialize.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + 'roleName': self._serialize.url("role_name", role_name, 'str'), + } + + if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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 + + def list_by_server_group( + self, + resource_group_name, # type: str + server_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> 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', {})) + api_version = "2020-10-05-privatepreview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_server_group.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'serverGroupName': self._serialize.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + 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..2669ea216f70 --- /dev/null +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/operations/_server_groups_operations.py @@ -0,0 +1,1005 @@ +# 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 TYPE_CHECKING +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 HttpRequest, HttpResponse +from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.mgmt.core.polling.arm_polling import ARMPolling + +from .. import models as _models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +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 + + def list( + self, + **kwargs # type: Any + ): + # type: (...) -> 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', {})) + api_version = "2020-10-05-privatepreview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + 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 + + def list_by_resource_group( + self, + resource_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> 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', {})) + api_version = "2020-10-05-privatepreview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_resource_group.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + 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, # type: str + server_group_name, # type: str + parameters, # type: "_models.ServerGroup" + **kwargs # type: Any + ): + # type: (...) -> 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', {})) + api_version = "2020-10-05-privatepreview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._create_or_update_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'serverGroupName': self._serialize.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'ServerGroup') + body_content_kwargs['content'] = body_content + request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + 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 + + def begin_create_or_update( + self, + resource_group_name, # type: str + server_group_name, # type: str + parameters, # type: "_models.ServerGroup" + **kwargs # type: Any + ): + # type: (...) -> 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: True for ARMPolling, False for no polling, or a + polling object for 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: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, 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, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ServerGroup', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'serverGroupName': self._serialize.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + } + + if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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 + + def get( + self, + resource_group_name, # type: str + server_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_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', {})) + api_version = "2020-10-05-privatepreview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'serverGroupName': self._serialize.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + 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, # type: str + server_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-05-privatepreview" + accept = "application/json" + + # Construct URL + url = self._delete_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'serverGroupName': self._serialize.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.delete(url, query_parameters, header_parameters) + 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 + + def begin_delete( + self, + resource_group_name, # type: str + server_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> 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: True for ARMPolling, False for no polling, or a + polling object for 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, 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) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'serverGroupName': self._serialize.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + } + + if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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, # type: str + server_group_name, # type: str + parameters, # type: "_models.ServerGroupForUpdate" + **kwargs # type: Any + ): + # type: (...) -> 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', {})) + api_version = "2020-10-05-privatepreview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self._update_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'serverGroupName': self._serialize.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(parameters, 'ServerGroupForUpdate') + body_content_kwargs['content'] = body_content + request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) + 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 + + def begin_update( + self, + resource_group_name, # type: str + server_group_name, # type: str + parameters, # type: "_models.ServerGroupForUpdate" + **kwargs # type: Any + ): + # type: (...) -> 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: True for ARMPolling, False for no polling, or a + polling object for 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: + """ + polling = kwargs.pop('polling', True) # type: Union[bool, 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, + cls=lambda x,y,z: x, + **kwargs + ) + + kwargs.pop('error_map', None) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + deserialized = self._deserialize('ServerGroup', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + return deserialized + + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'serverGroupName': self._serialize.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + } + + if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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, # type: str + server_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-05-privatepreview" + accept = "application/json" + + # Construct URL + url = self._restart_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'serverGroupName': self._serialize.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(url, query_parameters, header_parameters) + 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 + + def begin_restart( + self, + resource_group_name, # type: str + server_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> 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: True for ARMPolling, False for no polling, or a + polling object for 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, 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) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'serverGroupName': self._serialize.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + } + + if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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, # type: str + server_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-05-privatepreview" + accept = "application/json" + + # Construct URL + url = self._start_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'serverGroupName': self._serialize.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(url, query_parameters, header_parameters) + 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 + + def begin_start( + self, + resource_group_name, # type: str + server_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> 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: True for ARMPolling, False for no polling, or a + polling object for 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, 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) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'serverGroupName': self._serialize.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + } + + if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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, # type: str + server_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> None + cls = kwargs.pop('cls', None) # type: ClsType[None] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + api_version = "2020-10-05-privatepreview" + accept = "application/json" + + # Construct URL + url = self._stop_initial.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'serverGroupName': self._serialize.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.post(url, query_parameters, header_parameters) + 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 + + def begin_stop( + self, + resource_group_name, # type: str + server_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> 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: True for ARMPolling, False for no polling, or a + polling object for 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, 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) + kwargs.pop('content_type', None) + + def get_long_running_output(pipeline_response): + if cls: + return cls(pipeline_response, None, {}) + + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'serverGroupName': self._serialize.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + } + + if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **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 + + def check_name_availability( + self, + name_availability_request, # type: "_models.NameAvailabilityRequest" + **kwargs # type: Any + ): + # type: (...) -> "_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', {})) + api_version = "2020-10-05-privatepreview" + content_type = kwargs.pop("content_type", "application/json") + accept = "application/json" + + # Construct URL + url = self.check_name_availability.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + body_content_kwargs = {} # type: Dict[str, Any] + body_content = self._serialize.body(name_availability_request, 'NameAvailabilityRequest') + body_content_kwargs['content'] = body_content + request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + 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..e1a6c833f2a6 --- /dev/null +++ b/sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresqlhsc/operations/_servers_operations.py @@ -0,0 +1,184 @@ +# 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 TYPE_CHECKING +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 HttpRequest, HttpResponse +from azure.mgmt.core.exceptions import ARMErrorFormat + +from .. import models as _models + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +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 + + def list_by_server_group( + self, + resource_group_name, # type: str + server_group_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> 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', {})) + api_version = "2020-10-05-privatepreview" + accept = "application/json" + + def prepare_request(next_link=None): + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + if not next_link: + # Construct URL + url = self.list_by_server_group.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'serverGroupName': self._serialize.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + else: + url = next_link + query_parameters = {} # type: Dict[str, Any] + request = self._client.get(url, query_parameters, header_parameters) + 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 + + def get( + self, + resource_group_name, # type: str + server_group_name, # type: str + server_name, # type: str + **kwargs # type: Any + ): + # type: (...) -> "_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', {})) + api_version = "2020-10-05-privatepreview" + accept = "application/json" + + # Construct URL + url = self.get.metadata['url'] # type: ignore + path_format_arguments = { + 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), + 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1, pattern=r'^[-\w\._\(\)]+$'), + 'serverGroupName': self._serialize.url("server_group_name", server_group_name, 'str', max_length=90, min_length=1), + 'serverName': self._serialize.url("server_name", server_name, 'str', max_length=90, min_length=1), + } + url = self._client.format_url(url, **path_format_arguments) + + # Construct parameters + query_parameters = {} # type: Dict[str, Any] + query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = {} # type: Dict[str, Any] + header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = self._client.get(url, query_parameters, header_parameters) + 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