diff --git a/src/postgresqlhsc/HISTORY.rst b/src/postgresqlhsc/HISTORY.rst new file mode 100644 index 00000000000..1c139576ba0 --- /dev/null +++ b/src/postgresqlhsc/HISTORY.rst @@ -0,0 +1,8 @@ +.. :changelog: + +Release History +=============== + +0.1.0 +++++++ +* Initial release. diff --git a/src/postgresqlhsc/README.md b/src/postgresqlhsc/README.md new file mode 100644 index 00000000000..51a95007f4e --- /dev/null +++ b/src/postgresqlhsc/README.md @@ -0,0 +1,140 @@ +# Azure CLI postgresqlhsc Extension # +This is the extension for postgresqlhsc + +### How to use ### +Install this extension using the below CLI command +``` +az extension add --name postgresqlhsc +``` + +### Included Features ### +#### postgresqlhsc server-group #### +##### Create ##### +``` +az postgresqlhsc server-group create --location "westus" --administrator-login "citus" \ + --administrator-login-password "password" --availability-zone "1" --backup-retention-days 35 --citus-version "9.5" \ + --enable-mx true --enable-zfs false --postgresql-version "12" \ + --server-role-groups name="" enable-ha=true role="Coordinator" server-count=1 server-edition="GeneralPurpose" storage-quota-in-mb=524288 v-cores=4 \ + --server-role-groups name="" enable-ha=false role="Worker" server-count=3 server-edition="MemoryOptimized" storage-quota-in-mb=524288 v-cores=4 \ + --standby-availability-zone "2" --tags ElasticServer="1" --resource-group "TestGroup" --name "hsctestsg" +``` +##### Create ##### +``` +az postgresqlhsc server-group create --location "westus" --create-mode "PointInTimeRestore" --enable-mx true \ + --enable-zfs false --point-in-time-utc "2017-12-14T00:00:37.467Z" --source-location "eastus" \ + --source-resource-group-name "SourceGroup" --source-server-group-name "pgtests-source-server-group" \ + --source-subscription-id "dddddddd-dddd-dddd-dddd-dddddddddddd" --resource-group "TestGroup" --name "hsctestsg" +``` +##### List ##### +``` +az postgresqlhsc server-group list --resource-group "TestGroup" +``` +##### Show ##### +``` +az postgresqlhsc server-group show --resource-group "TestGroup" --name "hsctestsg1" +``` +##### Update ##### +``` +az postgresqlhsc server-group update --location "westus" --server-role-groups name="" role="Worker" server-count=10 \ + --resource-group "TestGroup" --name "hsctestsg" +``` +##### Update ##### +``` +az postgresqlhsc server-group update --location "westus" --server-role-groups name="" role="Coordinator" v-cores=16 \ + --resource-group "TestGroup" --name "hsctestsg" +``` +##### Update ##### +``` +az postgresqlhsc server-group update --location "westus" \ + --server-role-groups name="" role="Worker" storage-quota-in-mb=8388608 --resource-group "TestGroup" \ + --name "hsctestsg" +``` +##### Update ##### +``` +az postgresqlhsc server-group update \ + --maintenance-window custom-window="Enabled" day-of-week=0 start-hour=8 start-minute=0 \ + --resource-group "TestGroup" --name "hsctestsg" +``` +##### Update ##### +``` +az postgresqlhsc server-group update --administrator-login-password "secret" --backup-retention-days 30 \ + --postgresql-version "12" \ + --server-role-groups name="" enable-ha=false role="Coordinator" server-count=1 server-edition="GeneralPurpose" storage-quota-in-mb=1048576 v-cores=8 \ + --server-role-groups name="" enable-ha=true role="Worker" server-count=4 server-edition="MemoryOptimized" storage-quota-in-mb=524288 v-cores=4 \ + --tags ElasticServer="2" --resource-group "TestGroup" --name "hsctestsg" +``` +##### Restart ##### +``` +az postgresqlhsc server-group restart --resource-group "TestGroup" --name "hsctestsg1" +``` +##### Start ##### +``` +az postgresqlhsc server-group start --resource-group "TestGroup" --name "hsctestsg1" +``` +##### Stop ##### +``` +az postgresqlhsc server-group stop --resource-group "TestGroup" --name "hsctestsg1" +``` +##### Delete ##### +``` +az postgresqlhsc server-group delete --resource-group "TestGroup" --name "testservergroup" +``` +#### postgresqlhsc server #### +##### List ##### +``` +az postgresqlhsc server list --resource-group "TestGroup" --server-group-name "hsctestsg1" +``` +##### Show ##### +``` +az postgresqlhsc server show --resource-group "TestGroup" --server-group-name "hsctestsg1" --name "hsctestsg1-c" +``` +#### postgresqlhsc configuration #### +##### List ##### +``` +az postgresqlhsc configuration list --resource-group "TestResourceGroup" --server-group-name "hsctestsg" \ + --server-name "testserver" +``` +##### Show ##### +``` +az postgresqlhsc configuration show --name "array_nulls" --resource-group "TestResourceGroup" \ + --server-group-name "hsctestsg" +``` +##### Update ##### +``` +az postgresqlhsc configuration update --name "array_nulls" \ + --server-role-group-configurations role="Coordinator" value="on" \ + --server-role-group-configurations role="Worker" value="off" --resource-group "TestResourceGroup" \ + --server-group-name "hsctestsg" +``` +#### postgresqlhsc firewall-rule #### +##### Create ##### +``` +az postgresqlhsc firewall-rule create --name "rule1" --end-ip-address "255.255.255.255" --start-ip-address "0.0.0.0" \ + --resource-group "TestGroup" --server-group-name "pgtestsvc4" +``` +##### Show ##### +``` +az postgresqlhsc firewall-rule show --name "rule1" --resource-group "TestGroup" --server-group-name "pgtestsvc4" +``` +##### List ##### +``` +az postgresqlhsc firewall-rule list --resource-group "TestGroup" --server-group-name "pgtestsvc4" +``` +##### Delete ##### +``` +az postgresqlhsc firewall-rule delete --name "rule1" --resource-group "TestGroup" --server-group-name "pgtestsvc4" +``` +#### postgresqlhsc role #### +##### Create ##### +``` +az postgresqlhsc role create --password "secret" --resource-group "TestGroup" --name "role1" \ + --server-group-name "pgtestsvc4" +``` +##### List ##### +``` +az postgresqlhsc role list --resource-group "TestGroup" --server-group-name "pgtestsvc4" +``` +##### Delete ##### +``` +az postgresqlhsc role delete --resource-group "TestGroup" --name "role1" --server-group-name "pgtestsvc4" +``` \ No newline at end of file diff --git a/src/postgresqlhsc/azext_postgresqlhsc/__init__.py b/src/postgresqlhsc/azext_postgresqlhsc/__init__.py new file mode 100644 index 00000000000..0bf77303c3d --- /dev/null +++ b/src/postgresqlhsc/azext_postgresqlhsc/__init__.py @@ -0,0 +1,50 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from azure.cli.core import AzCommandsLoader +from azext_postgresqlhsc.generated._help import helps # pylint: disable=unused-import +try: + from azext_postgresqlhsc.manual._help import helps # pylint: disable=reimported +except ImportError: + pass + + +class MicrosoftPostgreSQLHyperscaleCommandsLoader(AzCommandsLoader): + + def __init__(self, cli_ctx=None): + from azure.cli.core.commands import CliCommandType + from azext_postgresqlhsc.generated._client_factory import cf_postgresqlhsc_cl + postgresqlhsc_custom = CliCommandType( + operations_tmpl='azext_postgresqlhsc.custom#{}', + client_factory=cf_postgresqlhsc_cl) + parent = super(MicrosoftPostgreSQLHyperscaleCommandsLoader, self) + parent.__init__(cli_ctx=cli_ctx, custom_command_type=postgresqlhsc_custom) + + def load_command_table(self, args): + from azext_postgresqlhsc.generated.commands import load_command_table + load_command_table(self, args) + try: + from azext_postgresqlhsc.manual.commands import load_command_table as load_command_table_manual + load_command_table_manual(self, args) + except ImportError: + pass + return self.command_table + + def load_arguments(self, command): + from azext_postgresqlhsc.generated._params import load_arguments + load_arguments(self, command) + try: + from azext_postgresqlhsc.manual._params import load_arguments as load_arguments_manual + load_arguments_manual(self, command) + except ImportError: + pass + + +COMMAND_LOADER_CLS = MicrosoftPostgreSQLHyperscaleCommandsLoader diff --git a/src/postgresqlhsc/azext_postgresqlhsc/action.py b/src/postgresqlhsc/azext_postgresqlhsc/action.py new file mode 100644 index 00000000000..d95d53bf711 --- /dev/null +++ b/src/postgresqlhsc/azext_postgresqlhsc/action.py @@ -0,0 +1,17 @@ +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +# pylint: disable=wildcard-import +# pylint: disable=unused-wildcard-import + +from .generated.action import * # noqa: F403 +try: + from .manual.action import * # noqa: F403 +except ImportError: + pass diff --git a/src/postgresqlhsc/azext_postgresqlhsc/azext_metadata.json b/src/postgresqlhsc/azext_postgresqlhsc/azext_metadata.json new file mode 100644 index 00000000000..4f48fa652a5 --- /dev/null +++ b/src/postgresqlhsc/azext_postgresqlhsc/azext_metadata.json @@ -0,0 +1,4 @@ +{ + "azext.isExperimental": true, + "azext.minCliCoreVersion": "2.11.0" +} \ No newline at end of file diff --git a/src/postgresqlhsc/azext_postgresqlhsc/custom.py b/src/postgresqlhsc/azext_postgresqlhsc/custom.py new file mode 100644 index 00000000000..dbe9d5f9742 --- /dev/null +++ b/src/postgresqlhsc/azext_postgresqlhsc/custom.py @@ -0,0 +1,17 @@ +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +# pylint: disable=wildcard-import +# pylint: disable=unused-wildcard-import + +from .generated.custom import * # noqa: F403 +try: + from .manual.custom import * # noqa: F403 +except ImportError: + pass diff --git a/src/postgresqlhsc/azext_postgresqlhsc/generated/__init__.py b/src/postgresqlhsc/azext_postgresqlhsc/generated/__init__.py new file mode 100644 index 00000000000..c9cfdc73e77 --- /dev/null +++ b/src/postgresqlhsc/azext_postgresqlhsc/generated/__init__.py @@ -0,0 +1,12 @@ +# 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. +# -------------------------------------------------------------------------- + +__path__ = __import__('pkgutil').extend_path(__path__, __name__) diff --git a/src/postgresqlhsc/azext_postgresqlhsc/generated/_client_factory.py b/src/postgresqlhsc/azext_postgresqlhsc/generated/_client_factory.py new file mode 100644 index 00000000000..8f65d675f9d --- /dev/null +++ b/src/postgresqlhsc/azext_postgresqlhsc/generated/_client_factory.py @@ -0,0 +1,36 @@ +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- + + +def cf_postgresqlhsc_cl(cli_ctx, *_): + from azure.cli.core.commands.client_factory import get_mgmt_service_client + from ..vendored_sdks.postgresqlhsc import MicrosoftPostgreSQLHyperscale + return get_mgmt_service_client(cli_ctx, + MicrosoftPostgreSQLHyperscale) + + +def cf_server_group(cli_ctx, *_): + return cf_postgresqlhsc_cl(cli_ctx).server_group + + +def cf_server(cli_ctx, *_): + return cf_postgresqlhsc_cl(cli_ctx).server + + +def cf_configuration(cli_ctx, *_): + return cf_postgresqlhsc_cl(cli_ctx).configuration + + +def cf_firewall_rule(cli_ctx, *_): + return cf_postgresqlhsc_cl(cli_ctx).firewall_rule + + +def cf_role(cli_ctx, *_): + return cf_postgresqlhsc_cl(cli_ctx).role diff --git a/src/postgresqlhsc/azext_postgresqlhsc/generated/_help.py b/src/postgresqlhsc/azext_postgresqlhsc/generated/_help.py new file mode 100644 index 00000000000..87da88a11f5 --- /dev/null +++ b/src/postgresqlhsc/azext_postgresqlhsc/generated/_help.py @@ -0,0 +1,378 @@ +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +# pylint: disable=too-many-lines + +from knack.help_files import helps + + +helps['postgresqlhsc server-group'] = """ + type: group + short-summary: postgresqlhsc server-group +""" + +helps['postgresqlhsc server-group list'] = """ + type: command + short-summary: "List all the server groups in a given resource group. And List all the server groups in a given \ +subscription." + examples: + - name: List the server groups by resource group + text: |- + az postgresqlhsc server-group list --resource-group "TestGroup" + - name: List all the server groups + text: |- + az postgresqlhsc server-group list +""" + +helps['postgresqlhsc server-group show'] = """ + type: command + short-summary: "Gets information about a server group." + examples: + - name: Get the server group + text: |- + az postgresqlhsc server-group show --resource-group "TestGroup" --name "hsctestsg1" +""" + +helps['postgresqlhsc server-group create'] = """ + type: command + short-summary: "Creates a new server group with servers." + parameters: + - name: --server-role-groups + short-summary: "The list of server role groups." + long-summary: | + Usage: --server-role-groups name=XX role=XX server-count=XX server-edition=XX storage-quota-in-mb=XX \ +v-cores=XX enable-ha=XX + + name: The name of the server role group. + role: The role of servers in the server role group. + server-count: The number of servers in the server role group. + server-edition: The edition of a server (default: GeneralPurpose). + storage-quota-in-mb: The storage of a server in MB (max: 2097152 = 2TiB). + v-cores: The vCores count of a server (max: 64). + enable-ha: If high availability is enabled or not for the server. + + Multiple actions can be specified by using more than one --server-role-groups argument. + - name: --maintenance-window + short-summary: "Maintenance window of a server group." + long-summary: | + Usage: --maintenance-window custom-window=XX start-hour=XX start-minute=XX day-of-week=XX + + custom-window: indicates whether custom window is enabled or disabled + start-hour: start hour for maintenance window + start-minute: start minute for maintenance window + day-of-week: day of week for maintenance window + examples: + - name: Create a new server group + text: |- + az postgresqlhsc server-group create --location "westus" --administrator-login "citus" \ +--administrator-login-password "password" --availability-zone "1" --backup-retention-days 35 --citus-version "9.5" \ +--enable-mx true --enable-zfs false --postgresql-version "12" --server-role-groups name="" enable-ha=true \ +role="Coordinator" server-count=1 server-edition="GeneralPurpose" storage-quota-in-mb=524288 v-cores=4 \ +--server-role-groups name="" enable-ha=false role="Worker" server-count=3 server-edition="MemoryOptimized" \ +storage-quota-in-mb=524288 v-cores=4 --standby-availability-zone "2" --tags ElasticServer="1" --resource-group \ +"TestGroup" --name "hsctestsg" + - name: Create a new server group as a point in time restore + text: |- + az postgresqlhsc server-group create --location "westus" --create-mode "PointInTimeRestore" --enable-mx \ +true --enable-zfs false --point-in-time-utc "2017-12-14T00:00:37.467Z" --source-location "eastus" \ +--source-resource-group-name "SourceGroup" --source-server-group-name "pgtests-source-server-group" \ +--source-subscription-id "dddddddd-dddd-dddd-dddd-dddddddddddd" --resource-group "TestGroup" --name "hsctestsg" +""" + +helps['postgresqlhsc server-group update'] = """ + type: command + short-summary: "Updates an existing server group. The request body can contain one to many of the properties \ +present in the normal server group definition." + parameters: + - name: --server-role-groups + short-summary: "The list of server role groups." + long-summary: | + Usage: --server-role-groups name=XX role=XX server-count=XX server-edition=XX storage-quota-in-mb=XX \ +v-cores=XX enable-ha=XX + + name: The name of the server role group. + role: The role of servers in the server role group. + server-count: The number of servers in the server role group. + server-edition: The edition of a server (default: GeneralPurpose). + storage-quota-in-mb: The storage of a server in MB (max: 2097152 = 2TiB). + v-cores: The vCores count of a server (max: 64). + enable-ha: If high availability is enabled or not for the server. + + Multiple actions can be specified by using more than one --server-role-groups argument. + - name: --maintenance-window + short-summary: "Maintenance window of a server group." + long-summary: | + Usage: --maintenance-window custom-window=XX start-hour=XX start-minute=XX day-of-week=XX + + custom-window: indicates whether custom window is enabled or disabled + start-hour: start hour for maintenance window + start-minute: start minute for maintenance window + day-of-week: day of week for maintenance window + examples: + - name: Add new worker nodes + text: |- + az postgresqlhsc server-group update --location "westus" --server-role-groups name="" role="Worker" \ +server-count=10 --resource-group "TestGroup" --name "hsctestsg" + - name: Scale compute + text: |- + az postgresqlhsc server-group update --location "westus" --server-role-groups name="" \ +role="Coordinator" v-cores=16 --resource-group "TestGroup" --name "hsctestsg" + - name: Scale storage + text: |- + az postgresqlhsc server-group update --location "westus" --server-role-groups name="" role="Worker" \ +storage-quota-in-mb=8388608 --resource-group "TestGroup" --name "hsctestsg" + - name: Update customer maintenance window + text: |- + az postgresqlhsc server-group update --maintenance-window custom-window="Enabled" day-of-week=0 \ +start-hour=8 start-minute=0 --resource-group "TestGroup" --name "hsctestsg" + - name: Update the server group + text: |- + az postgresqlhsc server-group update --administrator-login-password "secret" --backup-retention-days 30 \ +--postgresql-version "12" --server-role-groups name="" enable-ha=false role="Coordinator" server-count=1 \ +server-edition="GeneralPurpose" storage-quota-in-mb=1048576 v-cores=8 --server-role-groups name="" enable-ha=true \ +role="Worker" server-count=4 server-edition="MemoryOptimized" storage-quota-in-mb=524288 v-cores=4 --tags \ +ElasticServer="2" --resource-group "TestGroup" --name "hsctestsg" +""" + +helps['postgresqlhsc server-group delete'] = """ + type: command + short-summary: "Deletes a server group together with servers in it." + examples: + - name: Delete the server group + text: |- + az postgresqlhsc server-group delete --resource-group "TestGroup" --name "testservergroup" +""" + +helps['postgresqlhsc server-group restart'] = """ + type: command + short-summary: "Restarts the server group." + examples: + - name: Restart all servers in the server group + text: |- + az postgresqlhsc server-group restart --resource-group "TestGroup" --name "hsctestsg1" +""" + +helps['postgresqlhsc server-group start'] = """ + type: command + short-summary: "Starts the server group." + examples: + - name: Start all servers in the server group + text: |- + az postgresqlhsc server-group start --resource-group "TestGroup" --name "hsctestsg1" +""" + +helps['postgresqlhsc server-group stop'] = """ + type: command + short-summary: "Stops the server group." + examples: + - name: Stop all servers in the server group + text: |- + az postgresqlhsc server-group stop --resource-group "TestGroup" --name "hsctestsg1" +""" + +helps['postgresqlhsc server-group wait'] = """ + type: command + short-summary: Place the CLI in a waiting state until a condition of the postgresqlhsc server-group is met. + examples: + - name: Pause executing next line of CLI script until the postgresqlhsc server-group is successfully created. + text: |- + az postgresqlhsc server-group wait --resource-group "TestGroup" --name "hsctestsg1" --created + - name: Pause executing next line of CLI script until the postgresqlhsc server-group is successfully updated. + text: |- + az postgresqlhsc server-group wait --resource-group "TestGroup" --name "hsctestsg1" --updated + - name: Pause executing next line of CLI script until the postgresqlhsc server-group is successfully deleted. + text: |- + az postgresqlhsc server-group wait --resource-group "TestGroup" --name "hsctestsg1" --deleted +""" + +helps['postgresqlhsc server'] = """ + type: group + short-summary: postgresqlhsc server +""" + +helps['postgresqlhsc server list'] = """ + type: command + short-summary: "Lists servers of a server group." + examples: + - name: List servers of the server group + text: |- + az postgresqlhsc server list --resource-group "TestGroup" --server-group-name "hsctestsg1" +""" + +helps['postgresqlhsc server show'] = """ + type: command + short-summary: "Gets information about a server in server group." + examples: + - name: Get the server of server group + text: |- + az postgresqlhsc server show --resource-group "TestGroup" --server-group-name "hsctestsg1" --name \ +"hsctestsg1-c" +""" + +helps['postgresqlhsc configuration'] = """ + type: group + short-summary: postgresqlhsc configuration +""" + +helps['postgresqlhsc configuration list'] = """ + type: command + short-summary: "List all the configurations of a server in server group. And List all the configurations of a \ +server group." + examples: + - name: List configurations of the server that in the server group + text: |- + az postgresqlhsc configuration list --resource-group "TestResourceGroup" --server-group-name \ +"hsctestsg" --server-name "testserver" + - name: List configurations of the server group + text: |- + az postgresqlhsc configuration list --resource-group "TestResourceGroup" --server-group-name \ +"hsctestsg" +""" + +helps['postgresqlhsc configuration show'] = """ + type: command + short-summary: "Gets information about single server group configuration." + examples: + - name: Get single configuration of the server group + text: |- + az postgresqlhsc configuration show --name "array_nulls" --resource-group "TestResourceGroup" \ +--server-group-name "hsctestsg" +""" + +helps['postgresqlhsc configuration update'] = """ + type: command + short-summary: "Updates configuration of server role groups in a server group." + parameters: + - name: --server-role-group-configurations + short-summary: "The list of server role group configuration values." + long-summary: | + Usage: --server-role-group-configurations role=XX value=XX + + role: Required. The role of servers in the server role group. + value: Required. Value of the configuration. + + Multiple actions can be specified by using more than one --server-role-group-configurations argument. + examples: + - name: Update single configuration of the server group + text: |- + az postgresqlhsc configuration update --name "array_nulls" --server-role-group-configurations \ +role="Coordinator" value="on" --server-role-group-configurations role="Worker" value="off" --resource-group \ +"TestResourceGroup" --server-group-name "hsctestsg" +""" + +helps['postgresqlhsc configuration wait'] = """ + type: command + short-summary: Place the CLI in a waiting state until a condition of the postgresqlhsc configuration is met. + examples: + - name: Pause executing next line of CLI script until the postgresqlhsc configuration is successfully updated. + text: |- + az postgresqlhsc configuration wait --name "array_nulls" --resource-group "TestResourceGroup" \ +--server-group-name "hsctestsg" --updated +""" + +helps['postgresqlhsc firewall-rule'] = """ + type: group + short-summary: postgresqlhsc firewall-rule +""" + +helps['postgresqlhsc firewall-rule list'] = """ + type: command + short-summary: "List all the firewall rules in a given server group." + examples: + - name: List firewall rules of the server group + text: |- + az postgresqlhsc firewall-rule list --resource-group "TestGroup" --server-group-name "pgtestsvc4" +""" + +helps['postgresqlhsc firewall-rule show'] = """ + type: command + short-summary: "Gets information about a server group firewall rule." + examples: + - name: Get the firewall rule of the server group + text: |- + az postgresqlhsc firewall-rule show --name "rule1" --resource-group "TestGroup" --server-group-name \ +"pgtestsvc4" +""" + +helps['postgresqlhsc firewall-rule create'] = """ + type: command + short-summary: "Creates a new firewall rule or updates an existing firewall rule." + examples: + - name: Create a firewall rule of the server group + text: |- + az postgresqlhsc firewall-rule create --name "rule1" --end-ip-address "255.255.255.255" \ +--start-ip-address "0.0.0.0" --resource-group "TestGroup" --server-group-name "pgtestsvc4" +""" + +helps['postgresqlhsc firewall-rule update'] = """ + type: command + short-summary: "Update a new firewall rule or updates an existing firewall rule." +""" + +helps['postgresqlhsc firewall-rule delete'] = """ + type: command + short-summary: "Deletes a server group firewall rule." + examples: + - name: Delete the firewall rule of the server group + text: |- + az postgresqlhsc firewall-rule delete --name "rule1" --resource-group "TestGroup" --server-group-name \ +"pgtestsvc4" +""" + +helps['postgresqlhsc firewall-rule wait'] = """ + type: command + short-summary: Place the CLI in a waiting state until a condition of the postgresqlhsc firewall-rule is met. + examples: + - name: Pause executing next line of CLI script until the postgresqlhsc firewall-rule is successfully created. + text: |- + az postgresqlhsc firewall-rule wait --name "rule1" --resource-group "TestGroup" --server-group-name \ +"pgtestsvc4" --created + - name: Pause executing next line of CLI script until the postgresqlhsc firewall-rule is successfully updated. + text: |- + az postgresqlhsc firewall-rule wait --name "rule1" --resource-group "TestGroup" --server-group-name \ +"pgtestsvc4" --updated + - name: Pause executing next line of CLI script until the postgresqlhsc firewall-rule is successfully deleted. + text: |- + az postgresqlhsc firewall-rule wait --name "rule1" --resource-group "TestGroup" --server-group-name \ +"pgtestsvc4" --deleted +""" + +helps['postgresqlhsc role'] = """ + type: group + short-summary: postgresqlhsc role +""" + +helps['postgresqlhsc role list'] = """ + type: command + short-summary: "List all the roles in a given server group." + examples: + - name: RoleList + text: |- + az postgresqlhsc role list --resource-group "TestGroup" --server-group-name "pgtestsvc4" +""" + +helps['postgresqlhsc role create'] = """ + type: command + short-summary: "Creates a new role or updates an existing role." + examples: + - name: RoleCreate + text: |- + az postgresqlhsc role create --password "secret" --resource-group "TestGroup" --name "role1" \ +--server-group-name "pgtestsvc4" +""" + +helps['postgresqlhsc role delete'] = """ + type: command + short-summary: "Deletes a server group role." + examples: + - name: RoleDelete + text: |- + az postgresqlhsc role delete --resource-group "TestGroup" --name "role1" --server-group-name \ +"pgtestsvc4" +""" diff --git a/src/postgresqlhsc/azext_postgresqlhsc/generated/_params.py b/src/postgresqlhsc/azext_postgresqlhsc/generated/_params.py new file mode 100644 index 00000000000..ca03007cfd1 --- /dev/null +++ b/src/postgresqlhsc/azext_postgresqlhsc/generated/_params.py @@ -0,0 +1,221 @@ +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +# pylint: disable=too-many-lines +# pylint: disable=too-many-statements + +from azure.cli.core.commands.parameters import ( + tags_type, + get_three_state_flag, + get_enum_type, + resource_group_name_type, + get_location_type +) +from azure.cli.core.commands.validators import get_default_location_from_resource_group +from azext_postgresqlhsc.action import ( + AddServerRoleGroups, + AddMaintenanceWindow, + AddServerRoleGroupConfigurations +) + + +def load_arguments(self, _): + + with self.argument_context('postgresqlhsc server-group list') as c: + c.argument('resource_group_name', resource_group_name_type) + + with self.argument_context('postgresqlhsc server-group show') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('server_group_name', options_list=['--name', '-n', '--server-group-name'], type=str, help='The name ' + 'of the server group.', id_part='name') + + with self.argument_context('postgresqlhsc server-group create') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('server_group_name', options_list=['--name', '-n', '--server-group-name'], type=str, help='The name ' + 'of the server group.') + c.argument('tags', tags_type) + c.argument('location', arg_type=get_location_type(self.cli_ctx), + validator=get_default_location_from_resource_group) + c.argument('create_mode', arg_type=get_enum_type(['Default', 'PointInTimeRestore']), help='The mode to create ' + 'a new server group.') + c.argument('administrator_login', type=str, help='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).') + c.argument('administrator_login_password', help='The password of the administrator login.') + c.argument('backup_retention_days', type=int, help='The backup retention days for server group.') + c.argument('postgresql_version', arg_type=get_enum_type(['11', '12']), help='The PostgreSQL version of server ' + 'group.') + c.argument('citus_version', arg_type=get_enum_type(['8.3', '9.0', '9.1', '9.2', '9.3', '9.4', '9.5']), help='' + 'The Citus version of server group.') + c.argument('enable_mx', arg_type=get_three_state_flag(), help='If Citus MX is enabled or not for the server ' + 'group.') + c.argument('enable_zfs', arg_type=get_three_state_flag(), help='If ZFS compression is enabled or not for the ' + 'server group.') + c.argument('enable_shards_on_coordinator', arg_type=get_three_state_flag(), help='If shards on coordinator is ' + 'enabled or not for the server group.') + c.argument('server_role_groups', action=AddServerRoleGroups, nargs='*', + help='The list of server role groups.') + c.argument('maintenance_window', action=AddMaintenanceWindow, nargs='*', help='Maintenance window of a server ' + 'group.') + c.argument('availability_zone', type=str, help='Availability Zone information of the server group.') + c.argument('standby_availability_zone', type=str, help='Standby Availability Zone information of the server ' + 'group.') + c.argument('source_subscription_id', type=str, help='The source subscription id to restore from. It\'s ' + 'required when \'createMode\' is \'PointInTimeRestore\'') + c.argument('source_resource_group_name', type=str, help='The source resource group name to restore from. It\'s ' + 'required when \'createMode\' is \'PointInTimeRestore\'') + c.argument('source_server_group_name', type=str, help='The source server group name to restore from. It\'s ' + 'required when \'createMode\' is \'PointInTimeRestore\'') + c.argument('source_location', type=str, help='The source server group location to restore from. It\'s required ' + 'when \'createMode\' is \'PointInTimeRestore\'') + c.argument('point_in_time_utc', help='Restore point creation time (ISO8601 format), specifying the time to ' + 'restore from. It\'s required when \'createMode\' is \'PointInTimeRestore\'') + c.argument('delegated_subnet_arguments_subnet_arm_resource_id', type=str, help='delegated subnet arm resource ' + 'id.') + + with self.argument_context('postgresqlhsc server-group update') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('server_group_name', options_list=['--name', '-n', '--server-group-name'], type=str, help='The name ' + 'of the server group.', id_part='name') + c.argument('location', arg_type=get_location_type(self.cli_ctx), + validator=get_default_location_from_resource_group) + c.argument('tags', tags_type) + c.argument('administrator_login_password', help='The password of the administrator login.') + c.argument('backup_retention_days', type=int, help='The backup retention days for server group.') + c.argument('postgresql_version', arg_type=get_enum_type(['11', '12']), help='The PostgreSQL version of server ' + 'group.') + c.argument('citus_version', arg_type=get_enum_type(['8.3', '9.0', '9.1', '9.2', '9.3', '9.4', '9.5']), help='' + 'The Citus version of server group.') + c.argument('enable_shards_on_coordinator', arg_type=get_three_state_flag(), help='If shards on coordinator is ' + 'enabled or not for the server group.') + c.argument('server_role_groups', action=AddServerRoleGroups, nargs='*', + help='The list of server role groups.') + c.argument('maintenance_window', action=AddMaintenanceWindow, nargs='*', help='Maintenance window of a server ' + 'group.') + c.argument('availability_zone', type=str, help='Availability Zone information of the server group.') + c.argument('standby_availability_zone', type=str, help='Standby Availability Zone information of the server ' + 'group.') + + with self.argument_context('postgresqlhsc server-group delete') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('server_group_name', options_list=['--name', '-n', '--server-group-name'], type=str, help='The name ' + 'of the server group.', id_part='name') + + with self.argument_context('postgresqlhsc server-group restart') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('server_group_name', options_list=['--name', '-n', '--server-group-name'], type=str, help='The name ' + 'of the server group.', id_part='name') + + with self.argument_context('postgresqlhsc server-group start') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('server_group_name', options_list=['--name', '-n', '--server-group-name'], type=str, help='The name ' + 'of the server group.', id_part='name') + + with self.argument_context('postgresqlhsc server-group stop') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('server_group_name', options_list=['--name', '-n', '--server-group-name'], type=str, help='The name ' + 'of the server group.', id_part='name') + + with self.argument_context('postgresqlhsc server-group wait') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('server_group_name', options_list=['--name', '-n', '--server-group-name'], type=str, help='The name ' + 'of the server group.', id_part='name') + + with self.argument_context('postgresqlhsc server list') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('server_group_name', type=str, help='The name of the server group.') + + with self.argument_context('postgresqlhsc server show') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('server_group_name', type=str, help='The name of the server group.', id_part='name') + c.argument('server_name', options_list=['--name', '-n', '--server-name'], type=str, help='The name of the ' + 'server.', id_part='child_name_1') + + with self.argument_context('postgresqlhsc configuration list') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('server_group_name', type=str, help='The name of the server group.') + c.argument('server_name', type=str, help='The name of the server.') + + with self.argument_context('postgresqlhsc configuration show') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('server_group_name', type=str, help='The name of the server group.', id_part='name') + c.argument('configuration_name', options_list=['--name', '-n', '--configuration-name'], type=str, help='The ' + 'name of the server group configuration.', id_part='child_name_1') + + with self.argument_context('postgresqlhsc configuration update') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('server_group_name', type=str, help='The name of the server group.', id_part='name') + c.argument('configuration_name', options_list=['--name', '-n', '--configuration-name'], type=str, help='The ' + 'name of the server group configuration.', id_part='child_name_1') + c.argument('server_role_group_configurations', action=AddServerRoleGroupConfigurations, nargs='*', help='The ' + 'list of server role group configuration values.') + + with self.argument_context('postgresqlhsc configuration wait') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('server_group_name', type=str, help='The name of the server group.', id_part='name') + c.argument('configuration_name', options_list=['--name', '-n', '--configuration-name'], type=str, help='The ' + 'name of the server group configuration.', id_part='child_name_1') + + with self.argument_context('postgresqlhsc firewall-rule list') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('server_group_name', type=str, help='The name of the server group.') + + with self.argument_context('postgresqlhsc firewall-rule show') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('server_group_name', type=str, help='The name of the server group.', id_part='name') + c.argument('firewall_rule_name', options_list=['--name', '-n', '--firewall-rule-name'], type=str, help='The ' + 'name of the server group firewall rule.', id_part='child_name_1') + + with self.argument_context('postgresqlhsc firewall-rule create') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('server_group_name', type=str, help='The name of the server group.') + c.argument('firewall_rule_name', options_list=['--name', '-n', '--firewall-rule-name'], type=str, help='The ' + 'name of the server group firewall rule.') + c.argument('start_ip_address', type=str, help='The start IP address of the server group firewall rule. Must be ' + 'IPv4 format.') + c.argument('end_ip_address', type=str, help='The end IP address of the server group firewall rule. Must be ' + 'IPv4 format.') + + with self.argument_context('postgresqlhsc firewall-rule update') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('server_group_name', type=str, help='The name of the server group.', id_part='name') + c.argument('firewall_rule_name', options_list=['--name', '-n', '--firewall-rule-name'], type=str, help='The ' + 'name of the server group firewall rule.', id_part='child_name_1') + c.argument('start_ip_address', type=str, help='The start IP address of the server group firewall rule. Must be ' + 'IPv4 format.') + c.argument('end_ip_address', type=str, help='The end IP address of the server group firewall rule. Must be ' + 'IPv4 format.') + + with self.argument_context('postgresqlhsc firewall-rule delete') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('server_group_name', type=str, help='The name of the server group.', id_part='name') + c.argument('firewall_rule_name', options_list=['--name', '-n', '--firewall-rule-name'], type=str, help='The ' + 'name of the server group firewall rule.', id_part='child_name_1') + + with self.argument_context('postgresqlhsc firewall-rule wait') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('server_group_name', type=str, help='The name of the server group.', id_part='name') + c.argument('firewall_rule_name', options_list=['--name', '-n', '--firewall-rule-name'], type=str, help='The ' + 'name of the server group firewall rule.', id_part='child_name_1') + + with self.argument_context('postgresqlhsc role list') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('server_group_name', type=str, help='The name of the server group.') + + with self.argument_context('postgresqlhsc role create') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('server_group_name', type=str, help='The name of the server group.') + c.argument('role_name', options_list=['--name', '-n', '--role-name'], type=str, help='The name of the server ' + 'group role name.') + c.argument('password', help='The password of the server group role.') + + with self.argument_context('postgresqlhsc role delete') as c: + c.argument('resource_group_name', resource_group_name_type) + c.argument('server_group_name', type=str, help='The name of the server group.', id_part='name') + c.argument('role_name', options_list=['--name', '-n', '--role-name'], type=str, help='The name of the server ' + 'group role name.', id_part='child_name_1') diff --git a/src/postgresqlhsc/azext_postgresqlhsc/generated/_validators.py b/src/postgresqlhsc/azext_postgresqlhsc/generated/_validators.py new file mode 100644 index 00000000000..b33a44c1ebf --- /dev/null +++ b/src/postgresqlhsc/azext_postgresqlhsc/generated/_validators.py @@ -0,0 +1,9 @@ +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- diff --git a/src/postgresqlhsc/azext_postgresqlhsc/generated/action.py b/src/postgresqlhsc/azext_postgresqlhsc/generated/action.py new file mode 100644 index 00000000000..1f7538de9d5 --- /dev/null +++ b/src/postgresqlhsc/azext_postgresqlhsc/generated/action.py @@ -0,0 +1,100 @@ +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +# pylint: disable=protected-access + +import argparse +from collections import defaultdict +from knack.util import CLIError + + +class AddServerRoleGroups(argparse._AppendAction): + def __call__(self, parser, namespace, values, option_string=None): + action = self.get_action(values, option_string) + super(AddServerRoleGroups, self).__call__(parser, namespace, action, option_string) + + def get_action(self, values, option_string): # pylint: disable=no-self-use + try: + properties = defaultdict(list) + for (k, v) in (x.split('=', 1) for x in values): + properties[k].append(v) + properties = dict(properties) + except ValueError: + raise CLIError('usage error: {} [KEY=VALUE ...]'.format(option_string)) + d = {} + for k in properties: + kl = k.lower() + v = properties[k] + if kl == 'name': + d['name'] = v[0] + elif kl == 'role': + d['role'] = v[0] + elif kl == 'server-count': + d['server_count'] = v[0] + elif kl == 'server-edition': + d['server_edition'] = v[0] + elif kl == 'storage-quota-in-mb': + d['storage_quota_in_mb'] = v[0] + elif kl == 'v-cores': + d['v_cores'] = v[0] + elif kl == 'enable-ha': + d['enable_ha'] = v[0] + return d + + +class AddMaintenanceWindow(argparse.Action): + def __call__(self, parser, namespace, values, option_string=None): + action = self.get_action(values, option_string) + namespace.maintenance_window = action + + def get_action(self, values, option_string): # pylint: disable=no-self-use + try: + properties = defaultdict(list) + for (k, v) in (x.split('=', 1) for x in values): + properties[k].append(v) + properties = dict(properties) + except ValueError: + raise CLIError('usage error: {} [KEY=VALUE ...]'.format(option_string)) + d = {} + for k in properties: + kl = k.lower() + v = properties[k] + if kl == 'custom-window': + d['custom_window'] = v[0] + elif kl == 'start-hour': + d['start_hour'] = v[0] + elif kl == 'start-minute': + d['start_minute'] = v[0] + elif kl == 'day-of-week': + d['day_of_week'] = v[0] + return d + + +class AddServerRoleGroupConfigurations(argparse._AppendAction): + def __call__(self, parser, namespace, values, option_string=None): + action = self.get_action(values, option_string) + super(AddServerRoleGroupConfigurations, self).__call__(parser, namespace, action, option_string) + + def get_action(self, values, option_string): # pylint: disable=no-self-use + try: + properties = defaultdict(list) + for (k, v) in (x.split('=', 1) for x in values): + properties[k].append(v) + properties = dict(properties) + except ValueError: + raise CLIError('usage error: {} [KEY=VALUE ...]'.format(option_string)) + d = {} + for k in properties: + kl = k.lower() + v = properties[k] + if kl == 'role': + d['role'] = v[0] + elif kl == 'value': + d['value'] = v[0] + return d diff --git a/src/postgresqlhsc/azext_postgresqlhsc/generated/commands.py b/src/postgresqlhsc/azext_postgresqlhsc/generated/commands.py new file mode 100644 index 00000000000..90f30fcd18d --- /dev/null +++ b/src/postgresqlhsc/azext_postgresqlhsc/generated/commands.py @@ -0,0 +1,79 @@ +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +# pylint: disable=too-many-statements +# pylint: disable=too-many-locals + +from azure.cli.core.commands import CliCommandType + + +def load_command_table(self, _): + + from azext_postgresqlhsc.generated._client_factory import cf_server_group + postgresqlhsc_server_group = CliCommandType( + operations_tmpl='azext_postgresqlhsc.vendored_sdks.postgresqlhsc.operations._server_group_operations#ServerGrou' + 'pOperations.{}', + client_factory=cf_server_group) + with self.command_group('postgresqlhsc server-group', postgresqlhsc_server_group, client_factory=cf_server_group, + is_experimental=True) as g: + g.custom_command('list', 'postgresqlhsc_server_group_list') + g.custom_show_command('show', 'postgresqlhsc_server_group_show') + g.custom_command('create', 'postgresqlhsc_server_group_create', supports_no_wait=True) + g.custom_command('update', 'postgresqlhsc_server_group_update', supports_no_wait=True) + g.custom_command('delete', 'postgresqlhsc_server_group_delete', supports_no_wait=True, confirmation=True) + g.custom_command('restart', 'postgresqlhsc_server_group_restart', supports_no_wait=True) + g.custom_command('start', 'postgresqlhsc_server_group_start', supports_no_wait=True) + g.custom_command('stop', 'postgresqlhsc_server_group_stop', supports_no_wait=True) + g.custom_wait_command('wait', 'postgresqlhsc_server_group_show') + + from azext_postgresqlhsc.generated._client_factory import cf_server + postgresqlhsc_server = CliCommandType( + operations_tmpl='azext_postgresqlhsc.vendored_sdks.postgresqlhsc.operations._server_operations#ServerOperations' + '.{}', + client_factory=cf_server) + with self.command_group('postgresqlhsc server', postgresqlhsc_server, client_factory=cf_server, + is_experimental=True) as g: + g.custom_command('list', 'postgresqlhsc_server_list') + g.custom_show_command('show', 'postgresqlhsc_server_show') + + from azext_postgresqlhsc.generated._client_factory import cf_configuration + postgresqlhsc_configuration = CliCommandType( + operations_tmpl='azext_postgresqlhsc.vendored_sdks.postgresqlhsc.operations._configuration_operations#Configura' + 'tionOperations.{}', + client_factory=cf_configuration) + with self.command_group('postgresqlhsc configuration', postgresqlhsc_configuration, + client_factory=cf_configuration, is_experimental=True) as g: + g.custom_command('list', 'postgresqlhsc_configuration_list') + g.custom_show_command('show', 'postgresqlhsc_configuration_show') + g.custom_command('update', 'postgresqlhsc_configuration_update', supports_no_wait=True) + g.custom_wait_command('wait', 'postgresqlhsc_configuration_show') + + from azext_postgresqlhsc.generated._client_factory import cf_firewall_rule + postgresqlhsc_firewall_rule = CliCommandType( + operations_tmpl='azext_postgresqlhsc.vendored_sdks.postgresqlhsc.operations._firewall_rule_operations#FirewallR' + 'uleOperations.{}', + client_factory=cf_firewall_rule) + with self.command_group('postgresqlhsc firewall-rule', postgresqlhsc_firewall_rule, + client_factory=cf_firewall_rule, is_experimental=True) as g: + g.custom_command('list', 'postgresqlhsc_firewall_rule_list') + g.custom_show_command('show', 'postgresqlhsc_firewall_rule_show') + g.custom_command('create', 'postgresqlhsc_firewall_rule_create', supports_no_wait=True) + g.custom_command('update', 'postgresqlhsc_firewall_rule_update', supports_no_wait=True) + g.custom_command('delete', 'postgresqlhsc_firewall_rule_delete', supports_no_wait=True, confirmation=True) + g.custom_wait_command('wait', 'postgresqlhsc_firewall_rule_show') + + from azext_postgresqlhsc.generated._client_factory import cf_role + postgresqlhsc_role = CliCommandType( + operations_tmpl='azext_postgresqlhsc.vendored_sdks.postgresqlhsc.operations._role_operations#RoleOperations.{}', + client_factory=cf_role) + with self.command_group('postgresqlhsc role', postgresqlhsc_role, client_factory=cf_role, + is_experimental=True) as g: + g.custom_command('list', 'postgresqlhsc_role_list') + g.custom_command('create', 'postgresqlhsc_role_create') + g.custom_command('delete', 'postgresqlhsc_role_delete', confirmation=True) diff --git a/src/postgresqlhsc/azext_postgresqlhsc/generated/custom.py b/src/postgresqlhsc/azext_postgresqlhsc/generated/custom.py new file mode 100644 index 00000000000..89c21713c10 --- /dev/null +++ b/src/postgresqlhsc/azext_postgresqlhsc/generated/custom.py @@ -0,0 +1,288 @@ +# -------------------------------------------------------------------------- +# 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. +# -------------------------------------------------------------------------- +# pylint: disable=too-many-lines + +from azure.cli.core.util import sdk_no_wait + + +def postgresqlhsc_server_group_list(client, + resource_group_name=None): + if resource_group_name: + return client.list_by_resource_group(resource_group_name=resource_group_name) + return client.list() + + +def postgresqlhsc_server_group_show(client, + resource_group_name, + server_group_name): + return client.get(resource_group_name=resource_group_name, + server_group_name=server_group_name) + + +def postgresqlhsc_server_group_create(client, + resource_group_name, + server_group_name, + location, + tags=None, + create_mode=None, + administrator_login=None, + administrator_login_password=None, + backup_retention_days=None, + postgresql_version=None, + citus_version=None, + enable_mx=None, + enable_zfs=None, + enable_shards_on_coordinator=None, + server_role_groups=None, + maintenance_window=None, + availability_zone=None, + standby_availability_zone=None, + source_subscription_id=None, + source_resource_group_name=None, + source_server_group_name=None, + source_location=None, + point_in_time_utc=None, + delegated_subnet_arguments_subnet_arm_resource_id=None, + no_wait=False): + return sdk_no_wait(no_wait, + client.begin_create_or_update, + resource_group_name=resource_group_name, + server_group_name=server_group_name, + tags=tags, + location=location, + create_mode=create_mode, + administrator_login=administrator_login, + administrator_login_password=administrator_login_password, + backup_retention_days=backup_retention_days, + postgresql_version=postgresql_version, + citus_version=citus_version, + enable_mx=enable_mx, + enable_zfs=enable_zfs, + enable_shards_on_coordinator=enable_shards_on_coordinator, + server_role_groups=server_role_groups, + maintenance_window=maintenance_window, + availability_zone=availability_zone, + standby_availability_zone=standby_availability_zone, + source_subscription_id=source_subscription_id, + source_resource_group_name=source_resource_group_name, + source_server_group_name=source_server_group_name, + source_location=source_location, + point_in_time_utc=point_in_time_utc, + subnet_arm_resource_id=delegated_subnet_arguments_subnet_arm_resource_id) + + +def postgresqlhsc_server_group_update(client, + resource_group_name, + server_group_name, + location=None, + tags=None, + administrator_login_password=None, + backup_retention_days=None, + postgresql_version=None, + citus_version=None, + enable_shards_on_coordinator=None, + server_role_groups=None, + maintenance_window=None, + availability_zone=None, + standby_availability_zone=None, + no_wait=False): + return sdk_no_wait(no_wait, + client.begin_update, + resource_group_name=resource_group_name, + server_group_name=server_group_name, + location=location, + tags=tags, + administrator_login_password=administrator_login_password, + backup_retention_days=backup_retention_days, + postgresql_version=postgresql_version, + citus_version=citus_version, + enable_shards_on_coordinator=enable_shards_on_coordinator, + server_role_groups=server_role_groups, + maintenance_window=maintenance_window, + availability_zone=availability_zone, + standby_availability_zone=standby_availability_zone) + + +def postgresqlhsc_server_group_delete(client, + resource_group_name, + server_group_name, + no_wait=False): + return sdk_no_wait(no_wait, + client.begin_delete, + resource_group_name=resource_group_name, + server_group_name=server_group_name) + + +def postgresqlhsc_server_group_restart(client, + resource_group_name, + server_group_name, + no_wait=False): + return sdk_no_wait(no_wait, + client.begin_restart, + resource_group_name=resource_group_name, + server_group_name=server_group_name) + + +def postgresqlhsc_server_group_start(client, + resource_group_name, + server_group_name, + no_wait=False): + return sdk_no_wait(no_wait, + client.begin_start, + resource_group_name=resource_group_name, + server_group_name=server_group_name) + + +def postgresqlhsc_server_group_stop(client, + resource_group_name, + server_group_name, + no_wait=False): + return sdk_no_wait(no_wait, + client.begin_stop, + resource_group_name=resource_group_name, + server_group_name=server_group_name) + + +def postgresqlhsc_server_list(client, + resource_group_name, + server_group_name): + return client.list_by_server_group(resource_group_name=resource_group_name, + server_group_name=server_group_name) + + +def postgresqlhsc_server_show(client, + resource_group_name, + server_group_name, + server_name): + return client.get(resource_group_name=resource_group_name, + server_group_name=server_group_name, + server_name=server_name) + + +def postgresqlhsc_configuration_list(client, + resource_group_name, + server_group_name, + server_name=None): + if resource_group_name and server_group_name is not None and server_name is not None: + return client.list_by_server(resource_group_name=resource_group_name, + server_group_name=server_group_name, + server_name=server_name) + return client.list_by_server_group(resource_group_name=resource_group_name, + server_group_name=server_group_name) + + +def postgresqlhsc_configuration_show(client, + resource_group_name, + server_group_name, + configuration_name): + return client.get(resource_group_name=resource_group_name, + server_group_name=server_group_name, + configuration_name=configuration_name) + + +def postgresqlhsc_configuration_update(client, + resource_group_name, + server_group_name, + configuration_name, + server_role_group_configurations=None, + no_wait=False): + return sdk_no_wait(no_wait, + client.begin_update, + resource_group_name=resource_group_name, + server_group_name=server_group_name, + configuration_name=configuration_name, + server_role_group_configurations=server_role_group_configurations) + + +def postgresqlhsc_firewall_rule_list(client, + resource_group_name, + server_group_name): + return client.list_by_server_group(resource_group_name=resource_group_name, + server_group_name=server_group_name) + + +def postgresqlhsc_firewall_rule_show(client, + resource_group_name, + server_group_name, + firewall_rule_name): + return client.get(resource_group_name=resource_group_name, + server_group_name=server_group_name, + firewall_rule_name=firewall_rule_name) + + +def postgresqlhsc_firewall_rule_create(client, + resource_group_name, + server_group_name, + firewall_rule_name, + start_ip_address, + end_ip_address, + no_wait=False): + return sdk_no_wait(no_wait, + client.begin_create_or_update, + resource_group_name=resource_group_name, + server_group_name=server_group_name, + firewall_rule_name=firewall_rule_name, + start_ip_address=start_ip_address, + end_ip_address=end_ip_address) + + +def postgresqlhsc_firewall_rule_update(client, + resource_group_name, + server_group_name, + firewall_rule_name, + start_ip_address, + end_ip_address, + no_wait=False): + return sdk_no_wait(no_wait, + client.begin_create_or_update, + resource_group_name=resource_group_name, + server_group_name=server_group_name, + firewall_rule_name=firewall_rule_name, + start_ip_address=start_ip_address, + end_ip_address=end_ip_address) + + +def postgresqlhsc_firewall_rule_delete(client, + resource_group_name, + server_group_name, + firewall_rule_name, + no_wait=False): + return sdk_no_wait(no_wait, + client.begin_delete, + resource_group_name=resource_group_name, + server_group_name=server_group_name, + firewall_rule_name=firewall_rule_name) + + +def postgresqlhsc_role_list(client, + resource_group_name, + server_group_name): + return client.list_by_server_group(resource_group_name=resource_group_name, + server_group_name=server_group_name) + + +def postgresqlhsc_role_create(client, + resource_group_name, + server_group_name, + role_name, + password=None): + return client.begin_create(resource_group_name=resource_group_name, + server_group_name=server_group_name, + role_name=role_name, + password=password) + + +def postgresqlhsc_role_delete(client, + resource_group_name, + server_group_name, + role_name): + return client.begin_delete(resource_group_name=resource_group_name, + server_group_name=server_group_name, + role_name=role_name) diff --git a/src/postgresqlhsc/azext_postgresqlhsc/manual/__init__.py b/src/postgresqlhsc/azext_postgresqlhsc/manual/__init__.py new file mode 100644 index 00000000000..c9cfdc73e77 --- /dev/null +++ b/src/postgresqlhsc/azext_postgresqlhsc/manual/__init__.py @@ -0,0 +1,12 @@ +# 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. +# -------------------------------------------------------------------------- + +__path__ = __import__('pkgutil').extend_path(__path__, __name__) diff --git a/src/postgresqlhsc/azext_postgresqlhsc/tests/__init__.py b/src/postgresqlhsc/azext_postgresqlhsc/tests/__init__.py new file mode 100644 index 00000000000..50e0627daff --- /dev/null +++ b/src/postgresqlhsc/azext_postgresqlhsc/tests/__init__.py @@ -0,0 +1,114 @@ +# 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 inspect +import logging +import os +import sys +import traceback +import datetime as dt + +from azure.core.exceptions import AzureError +from azure.cli.testsdk.exceptions import CliTestError, CliExecutionError, JMESPathCheckAssertionError + + +logger = logging.getLogger('azure.cli.testsdk') +logger.addHandler(logging.StreamHandler()) +__path__ = __import__('pkgutil').extend_path(__path__, __name__) +exceptions = [] +test_map = dict() +SUCCESSED = "successed" +FAILED = "failed" + + +def try_manual(func): + def import_manual_function(origin_func): + from importlib import import_module + decorated_path = inspect.getfile(origin_func) + module_path = __path__[0] + if not decorated_path.startswith(module_path): + raise Exception("Decorator can only be used in submodules!") + manual_path = os.path.join( + decorated_path[module_path.rfind(os.path.sep) + 1:]) + manual_file_path, manual_file_name = os.path.split(manual_path) + module_name, _ = os.path.splitext(manual_file_name) + manual_module = "..manual." + \ + ".".join(manual_file_path.split(os.path.sep) + [module_name, ]) + return getattr(import_module(manual_module, package=__name__), origin_func.__name__) + + def get_func_to_call(): + func_to_call = func + try: + func_to_call = import_manual_function(func) + func_to_call = import_manual_function(func) + logger.info("Found manual override for %s(...)", func.__name__) + except (ImportError, AttributeError): + pass + return func_to_call + + def wrapper(*args, **kwargs): + func_to_call = get_func_to_call() + logger.info("running %s()...", func.__name__) + try: + test_map[func.__name__] = dict() + test_map[func.__name__]["result"] = SUCCESSED + test_map[func.__name__]["error_message"] = "" + test_map[func.__name__]["error_stack"] = "" + test_map[func.__name__]["error_normalized"] = "" + test_map[func.__name__]["start_dt"] = dt.datetime.utcnow() + ret = func_to_call(*args, **kwargs) + except (AssertionError, AzureError, CliTestError, CliExecutionError, SystemExit, + JMESPathCheckAssertionError) as e: + test_map[func.__name__]["end_dt"] = dt.datetime.utcnow() + test_map[func.__name__]["result"] = FAILED + test_map[func.__name__]["error_message"] = str(e).replace("\r\n", " ").replace("\n", " ")[:500] + test_map[func.__name__]["error_stack"] = traceback.format_exc().replace( + "\r\n", " ").replace("\n", " ")[:500] + logger.info("--------------------------------------") + logger.info("step exception: %s", e) + logger.error("--------------------------------------") + logger.error("step exception in %s: %s", func.__name__, e) + logger.info(traceback.format_exc()) + exceptions.append((func.__name__, sys.exc_info())) + else: + test_map[func.__name__]["end_dt"] = dt.datetime.utcnow() + return ret + + if inspect.isclass(func): + return get_func_to_call() + return wrapper + + +def calc_coverage(filename): + filename = filename.split(".")[0] + coverage_name = filename + "_coverage.md" + with open(coverage_name, "w") as f: + f.write("|Scenario|Result|ErrorMessage|ErrorStack|ErrorNormalized|StartDt|EndDt|\n") + total = len(test_map) + covered = 0 + for k, v in test_map.items(): + if not k.startswith("step_"): + total -= 1 + continue + if v["result"] == SUCCESSED: + covered += 1 + f.write("|{step_name}|{result}|{error_message}|{error_stack}|{error_normalized}|{start_dt}|" + "{end_dt}|\n".format(step_name=k, **v)) + f.write("Coverage: {}/{}\n".format(covered, total)) + print("Create coverage\n", file=sys.stderr) + + +def raise_if(): + if exceptions: + if len(exceptions) <= 1: + raise exceptions[0][1][1] + message = "{}\nFollowed with exceptions in other steps:\n".format(str(exceptions[0][1][1])) + message += "\n".join(["{}: {}".format(h[0], h[1][1]) for h in exceptions[1:]]) + raise exceptions[0][1][0](message).with_traceback(exceptions[0][1][2]) diff --git a/src/postgresqlhsc/azext_postgresqlhsc/tests/latest/__init__.py b/src/postgresqlhsc/azext_postgresqlhsc/tests/latest/__init__.py new file mode 100644 index 00000000000..c9cfdc73e77 --- /dev/null +++ b/src/postgresqlhsc/azext_postgresqlhsc/tests/latest/__init__.py @@ -0,0 +1,12 @@ +# 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. +# -------------------------------------------------------------------------- + +__path__ = __import__('pkgutil').extend_path(__path__, __name__) diff --git a/src/postgresqlhsc/azext_postgresqlhsc/tests/latest/test_postgresqlhsc_scenario.py b/src/postgresqlhsc/azext_postgresqlhsc/tests/latest/test_postgresqlhsc_scenario.py new file mode 100644 index 00000000000..485ac83ad14 --- /dev/null +++ b/src/postgresqlhsc/azext_postgresqlhsc/tests/latest/test_postgresqlhsc_scenario.py @@ -0,0 +1,412 @@ +# -------------------------------------------------------------------------- +# 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 os +from azure.cli.testsdk import ScenarioTest +from .. import try_manual, raise_if, calc_coverage +from azure.cli.testsdk import ResourceGroupPreparer + + +TEST_DIR = os.path.abspath(os.path.join(os.path.abspath(__file__), '..')) + + +# Env setup +@try_manual +def setup(test, rg, rg_2): + pass + + +# EXAMPLE: Create a new server group +@try_manual +def step_create_a_new_server_group(test, rg, rg_2): + test.cmd('az postgresqlhsc server-group create ' + '--location "westus" ' + '--administrator-login "citus" ' + '--administrator-login-password "password" ' + '--availability-zone "1" ' + '--backup-retention-days 35 ' + '--citus-version "9.5" ' + '--enable-mx true ' + '--enable-zfs false ' + '--postgresql-version "12" ' + '--server-role-groups name="" enable-ha=true role="Coordinator" server-count=1 ' + 'server-edition="GeneralPurpose" storage-quota-in-mb=524288 v-cores=4 ' + '--server-role-groups name="" enable-ha=false role="Worker" server-count=3 server-edition="MemoryOptimized' + '" storage-quota-in-mb=524288 v-cores=4 ' + '--standby-availability-zone "2" ' + '--tags ElasticServer="1" ' + '--resource-group "{rg}" ' + '--name "{myServerGroup2}"', + checks=[ + test.check("name", "{myServerGroup2}", case_sensitive=False), + ]) + + +# EXAMPLE: Create a new server group as a point in time restore +@try_manual +def step_create_a_new(test, rg, rg_2): + test.cmd('az postgresqlhsc server-group create ' + '--location "westus" ' + '--create-mode "PointInTimeRestore" ' + '--enable-mx true ' + '--enable-zfs false ' + '--point-in-time-utc "2017-12-14T00:00:37.467Z" ' + '--source-location "eastus" ' + '--source-resource-group-name "SourceGroup" ' + '--source-server-group-name "pgtests-source-server-group" ' + '--source-subscription-id "dddddddd-dddd-dddd-dddd-dddddddddddd" ' + '--resource-group "{rg}" ' + '--name "{myServerGroup2}"', + checks=[ + test.check("name", "{myServerGroup2}", case_sensitive=False), + ]) + + +# EXAMPLE: Update the server group +@try_manual +def step_update_the_server_group(test, rg, rg_2): + test.cmd('az postgresqlhsc server-group update ' + '--administrator-login-password "secret" ' + '--backup-retention-days 30 ' + '--postgresql-version "12" ' + '--server-role-groups name="" enable-ha=false role="Coordinator" server-count=1 ' + 'server-edition="GeneralPurpose" storage-quota-in-mb=1048576 v-cores=8 ' + '--server-role-groups name="" enable-ha=true role="Worker" server-count=4 server-edition="MemoryOptimized"' + ' storage-quota-in-mb=524288 v-cores=4 ' + '--tags ElasticServer="2" ' + '--resource-group "{rg}" ' + '--name "{myServerGroup2}"', + checks=[ + test.check("name", "{myServerGroup2}", case_sensitive=False), + ]) + + +# EXAMPLE: Get the server group +@try_manual +def step_get_the_server_group(test, rg, rg_2): + test.cmd('az postgresqlhsc server-group show ' + '--resource-group "{rg}" ' + '--name "{myServerGroup}"', + checks=[]) + + +# EXAMPLE: Delete the server group +@try_manual +def step_delete_the_server_group(test, rg, rg_2): + test.cmd('az postgresqlhsc server-group delete -y ' + '--resource-group "{rg}" ' + '--name "{myServerGroup3}"', + checks=[]) + + +# EXAMPLE: Scale compute +@try_manual +def step_scale_compute(test, rg, rg_2): + test.cmd('az postgresqlhsc server-group update ' + '--location "westus" ' + '--server-role-groups name="" role="Coordinator" v-cores=16 ' + '--resource-group "{rg}" ' + '--name "{myServerGroup2}"', + checks=[ + test.check("name", "{myServerGroup2}", case_sensitive=False), + ]) + + +# EXAMPLE: Scale storage +@try_manual +def step_scale_storage(test, rg, rg_2): + test.cmd('az postgresqlhsc server-group update ' + '--location "westus" ' + '--server-role-groups name="" role="Worker" storage-quota-in-mb=8388608 ' + '--resource-group "{rg}" ' + '--name "{myServerGroup2}"', + checks=[ + test.check("name", "{myServerGroup2}", case_sensitive=False), + ]) + + +# EXAMPLE: Add new worker nodes +@try_manual +def step_add_new_worker_nodes(test, rg, rg_2): + test.cmd('az postgresqlhsc server-group update ' + '--location "westus" ' + '--server-role-groups name="" role="Worker" server-count=10 ' + '--resource-group "{rg}" ' + '--name "{myServerGroup2}"', + checks=[ + test.check("name", "{myServerGroup2}", case_sensitive=False), + ]) + + +# EXAMPLE: Update customer maintenance window +@try_manual +def step_update_customer_maintenance_window(test, rg, rg_2): + test.cmd('az postgresqlhsc server-group update ' + '--maintenance-window custom-window="Enabled" day-of-week=0 start-hour=8 start-minute=0 ' + '--resource-group "{rg}" ' + '--name "{myServerGroup2}"', + checks=[ + test.check("name", "{myServerGroup2}", case_sensitive=False), + ]) + + +# EXAMPLE: List servers of the server group +@try_manual +def step_list_servers_of_the_server_group(test, rg, rg_2): + test.cmd('az postgresqlhsc server list ' + '--resource-group "{rg}" ' + '--server-group-name "{myServerGroup}"', + checks=[]) + + +# EXAMPLE: Get the server of server group +@try_manual +def step_get_the_server_of_server_group(test, rg, rg_2): + test.cmd('az postgresqlhsc server show ' + '--resource-group "{rg}" ' + '--server-group-name "{myServerGroup}" ' + '--name "{myServer}"', + checks=[]) + + +# EXAMPLE: List configurations of the server that in the server group +@try_manual +def step_list_configurations_of(test, rg, rg_2): + test.cmd('az postgresqlhsc configuration list ' + '--resource-group "{rg_2}" ' + '--server-group-name "{myServerGroup2}" ' + '--server-name "{myServer2}"', + checks=[]) + + +# EXAMPLE: Update configurations of the server group +@try_manual +def step_update_configurations_of_the_server_group(test, rg, rg_2): + # EXAMPLE NOT FOUND! + pass + + +# EXAMPLE: List configurations of the server group +@try_manual +def step_list_configurations_of_the_server_group(test, rg, rg_2): + test.cmd('az postgresqlhsc configuration list ' + '--resource-group "{rg_2}" ' + '--server-group-name "{myServerGroup2}"', + checks=[]) + + +# EXAMPLE: Update single configuration of the server group +@try_manual +def step_update_single_configuration(test, rg, rg_2): + test.cmd('az postgresqlhsc configuration update ' + '--name "{myConfiguration}" ' + '--server-role-group-configurations role="Coordinator" value="on" ' + '--server-role-group-configurations role="Worker" value="off" ' + '--resource-group "{rg_2}" ' + '--server-group-name "{myServerGroup2}"', + checks=[ + test.check("name", "{myConfiguration}", case_sensitive=False), + ]) + + +# EXAMPLE: Get single configuration of the server group +@try_manual +def step_get_single_configuration_of_the_server_group(test, rg, rg_2): + test.cmd('az postgresqlhsc configuration show ' + '--name "{myConfiguration}" ' + '--resource-group "{rg_2}" ' + '--server-group-name "{myServerGroup2}"', + checks=[ + test.check("name", "{myConfiguration}", case_sensitive=False), + ]) + + +# EXAMPLE: Create a firewall rule of the server group +@try_manual +def step_create_a_firewall_rule_of_the_server_group(test, rg, rg_2): + test.cmd('az postgresqlhsc firewall-rule create ' + '--name "{myFirewallRule}" ' + '--end-ip-address "255.255.255.255" ' + '--start-ip-address "0.0.0.0" ' + '--resource-group "{rg}" ' + '--server-group-name "{myServerGroup4}"', + checks=[ + test.check("name", "{myFirewallRule}", case_sensitive=False), + test.check("endIpAddress", "255.255.255.255", case_sensitive=False), + test.check("startIpAddress", "0.0.0.0", case_sensitive=False), + ]) + + +# EXAMPLE: Delete the firewall rule of the server group +@try_manual +def step_delete_the_firewall_rule_of_the_server_group(test, rg, rg_2): + test.cmd('az postgresqlhsc firewall-rule delete -y ' + '--name "{myFirewallRule}" ' + '--resource-group "{rg}" ' + '--server-group-name "{myServerGroup4}"', + checks=[]) + + +# EXAMPLE: Get the firewall rule of the server group +@try_manual +def step_get_the_firewall_rule_of_the_server_group(test, rg, rg_2): + test.cmd('az postgresqlhsc firewall-rule show ' + '--name "{myFirewallRule}" ' + '--resource-group "{rg}" ' + '--server-group-name "{myServerGroup4}"', + checks=[]) + + +# EXAMPLE: List firewall rules of the server group +@try_manual +def step_list_firewall_rules_of_the_server_group(test, rg, rg_2): + test.cmd('az postgresqlhsc firewall-rule list ' + '--resource-group "{rg}" ' + '--server-group-name "{myServerGroup4}"', + checks=[]) + + +# EXAMPLE: RoleCreate +@try_manual +def step_rolecreate(test, rg, rg_2): + test.cmd('az postgresqlhsc role create ' + '--password "secret" ' + '--resource-group "{rg}" ' + '--name "{myRole}" ' + '--server-group-name "{myServerGroup4}"', + checks=[ + test.check("name", "{myRole}", case_sensitive=False), + ]) + + +# EXAMPLE: RoleDelete +@try_manual +def step_roledelete(test, rg, rg_2): + test.cmd('az postgresqlhsc role delete -y ' + '--resource-group "{rg}" ' + '--name "{myRole}" ' + '--server-group-name "{myServerGroup4}"', + checks=[]) + + +# EXAMPLE: RoleList +@try_manual +def step_rolelist(test, rg, rg_2): + test.cmd('az postgresqlhsc role list ' + '--resource-group "{rg}" ' + '--server-group-name "{myServerGroup4}"', + checks=[]) + + +# EXAMPLE: Restart all servers in the server group +@try_manual +def step_restart_all_servers_in_the_server_group(test, rg, rg_2): + test.cmd('az postgresqlhsc server-group restart ' + '--resource-group "{rg}" ' + '--name "{myServerGroup}"', + checks=[]) + + +# EXAMPLE: Start all servers in the server group +@try_manual +def step_start_all_servers_in_the_server_group(test, rg, rg_2): + test.cmd('az postgresqlhsc server-group start ' + '--resource-group "{rg}" ' + '--name "{myServerGroup}"', + checks=[]) + + +# EXAMPLE: Stop all servers in the server group +@try_manual +def step_stop_all_servers_in_the_server_group(test, rg, rg_2): + test.cmd('az postgresqlhsc server-group stop ' + '--resource-group "{rg}" ' + '--name "{myServerGroup}"', + checks=[]) + + +# EXAMPLE: Check name availability +@try_manual +def step_check_name_availability(test, rg, rg_2): + # EXAMPLE NOT FOUND! + pass + + +# EXAMPLE: List all available operations +@try_manual +def step_list_all_available_operations(test, rg, rg_2): + # EXAMPLE NOT FOUND! + pass + + +# Env cleanup +@try_manual +def cleanup(test, rg, rg_2): + pass + + +# Testcase +@try_manual +def call_scenario(test, rg, rg_2): + setup(test, rg, rg_2) + step_create_a_new_server_group(test, rg, rg_2) + step_create_a_new(test, rg, rg_2) + step_update_the_server_group(test, rg, rg_2) + step_get_the_server_group(test, rg, rg_2) + step_delete_the_server_group(test, rg, rg_2) + step_scale_compute(test, rg, rg_2) + step_scale_storage(test, rg, rg_2) + step_add_new_worker_nodes(test, rg, rg_2) + step_update_customer_maintenance_window(test, rg, rg_2) + step_list_servers_of_the_server_group(test, rg, rg_2) + step_get_the_server_of_server_group(test, rg, rg_2) + step_list_configurations_of(test, rg, rg_2) + step_update_configurations_of_the_server_group(test, rg, rg_2) + step_list_configurations_of_the_server_group(test, rg, rg_2) + step_update_single_configuration(test, rg, rg_2) + step_get_single_configuration_of_the_server_group(test, rg, rg_2) + step_create_a_firewall_rule_of_the_server_group(test, rg, rg_2) + step_delete_the_firewall_rule_of_the_server_group(test, rg, rg_2) + step_get_the_firewall_rule_of_the_server_group(test, rg, rg_2) + step_list_firewall_rules_of_the_server_group(test, rg, rg_2) + step_rolecreate(test, rg, rg_2) + step_roledelete(test, rg, rg_2) + step_rolelist(test, rg, rg_2) + step_restart_all_servers_in_the_server_group(test, rg, rg_2) + step_start_all_servers_in_the_server_group(test, rg, rg_2) + step_stop_all_servers_in_the_server_group(test, rg, rg_2) + step_check_name_availability(test, rg, rg_2) + step_list_all_available_operations(test, rg, rg_2) + cleanup(test, rg, rg_2) + + +@try_manual +class MicrosoftPostgreSQLHyperscaleScenarioTest(ScenarioTest): + + @ResourceGroupPreparer(name_prefix='clitestpostgresqlhsc_TestGroup'[:7], key='rg', parameter_name='rg') + @ResourceGroupPreparer(name_prefix='clitestpostgresqlhsc_TestResourceGroup'[:7], key='rg_2', + parameter_name='rg_2') + def test_postgresqlhsc(self, rg, rg_2): + + self.kwargs.update({ + 'myServerGroup': 'hsctestsg1', + 'myServerGroup2': 'hsctestsg', + 'myServerGroup3': 'testservergroup', + 'myServerGroup4': 'pgtestsvc4', + 'myServer': 'hsctestsg1-c', + 'myServer2': 'testserver', + 'myConfiguration': 'array_nulls', + 'myFirewallRule': 'rule1', + 'myRole': 'role1', + }) + + call_scenario(self, rg, rg_2) + calc_coverage(__file__) + raise_if() diff --git a/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/__init__.py b/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/__init__.py new file mode 100644 index 00000000000..c9cfdc73e77 --- /dev/null +++ b/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/__init__.py @@ -0,0 +1,12 @@ +# 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. +# -------------------------------------------------------------------------- + +__path__ = __import__('pkgutil').extend_path(__path__, __name__) diff --git a/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/postgresqlhsc/__init__.py b/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/postgresqlhsc/__init__.py new file mode 100644 index 00000000000..6b1211b2b87 --- /dev/null +++ b/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/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/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/postgresqlhsc/_configuration.py b/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/postgresqlhsc/_configuration.py new file mode 100644 index 00000000000..19fc8e41477 --- /dev/null +++ b/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/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', 'microsoftpostgresqlhyperscale/{}'.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/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/postgresqlhsc/_microsoft_postgre_sql_hyperscale.py b/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/postgresqlhsc/_microsoft_postgre_sql_hyperscale.py new file mode 100644 index 00000000000..aa95a949a90 --- /dev/null +++ b/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/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 ServerGroupOperations +from .operations import ServerOperations +from .operations import ConfigurationOperations +from .operations import FirewallRuleOperations +from .operations import RoleOperations +from .operations import OperationOperations +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_group: ServerGroupOperations operations + :vartype server_group: azure.mgmt.rdbms.postgresqlhsc.operations.ServerGroupOperations + :ivar server: ServerOperations operations + :vartype server: azure.mgmt.rdbms.postgresqlhsc.operations.ServerOperations + :ivar configuration: ConfigurationOperations operations + :vartype configuration: azure.mgmt.rdbms.postgresqlhsc.operations.ConfigurationOperations + :ivar firewall_rule: FirewallRuleOperations operations + :vartype firewall_rule: azure.mgmt.rdbms.postgresqlhsc.operations.FirewallRuleOperations + :ivar role: RoleOperations operations + :vartype role: azure.mgmt.rdbms.postgresqlhsc.operations.RoleOperations + :ivar operation: OperationOperations operations + :vartype operation: azure.mgmt.rdbms.postgresqlhsc.operations.OperationOperations + :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_group = ServerGroupOperations( + self._client, self._config, self._serialize, self._deserialize) + self.server = ServerOperations( + self._client, self._config, self._serialize, self._deserialize) + self.configuration = ConfigurationOperations( + self._client, self._config, self._serialize, self._deserialize) + self.firewall_rule = FirewallRuleOperations( + self._client, self._config, self._serialize, self._deserialize) + self.role = RoleOperations( + self._client, self._config, self._serialize, self._deserialize) + self.operation = OperationOperations( + 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/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/postgresqlhsc/aio/__init__.py b/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/postgresqlhsc/aio/__init__.py new file mode 100644 index 00000000000..e7b00ed4c21 --- /dev/null +++ b/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/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/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/postgresqlhsc/aio/_configuration.py b/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/postgresqlhsc/aio/_configuration.py new file mode 100644 index 00000000000..bc8a37ff6d6 --- /dev/null +++ b/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/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', 'microsoftpostgresqlhyperscale/{}'.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/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/postgresqlhsc/aio/_microsoft_postgre_sql_hyperscale.py b/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/postgresqlhsc/aio/_microsoft_postgre_sql_hyperscale.py new file mode 100644 index 00000000000..52152c8b90a --- /dev/null +++ b/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/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 ServerGroupOperations +from .operations import ServerOperations +from .operations import ConfigurationOperations +from .operations import FirewallRuleOperations +from .operations import RoleOperations +from .operations import OperationOperations +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_group: ServerGroupOperations operations + :vartype server_group: azure.mgmt.rdbms.postgresqlhsc.aio.operations.ServerGroupOperations + :ivar server: ServerOperations operations + :vartype server: azure.mgmt.rdbms.postgresqlhsc.aio.operations.ServerOperations + :ivar configuration: ConfigurationOperations operations + :vartype configuration: azure.mgmt.rdbms.postgresqlhsc.aio.operations.ConfigurationOperations + :ivar firewall_rule: FirewallRuleOperations operations + :vartype firewall_rule: azure.mgmt.rdbms.postgresqlhsc.aio.operations.FirewallRuleOperations + :ivar role: RoleOperations operations + :vartype role: azure.mgmt.rdbms.postgresqlhsc.aio.operations.RoleOperations + :ivar operation: OperationOperations operations + :vartype operation: azure.mgmt.rdbms.postgresqlhsc.aio.operations.OperationOperations + :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_group = ServerGroupOperations( + self._client, self._config, self._serialize, self._deserialize) + self.server = ServerOperations( + self._client, self._config, self._serialize, self._deserialize) + self.configuration = ConfigurationOperations( + self._client, self._config, self._serialize, self._deserialize) + self.firewall_rule = FirewallRuleOperations( + self._client, self._config, self._serialize, self._deserialize) + self.role = RoleOperations( + self._client, self._config, self._serialize, self._deserialize) + self.operation = OperationOperations( + 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/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/postgresqlhsc/aio/operations/__init__.py b/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/postgresqlhsc/aio/operations/__init__.py new file mode 100644 index 00000000000..1be1614a899 --- /dev/null +++ b/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/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_group_operations import ServerGroupOperations +from ._server_operations import ServerOperations +from ._configuration_operations import ConfigurationOperations +from ._firewall_rule_operations import FirewallRuleOperations +from ._role_operations import RoleOperations +from ._operation_operations import OperationOperations + +__all__ = [ + 'ServerGroupOperations', + 'ServerOperations', + 'ConfigurationOperations', + 'FirewallRuleOperations', + 'RoleOperations', + 'OperationOperations', +] diff --git a/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/postgresqlhsc/aio/operations/_configuration_operations.py b/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/postgresqlhsc/aio/operations/_configuration_operations.py new file mode 100644 index 00000000000..62ba8b9788b --- /dev/null +++ b/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/postgresqlhsc/aio/operations/_configuration_operations.py @@ -0,0 +1,393 @@ +# 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, List, 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 + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ConfigurationOperations: + """ConfigurationOperations 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, + server_role_group_configurations: Optional[List["models.ServerRoleGroupConfiguration"]] = None, + **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', {})) + + parameters = models.ServerGroupConfiguration(server_role_group_configurations=server_role_group_configurations) + 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, + server_role_group_configurations: Optional[List["models.ServerRoleGroupConfiguration"]] = None, + **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 server_role_group_configurations: The list of server role group configuration values. + :type server_role_group_configurations: list[~azure.mgmt.rdbms.postgresqlhsc.models.ServerRoleGroupConfiguration] + :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, + server_role_group_configurations=server_role_group_configurations, + 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/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/postgresqlhsc/aio/operations/_firewall_rule_operations.py b/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/postgresqlhsc/aio/operations/_firewall_rule_operations.py new file mode 100644 index 00000000000..907c15b17d6 --- /dev/null +++ b/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/postgresqlhsc/aio/operations/_firewall_rule_operations.py @@ -0,0 +1,440 @@ +# 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 + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class FirewallRuleOperations: + """FirewallRuleOperations 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, + start_ip_address: str, + end_ip_address: str, + **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', {})) + + parameters = models.FirewallRule(start_ip_address=start_ip_address, end_ip_address=end_ip_address) + 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, + start_ip_address: str, + end_ip_address: str, + **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 start_ip_address: The start IP address of the server group firewall rule. Must be IPv4 + format. + :type start_ip_address: str + :param end_ip_address: The end IP address of the server group firewall rule. Must be IPv4 + format. + :type end_ip_address: 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 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, + start_ip_address=start_ip_address, + end_ip_address=end_ip_address, + 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/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/postgresqlhsc/aio/operations/_operation_operations.py b/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/postgresqlhsc/aio/operations/_operation_operations.py new file mode 100644 index 00000000000..523a43f2647 --- /dev/null +++ b/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/postgresqlhsc/aio/operations/_operation_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 + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class OperationOperations: + """OperationOperations 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/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/postgresqlhsc/aio/operations/_role_operations.py b/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/postgresqlhsc/aio/operations/_role_operations.py new file mode 100644 index 00000000000..532ffd02d7e --- /dev/null +++ b/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/postgresqlhsc/aio/operations/_role_operations.py @@ -0,0 +1,371 @@ +# 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 + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class RoleOperations: + """RoleOperations 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, + password: Optional[str] = None, + **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', {})) + + parameters = models.Role(password=password) + 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, + password: Optional[str] = None, + **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 password: The password of the server group role. + :type password: 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 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, + password=password, + 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/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/postgresqlhsc/aio/operations/_server_group_operations.py b/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/postgresqlhsc/aio/operations/_server_group_operations.py new file mode 100644 index 00000000000..72ff9407fcc --- /dev/null +++ b/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/postgresqlhsc/aio/operations/_server_group_operations.py @@ -0,0 +1,1149 @@ +# 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 Any, AsyncIterable, Callable, Dict, Generic, List, 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 + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ServerGroupOperations: + """ServerGroupOperations 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, + location: str, + tags: Optional[Dict[str, str]] = None, + create_mode: Optional[Union[str, "models.CreateMode"]] = None, + administrator_login: Optional[str] = None, + administrator_login_password: Optional[str] = None, + backup_retention_days: Optional[int] = None, + postgresql_version: Optional[Union[str, "models.PostgreSQLVersion"]] = None, + citus_version: Optional[Union[str, "models.CitusVersion"]] = None, + enable_mx: Optional[bool] = None, + enable_zfs: Optional[bool] = None, + enable_shards_on_coordinator: Optional[bool] = None, + server_role_groups: Optional[List["models.ServerRoleGroup"]] = None, + maintenance_window: Optional["models.MaintenanceWindow"] = None, + availability_zone: Optional[str] = None, + standby_availability_zone: Optional[str] = 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, + subnet_arm_resource_id: Optional[str] = None, + **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', {})) + + parameters = models.ServerGroup(tags=tags, location=location, create_mode=create_mode, administrator_login=administrator_login, administrator_login_password=administrator_login_password, backup_retention_days=backup_retention_days, postgresql_version=postgresql_version, citus_version=citus_version, enable_mx=enable_mx, enable_zfs=enable_zfs, enable_shards_on_coordinator=enable_shards_on_coordinator, server_role_groups=server_role_groups, maintenance_window=maintenance_window, availability_zone=availability_zone, standby_availability_zone=standby_availability_zone, source_subscription_id=source_subscription_id, source_resource_group_name=source_resource_group_name, source_server_group_name=source_server_group_name, source_location=source_location, point_in_time_utc=point_in_time_utc, subnet_arm_resource_id=subnet_arm_resource_id) + 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, + location: str, + tags: Optional[Dict[str, str]] = None, + create_mode: Optional[Union[str, "models.CreateMode"]] = None, + administrator_login: Optional[str] = None, + administrator_login_password: Optional[str] = None, + backup_retention_days: Optional[int] = None, + postgresql_version: Optional[Union[str, "models.PostgreSQLVersion"]] = None, + citus_version: Optional[Union[str, "models.CitusVersion"]] = None, + enable_mx: Optional[bool] = None, + enable_zfs: Optional[bool] = None, + enable_shards_on_coordinator: Optional[bool] = None, + server_role_groups: Optional[List["models.ServerRoleGroup"]] = None, + maintenance_window: Optional["models.MaintenanceWindow"] = None, + availability_zone: Optional[str] = None, + standby_availability_zone: Optional[str] = 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, + subnet_arm_resource_id: Optional[str] = None, + **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 location: The geo-location where the resource lives. + :type location: str + :param tags: Resource tags. + :type tags: dict[str, str] + :param create_mode: The mode to create a new server group. + :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. + :type postgresql_version: str or ~azure.mgmt.rdbms.postgresqlhsc.models.PostgreSQLVersion + :param citus_version: The Citus version of server group. + :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 + :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 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 + :param subnet_arm_resource_id: delegated subnet arm resource id. + :type subnet_arm_resource_id: 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 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, + location=location, + tags=tags, + create_mode=create_mode, + administrator_login=administrator_login, + administrator_login_password=administrator_login_password, + backup_retention_days=backup_retention_days, + postgresql_version=postgresql_version, + citus_version=citus_version, + enable_mx=enable_mx, + enable_zfs=enable_zfs, + enable_shards_on_coordinator=enable_shards_on_coordinator, + server_role_groups=server_role_groups, + maintenance_window=maintenance_window, + availability_zone=availability_zone, + standby_availability_zone=standby_availability_zone, + source_subscription_id=source_subscription_id, + source_resource_group_name=source_resource_group_name, + source_server_group_name=source_server_group_name, + source_location=source_location, + point_in_time_utc=point_in_time_utc, + subnet_arm_resource_id=subnet_arm_resource_id, + 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, + 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, "models.PostgreSQLVersion"]] = None, + citus_version: Optional[Union[str, "models.CitusVersion"]] = None, + enable_shards_on_coordinator: Optional[bool] = None, + server_role_groups: Optional[List["models.ServerRoleGroup"]] = None, + maintenance_window: Optional["models.MaintenanceWindow"] = None, + availability_zone: Optional[str] = None, + standby_availability_zone: Optional[str] = None, + **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', {})) + + parameters = models.ServerGroupForUpdate(location=location, tags=tags, administrator_login_password=administrator_login_password, backup_retention_days=backup_retention_days, postgresql_version=postgresql_version, citus_version=citus_version, enable_shards_on_coordinator=enable_shards_on_coordinator, server_role_groups=server_role_groups, maintenance_window=maintenance_window, availability_zone=availability_zone, standby_availability_zone=standby_availability_zone) + 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, + 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, "models.PostgreSQLVersion"]] = None, + citus_version: Optional[Union[str, "models.CitusVersion"]] = None, + enable_shards_on_coordinator: Optional[bool] = None, + server_role_groups: Optional[List["models.ServerRoleGroup"]] = None, + maintenance_window: Optional["models.MaintenanceWindow"] = None, + availability_zone: Optional[str] = None, + standby_availability_zone: Optional[str] = None, + **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 location: The location the resource resides in. + :type location: str + :param 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. + :type postgresql_version: str or ~azure.mgmt.rdbms.postgresqlhsc.models.PostgreSQLVersion + :param citus_version: The Citus version of server group. + :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 + :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, + location=location, + tags=tags, + administrator_login_password=administrator_login_password, + backup_retention_days=backup_retention_days, + postgresql_version=postgresql_version, + citus_version=citus_version, + enable_shards_on_coordinator=enable_shards_on_coordinator, + server_role_groups=server_role_groups, + maintenance_window=maintenance_window, + availability_zone=availability_zone, + standby_availability_zone=standby_availability_zone, + 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: str, + **kwargs + ) -> "models.NameAvailability": + """Check the availability of name for resource. + + :param name: Resource name to verify. + :type name: str + :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', {})) + + name_availability_request = models.NameAvailabilityRequest(name=name) + 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/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/postgresqlhsc/aio/operations/_server_operations.py b/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/postgresqlhsc/aio/operations/_server_operations.py new file mode 100644 index 00000000000..be31c11cc68 --- /dev/null +++ b/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/postgresqlhsc/aio/operations/_server_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 + +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class ServerOperations: + """ServerOperations 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/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/postgresqlhsc/models/__init__.py b/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/postgresqlhsc/models/__init__.py new file mode 100644 index 00000000000..c30704916ad --- /dev/null +++ b/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/postgresqlhsc/models/__init__.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. +# -------------------------------------------------------------------------- + +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 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 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', + 'ServerGroupServer', + 'ServerGroupServerListResult', + 'ServerGroupServerProperties', + 'ServerNameItem', + 'ServerProperties', + 'ServerRoleGroup', + 'ServerRoleGroupConfiguration', + 'SystemData', + 'TrackedResource', + 'CitusVersion', + 'ConfigurationDataType', + 'CreateMode', + 'CreatedByType', + 'OperationOrigin', + 'PostgreSQLVersion', + 'ResourceProviderType', + 'ServerEdition', + 'ServerHaState', + 'ServerRole', + 'ServerState', +] diff --git a/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/postgresqlhsc/models/_microsoft_postgre_sql_hyperscale_enums.py b/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/postgresqlhsc/models/_microsoft_postgre_sql_hyperscale_enums.py new file mode 100644 index 00000000000..e5730047307 --- /dev/null +++ b/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/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/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/postgresqlhsc/models/_models.py b/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/postgresqlhsc/models/_models.py new file mode 100644 index 00000000000..cda217378d8 --- /dev/null +++ b/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/postgresqlhsc/models/_models.py @@ -0,0 +1,1357 @@ +# 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 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 + :param subnet_arm_resource_id: delegated subnet arm resource id. + :type subnet_arm_resource_id: str + """ + + _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'}, + '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'}, + 'subnet_arm_resource_id': {'key': 'delegatedSubnetArguments.subnetArmResourceId', 'type': 'str'}, + } + + 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.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) + self.subnet_arm_resource_id = kwargs.get('subnet_arm_resource_id', 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 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/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/postgresqlhsc/models/_models_py3.py b/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/postgresqlhsc/models/_models_py3.py new file mode 100644 index 00000000000..0d4529707c6 --- /dev/null +++ b/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/postgresqlhsc/models/_models_py3.py @@ -0,0 +1,1488 @@ +# 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 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 + :param subnet_arm_resource_id: delegated subnet arm resource id. + :type subnet_arm_resource_id: str + """ + + _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'}, + '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'}, + 'subnet_arm_resource_id': {'key': 'delegatedSubnetArguments.subnetArmResourceId', 'type': 'str'}, + } + + 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, + 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, + subnet_arm_resource_id: Optional[str] = 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.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 + self.subnet_arm_resource_id = subnet_arm_resource_id + + +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 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/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/postgresqlhsc/operations/__init__.py b/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/postgresqlhsc/operations/__init__.py new file mode 100644 index 00000000000..1be1614a899 --- /dev/null +++ b/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/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_group_operations import ServerGroupOperations +from ._server_operations import ServerOperations +from ._configuration_operations import ConfigurationOperations +from ._firewall_rule_operations import FirewallRuleOperations +from ._role_operations import RoleOperations +from ._operation_operations import OperationOperations + +__all__ = [ + 'ServerGroupOperations', + 'ServerOperations', + 'ConfigurationOperations', + 'FirewallRuleOperations', + 'RoleOperations', + 'OperationOperations', +] diff --git a/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/postgresqlhsc/operations/_configuration_operations.py b/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/postgresqlhsc/operations/_configuration_operations.py new file mode 100644 index 00000000000..379ecdb6c7c --- /dev/null +++ b/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/postgresqlhsc/operations/_configuration_operations.py @@ -0,0 +1,402 @@ +# 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, List, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class ConfigurationOperations(object): + """ConfigurationOperations 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 + server_role_group_configurations=None, # type: Optional[List["models.ServerRoleGroupConfiguration"]] + **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', {})) + + parameters = models.ServerGroupConfiguration(server_role_group_configurations=server_role_group_configurations) + 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 + server_role_group_configurations=None, # type: Optional[List["models.ServerRoleGroupConfiguration"]] + **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 server_role_group_configurations: The list of server role group configuration values. + :type server_role_group_configurations: list[~azure.mgmt.rdbms.postgresqlhsc.models.ServerRoleGroupConfiguration] + :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, + server_role_group_configurations=server_role_group_configurations, + 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/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/postgresqlhsc/operations/_firewall_rule_operations.py b/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/postgresqlhsc/operations/_firewall_rule_operations.py new file mode 100644 index 00000000000..f35a3f7dc76 --- /dev/null +++ b/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/postgresqlhsc/operations/_firewall_rule_operations.py @@ -0,0 +1,450 @@ +# 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 + +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 FirewallRuleOperations(object): + """FirewallRuleOperations 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 + start_ip_address, # type: str + end_ip_address, # type: str + **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', {})) + + parameters = models.FirewallRule(start_ip_address=start_ip_address, end_ip_address=end_ip_address) + 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 + start_ip_address, # type: str + end_ip_address, # type: str + **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 start_ip_address: The start IP address of the server group firewall rule. Must be IPv4 + format. + :type start_ip_address: str + :param end_ip_address: The end IP address of the server group firewall rule. Must be IPv4 + format. + :type end_ip_address: 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 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, + start_ip_address=start_ip_address, + end_ip_address=end_ip_address, + 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/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/postgresqlhsc/operations/_operation_operations.py b/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/postgresqlhsc/operations/_operation_operations.py new file mode 100644 index 00000000000..2750621ba30 --- /dev/null +++ b/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/postgresqlhsc/operations/_operation_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 + +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 OperationOperations(object): + """OperationOperations 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/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/postgresqlhsc/operations/_role_operations.py b/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/postgresqlhsc/operations/_role_operations.py new file mode 100644 index 00000000000..e60d8595d2a --- /dev/null +++ b/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/postgresqlhsc/operations/_role_operations.py @@ -0,0 +1,380 @@ +# 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 + +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 RoleOperations(object): + """RoleOperations 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 + password=None, # type: Optional[str] + **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', {})) + + parameters = models.Role(password=password) + 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 + password=None, # type: Optional[str] + **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 password: The password of the server group role. + :type password: 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 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, + password=password, + 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/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/postgresqlhsc/operations/_server_group_operations.py b/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/postgresqlhsc/operations/_server_group_operations.py new file mode 100644 index 00000000000..8fa96090f82 --- /dev/null +++ b/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/postgresqlhsc/operations/_server_group_operations.py @@ -0,0 +1,1169 @@ +# 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 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 + +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from typing import Any, Callable, Dict, Generic, Iterable, List, Optional, TypeVar, Union + + T = TypeVar('T') + ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +class ServerGroupOperations(object): + """ServerGroupOperations 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 + location, # type: str + tags=None, # type: Optional[Dict[str, str]] + create_mode=None, # type: Optional[Union[str, "models.CreateMode"]] + administrator_login=None, # type: Optional[str] + administrator_login_password=None, # type: Optional[str] + backup_retention_days=None, # type: Optional[int] + postgresql_version=None, # type: Optional[Union[str, "models.PostgreSQLVersion"]] + citus_version=None, # type: Optional[Union[str, "models.CitusVersion"]] + enable_mx=None, # type: Optional[bool] + enable_zfs=None, # type: Optional[bool] + enable_shards_on_coordinator=None, # type: Optional[bool] + server_role_groups=None, # type: Optional[List["models.ServerRoleGroup"]] + maintenance_window=None, # type: Optional["models.MaintenanceWindow"] + availability_zone=None, # type: Optional[str] + standby_availability_zone=None, # type: Optional[str] + source_subscription_id=None, # type: Optional[str] + source_resource_group_name=None, # type: Optional[str] + source_server_group_name=None, # type: Optional[str] + source_location=None, # type: Optional[str] + point_in_time_utc=None, # type: Optional[datetime.datetime] + subnet_arm_resource_id=None, # type: Optional[str] + **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', {})) + + parameters = models.ServerGroup(tags=tags, location=location, create_mode=create_mode, administrator_login=administrator_login, administrator_login_password=administrator_login_password, backup_retention_days=backup_retention_days, postgresql_version=postgresql_version, citus_version=citus_version, enable_mx=enable_mx, enable_zfs=enable_zfs, enable_shards_on_coordinator=enable_shards_on_coordinator, server_role_groups=server_role_groups, maintenance_window=maintenance_window, availability_zone=availability_zone, standby_availability_zone=standby_availability_zone, source_subscription_id=source_subscription_id, source_resource_group_name=source_resource_group_name, source_server_group_name=source_server_group_name, source_location=source_location, point_in_time_utc=point_in_time_utc, subnet_arm_resource_id=subnet_arm_resource_id) + 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 + location, # type: str + tags=None, # type: Optional[Dict[str, str]] + create_mode=None, # type: Optional[Union[str, "models.CreateMode"]] + administrator_login=None, # type: Optional[str] + administrator_login_password=None, # type: Optional[str] + backup_retention_days=None, # type: Optional[int] + postgresql_version=None, # type: Optional[Union[str, "models.PostgreSQLVersion"]] + citus_version=None, # type: Optional[Union[str, "models.CitusVersion"]] + enable_mx=None, # type: Optional[bool] + enable_zfs=None, # type: Optional[bool] + enable_shards_on_coordinator=None, # type: Optional[bool] + server_role_groups=None, # type: Optional[List["models.ServerRoleGroup"]] + maintenance_window=None, # type: Optional["models.MaintenanceWindow"] + availability_zone=None, # type: Optional[str] + standby_availability_zone=None, # type: Optional[str] + source_subscription_id=None, # type: Optional[str] + source_resource_group_name=None, # type: Optional[str] + source_server_group_name=None, # type: Optional[str] + source_location=None, # type: Optional[str] + point_in_time_utc=None, # type: Optional[datetime.datetime] + subnet_arm_resource_id=None, # type: Optional[str] + **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 location: The geo-location where the resource lives. + :type location: str + :param tags: Resource tags. + :type tags: dict[str, str] + :param create_mode: The mode to create a new server group. + :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. + :type postgresql_version: str or ~azure.mgmt.rdbms.postgresqlhsc.models.PostgreSQLVersion + :param citus_version: The Citus version of server group. + :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 + :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 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 + :param subnet_arm_resource_id: delegated subnet arm resource id. + :type subnet_arm_resource_id: 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 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, + location=location, + tags=tags, + create_mode=create_mode, + administrator_login=administrator_login, + administrator_login_password=administrator_login_password, + backup_retention_days=backup_retention_days, + postgresql_version=postgresql_version, + citus_version=citus_version, + enable_mx=enable_mx, + enable_zfs=enable_zfs, + enable_shards_on_coordinator=enable_shards_on_coordinator, + server_role_groups=server_role_groups, + maintenance_window=maintenance_window, + availability_zone=availability_zone, + standby_availability_zone=standby_availability_zone, + source_subscription_id=source_subscription_id, + source_resource_group_name=source_resource_group_name, + source_server_group_name=source_server_group_name, + source_location=source_location, + point_in_time_utc=point_in_time_utc, + subnet_arm_resource_id=subnet_arm_resource_id, + 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 + location=None, # type: Optional[str] + tags=None, # type: Optional[Dict[str, str]] + administrator_login_password=None, # type: Optional[str] + backup_retention_days=None, # type: Optional[int] + postgresql_version=None, # type: Optional[Union[str, "models.PostgreSQLVersion"]] + citus_version=None, # type: Optional[Union[str, "models.CitusVersion"]] + enable_shards_on_coordinator=None, # type: Optional[bool] + server_role_groups=None, # type: Optional[List["models.ServerRoleGroup"]] + maintenance_window=None, # type: Optional["models.MaintenanceWindow"] + availability_zone=None, # type: Optional[str] + standby_availability_zone=None, # type: Optional[str] + **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', {})) + + parameters = models.ServerGroupForUpdate(location=location, tags=tags, administrator_login_password=administrator_login_password, backup_retention_days=backup_retention_days, postgresql_version=postgresql_version, citus_version=citus_version, enable_shards_on_coordinator=enable_shards_on_coordinator, server_role_groups=server_role_groups, maintenance_window=maintenance_window, availability_zone=availability_zone, standby_availability_zone=standby_availability_zone) + 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 + location=None, # type: Optional[str] + tags=None, # type: Optional[Dict[str, str]] + administrator_login_password=None, # type: Optional[str] + backup_retention_days=None, # type: Optional[int] + postgresql_version=None, # type: Optional[Union[str, "models.PostgreSQLVersion"]] + citus_version=None, # type: Optional[Union[str, "models.CitusVersion"]] + enable_shards_on_coordinator=None, # type: Optional[bool] + server_role_groups=None, # type: Optional[List["models.ServerRoleGroup"]] + maintenance_window=None, # type: Optional["models.MaintenanceWindow"] + availability_zone=None, # type: Optional[str] + standby_availability_zone=None, # type: Optional[str] + **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 location: The location the resource resides in. + :type location: str + :param 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. + :type postgresql_version: str or ~azure.mgmt.rdbms.postgresqlhsc.models.PostgreSQLVersion + :param citus_version: The Citus version of server group. + :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 + :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, + location=location, + tags=tags, + administrator_login_password=administrator_login_password, + backup_retention_days=backup_retention_days, + postgresql_version=postgresql_version, + citus_version=citus_version, + enable_shards_on_coordinator=enable_shards_on_coordinator, + server_role_groups=server_role_groups, + maintenance_window=maintenance_window, + availability_zone=availability_zone, + standby_availability_zone=standby_availability_zone, + 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, # type: str + **kwargs # type: Any + ): + # type: (...) -> "models.NameAvailability" + """Check the availability of name for resource. + + :param name: Resource name to verify. + :type name: str + :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', {})) + + name_availability_request = models.NameAvailabilityRequest(name=name) + 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/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/postgresqlhsc/operations/_server_operations.py b/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/postgresqlhsc/operations/_server_operations.py new file mode 100644 index 00000000000..78542ab0bcb --- /dev/null +++ b/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/postgresqlhsc/operations/_server_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 + +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 ServerOperations(object): + """ServerOperations 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/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/postgresqlhsc/py.typed b/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/postgresqlhsc/py.typed new file mode 100644 index 00000000000..e5aff4f83af --- /dev/null +++ b/src/postgresqlhsc/azext_postgresqlhsc/vendored_sdks/postgresqlhsc/py.typed @@ -0,0 +1 @@ +# Marker file for PEP 561. \ No newline at end of file diff --git a/src/postgresqlhsc/report.md b/src/postgresqlhsc/report.md new file mode 100644 index 00000000000..7344c8b8567 --- /dev/null +++ b/src/postgresqlhsc/report.md @@ -0,0 +1,423 @@ +# Azure CLI Module Creation Report + +## EXTENSION +|CLI Extension|Command Groups| +|---------|------------| +|az postgresqlhsc|[groups](#CommandGroups) + +## GROUPS +### Command groups in `az postgresqlhsc` extension +|CLI Command Group|Group Swagger name|Commands| +|---------|------------|--------| +|az postgresqlhsc server-group|ServerGroups|[commands](#CommandsInServerGroups)| +|az postgresqlhsc server|Servers|[commands](#CommandsInServers)| +|az postgresqlhsc configuration|Configurations|[commands](#CommandsInConfigurations)| +|az postgresqlhsc firewall-rule|FirewallRules|[commands](#CommandsInFirewallRules)| +|az postgresqlhsc role|Roles|[commands](#CommandsInRoles)| + +## COMMANDS +### Commands in `az postgresqlhsc configuration` group +|CLI Command|Operation Swagger name|Parameters|Examples| +|---------|------------|--------|-----------| +|[az postgresqlhsc configuration list](#ConfigurationsListByServer)|ListByServer|[Parameters](#ParametersConfigurationsListByServer)|[Example](#ExamplesConfigurationsListByServer)| +|[az postgresqlhsc configuration list](#ConfigurationsListByServerGroup)|ListByServerGroup|[Parameters](#ParametersConfigurationsListByServerGroup)|[Example](#ExamplesConfigurationsListByServerGroup)| +|[az postgresqlhsc configuration show](#ConfigurationsGet)|Get|[Parameters](#ParametersConfigurationsGet)|[Example](#ExamplesConfigurationsGet)| +|[az postgresqlhsc configuration update](#ConfigurationsUpdate)|Update|[Parameters](#ParametersConfigurationsUpdate)|[Example](#ExamplesConfigurationsUpdate)| + +### Commands in `az postgresqlhsc firewall-rule` group +|CLI Command|Operation Swagger name|Parameters|Examples| +|---------|------------|--------|-----------| +|[az postgresqlhsc firewall-rule list](#FirewallRulesListByServerGroup)|ListByServerGroup|[Parameters](#ParametersFirewallRulesListByServerGroup)|[Example](#ExamplesFirewallRulesListByServerGroup)| +|[az postgresqlhsc firewall-rule show](#FirewallRulesGet)|Get|[Parameters](#ParametersFirewallRulesGet)|[Example](#ExamplesFirewallRulesGet)| +|[az postgresqlhsc firewall-rule create](#FirewallRulesCreateOrUpdate#Create)|CreateOrUpdate#Create|[Parameters](#ParametersFirewallRulesCreateOrUpdate#Create)|[Example](#ExamplesFirewallRulesCreateOrUpdate#Create)| +|[az postgresqlhsc firewall-rule update](#FirewallRulesCreateOrUpdate#Update)|CreateOrUpdate#Update|[Parameters](#ParametersFirewallRulesCreateOrUpdate#Update)|Not Found| +|[az postgresqlhsc firewall-rule delete](#FirewallRulesDelete)|Delete|[Parameters](#ParametersFirewallRulesDelete)|[Example](#ExamplesFirewallRulesDelete)| + +### Commands in `az postgresqlhsc role` group +|CLI Command|Operation Swagger name|Parameters|Examples| +|---------|------------|--------|-----------| +|[az postgresqlhsc role list](#RolesListByServerGroup)|ListByServerGroup|[Parameters](#ParametersRolesListByServerGroup)|[Example](#ExamplesRolesListByServerGroup)| +|[az postgresqlhsc role create](#RolesCreate)|Create|[Parameters](#ParametersRolesCreate)|[Example](#ExamplesRolesCreate)| +|[az postgresqlhsc role delete](#RolesDelete)|Delete|[Parameters](#ParametersRolesDelete)|[Example](#ExamplesRolesDelete)| + +### Commands in `az postgresqlhsc server` group +|CLI Command|Operation Swagger name|Parameters|Examples| +|---------|------------|--------|-----------| +|[az postgresqlhsc server list](#ServersListByServerGroup)|ListByServerGroup|[Parameters](#ParametersServersListByServerGroup)|[Example](#ExamplesServersListByServerGroup)| +|[az postgresqlhsc server show](#ServersGet)|Get|[Parameters](#ParametersServersGet)|[Example](#ExamplesServersGet)| + +### Commands in `az postgresqlhsc server-group` group +|CLI Command|Operation Swagger name|Parameters|Examples| +|---------|------------|--------|-----------| +|[az postgresqlhsc server-group list](#ServerGroupsListByResourceGroup)|ListByResourceGroup|[Parameters](#ParametersServerGroupsListByResourceGroup)|[Example](#ExamplesServerGroupsListByResourceGroup)| +|[az postgresqlhsc server-group list](#ServerGroupsList)|List|[Parameters](#ParametersServerGroupsList)|[Example](#ExamplesServerGroupsList)| +|[az postgresqlhsc server-group show](#ServerGroupsGet)|Get|[Parameters](#ParametersServerGroupsGet)|[Example](#ExamplesServerGroupsGet)| +|[az postgresqlhsc server-group create](#ServerGroupsCreateOrUpdate#Create)|CreateOrUpdate#Create|[Parameters](#ParametersServerGroupsCreateOrUpdate#Create)|[Example](#ExamplesServerGroupsCreateOrUpdate#Create)| +|[az postgresqlhsc server-group update](#ServerGroupsUpdate)|Update|[Parameters](#ParametersServerGroupsUpdate)|[Example](#ExamplesServerGroupsUpdate)| +|[az postgresqlhsc server-group delete](#ServerGroupsDelete)|Delete|[Parameters](#ParametersServerGroupsDelete)|[Example](#ExamplesServerGroupsDelete)| +|[az postgresqlhsc server-group restart](#ServerGroupsRestart)|Restart|[Parameters](#ParametersServerGroupsRestart)|[Example](#ExamplesServerGroupsRestart)| +|[az postgresqlhsc server-group start](#ServerGroupsStart)|Start|[Parameters](#ParametersServerGroupsStart)|[Example](#ExamplesServerGroupsStart)| +|[az postgresqlhsc server-group stop](#ServerGroupsStop)|Stop|[Parameters](#ParametersServerGroupsStop)|[Example](#ExamplesServerGroupsStop)| + + +## COMMAND DETAILS + +### group `az postgresqlhsc configuration` +#### Command `az postgresqlhsc configuration list` + +##### Example +``` +az postgresqlhsc configuration list --resource-group "TestResourceGroup" --server-group-name "hsctestsg" --server-name \ +"testserver" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group. The name is case insensitive.|resource_group_name|resourceGroupName| +|**--server-group-name**|string|The name of the server group.|server_group_name|serverGroupName| +|**--server-name**|string|The name of the server.|server_name|serverName| + +#### Command `az postgresqlhsc configuration list` + +##### Example +``` +az postgresqlhsc configuration list --resource-group "TestResourceGroup" --server-group-name "hsctestsg" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +#### Command `az postgresqlhsc configuration show` + +##### Example +``` +az postgresqlhsc configuration show --name "array_nulls" --resource-group "TestResourceGroup" --server-group-name \ +"hsctestsg" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group. The name is case insensitive.|resource_group_name|resourceGroupName| +|**--server-group-name**|string|The name of the server group.|server_group_name|serverGroupName| +|**--configuration-name**|string|The name of the server group configuration.|configuration_name|configurationName| + +#### Command `az postgresqlhsc configuration update` + +##### Example +``` +az postgresqlhsc configuration update --name "array_nulls" --server-role-group-configurations role="Coordinator" \ +value="on" --server-role-group-configurations role="Worker" value="off" --resource-group "TestResourceGroup" \ +--server-group-name "hsctestsg" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group. The name is case insensitive.|resource_group_name|resourceGroupName| +|**--server-group-name**|string|The name of the server group.|server_group_name|serverGroupName| +|**--configuration-name**|string|The name of the server group configuration.|configuration_name|configurationName| +|**--server-role-group-configurations**|array|The list of server role group configuration values.|server_role_group_configurations|serverRoleGroupConfigurations| + +### group `az postgresqlhsc firewall-rule` +#### Command `az postgresqlhsc firewall-rule list` + +##### Example +``` +az postgresqlhsc firewall-rule list --resource-group "TestGroup" --server-group-name "pgtestsvc4" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group. The name is case insensitive.|resource_group_name|resourceGroupName| +|**--server-group-name**|string|The name of the server group.|server_group_name|serverGroupName| + +#### Command `az postgresqlhsc firewall-rule show` + +##### Example +``` +az postgresqlhsc firewall-rule show --name "rule1" --resource-group "TestGroup" --server-group-name "pgtestsvc4" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group. The name is case insensitive.|resource_group_name|resourceGroupName| +|**--server-group-name**|string|The name of the server group.|server_group_name|serverGroupName| +|**--firewall-rule-name**|string|The name of the server group firewall rule.|firewall_rule_name|firewallRuleName| + +#### Command `az postgresqlhsc firewall-rule create` + +##### Example +``` +az postgresqlhsc firewall-rule create --name "rule1" --end-ip-address "255.255.255.255" --start-ip-address "0.0.0.0" \ +--resource-group "TestGroup" --server-group-name "pgtestsvc4" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group. The name is case insensitive.|resource_group_name|resourceGroupName| +|**--server-group-name**|string|The name of the server group.|server_group_name|serverGroupName| +|**--firewall-rule-name**|string|The name of the server group firewall rule.|firewall_rule_name|firewallRuleName| +|**--start-ip-address**|string|The start IP address of the server group firewall rule. Must be IPv4 format.|start_ip_address|startIpAddress| +|**--end-ip-address**|string|The end IP address of the server group firewall rule. Must be IPv4 format.|end_ip_address|endIpAddress| + +#### Command `az postgresqlhsc firewall-rule update` + +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group. The name is case insensitive.|resource_group_name|resourceGroupName| +|**--server-group-name**|string|The name of the server group.|server_group_name|serverGroupName| +|**--firewall-rule-name**|string|The name of the server group firewall rule.|firewall_rule_name|firewallRuleName| +|**--start-ip-address**|string|The start IP address of the server group firewall rule. Must be IPv4 format.|start_ip_address|startIpAddress| +|**--end-ip-address**|string|The end IP address of the server group firewall rule. Must be IPv4 format.|end_ip_address|endIpAddress| + +#### Command `az postgresqlhsc firewall-rule delete` + +##### Example +``` +az postgresqlhsc firewall-rule delete --name "rule1" --resource-group "TestGroup" --server-group-name "pgtestsvc4" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group. The name is case insensitive.|resource_group_name|resourceGroupName| +|**--server-group-name**|string|The name of the server group.|server_group_name|serverGroupName| +|**--firewall-rule-name**|string|The name of the server group firewall rule.|firewall_rule_name|firewallRuleName| + +### group `az postgresqlhsc role` +#### Command `az postgresqlhsc role list` + +##### Example +``` +az postgresqlhsc role list --resource-group "TestGroup" --server-group-name "pgtestsvc4" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group. The name is case insensitive.|resource_group_name|resourceGroupName| +|**--server-group-name**|string|The name of the server group.|server_group_name|serverGroupName| + +#### Command `az postgresqlhsc role create` + +##### Example +``` +az postgresqlhsc role create --password "secret" --resource-group "TestGroup" --name "role1" --server-group-name \ +"pgtestsvc4" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group. The name is case insensitive.|resource_group_name|resourceGroupName| +|**--server-group-name**|string|The name of the server group.|server_group_name|serverGroupName| +|**--role-name**|string|The name of the server group role name.|role_name|roleName| +|**--password**|credential|The password of the server group role.|password|password| + +#### Command `az postgresqlhsc role delete` + +##### Example +``` +az postgresqlhsc role delete --resource-group "TestGroup" --name "role1" --server-group-name "pgtestsvc4" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group. The name is case insensitive.|resource_group_name|resourceGroupName| +|**--server-group-name**|string|The name of the server group.|server_group_name|serverGroupName| +|**--role-name**|string|The name of the server group role name.|role_name|roleName| + +### group `az postgresqlhsc server` +#### Command `az postgresqlhsc server list` + +##### Example +``` +az postgresqlhsc server list --resource-group "TestGroup" --server-group-name "hsctestsg1" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group. The name is case insensitive.|resource_group_name|resourceGroupName| +|**--server-group-name**|string|The name of the server group.|server_group_name|serverGroupName| + +#### Command `az postgresqlhsc server show` + +##### Example +``` +az postgresqlhsc server show --resource-group "TestGroup" --server-group-name "hsctestsg1" --name "hsctestsg1-c" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group. The name is case insensitive.|resource_group_name|resourceGroupName| +|**--server-group-name**|string|The name of the server group.|server_group_name|serverGroupName| +|**--server-name**|string|The name of the server.|server_name|serverName| + +### group `az postgresqlhsc server-group` +#### Command `az postgresqlhsc server-group list` + +##### Example +``` +az postgresqlhsc server-group list --resource-group "TestGroup" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group. The name is case insensitive.|resource_group_name|resourceGroupName| + +#### Command `az postgresqlhsc server-group list` + +##### Example +``` +az postgresqlhsc server-group list +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +#### Command `az postgresqlhsc server-group show` + +##### Example +``` +az postgresqlhsc server-group show --resource-group "TestGroup" --name "hsctestsg1" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group. The name is case insensitive.|resource_group_name|resourceGroupName| +|**--server-group-name**|string|The name of the server group.|server_group_name|serverGroupName| + +#### Command `az postgresqlhsc server-group create` + +##### Example +``` +az postgresqlhsc server-group create --location "westus" --administrator-login "citus" --administrator-login-password \ +"password" --availability-zone "1" --backup-retention-days 35 --citus-version "9.5" --enable-mx true --enable-zfs \ +false --postgresql-version "12" --server-role-groups name="" enable-ha=true role="Coordinator" server-count=1 \ +server-edition="GeneralPurpose" storage-quota-in-mb=524288 v-cores=4 --server-role-groups name="" enable-ha=false \ +role="Worker" server-count=3 server-edition="MemoryOptimized" storage-quota-in-mb=524288 v-cores=4 \ +--standby-availability-zone "2" --tags ElasticServer="1" --resource-group "TestGroup" --name "hsctestsg" +``` +##### Example +``` +az postgresqlhsc server-group create --location "westus" --create-mode "PointInTimeRestore" --enable-mx true \ +--enable-zfs false --point-in-time-utc "2017-12-14T00:00:37.467Z" --source-location "eastus" \ +--source-resource-group-name "SourceGroup" --source-server-group-name "pgtests-source-server-group" \ +--source-subscription-id "dddddddd-dddd-dddd-dddd-dddddddddddd" --resource-group "TestGroup" --name "hsctestsg" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group. The name is case insensitive.|resource_group_name|resourceGroupName| +|**--server-group-name**|string|The name of the server group.|server_group_name|serverGroupName| +|**--location**|string|The geo-location where the resource lives|location|location| +|**--tags**|dictionary|Resource tags.|tags|tags| +|**--create-mode**|choice|The mode to create a new server group.|create_mode|createMode| +|**--administrator-login**|string|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).|administrator_login|administratorLogin| +|**--administrator-login-password**|credential|The password of the administrator login.|administrator_login_password|administratorLoginPassword| +|**--backup-retention-days**|integer|The backup retention days for server group.|backup_retention_days|backupRetentionDays| +|**--postgresql-version**|choice|The PostgreSQL version of server group.|postgresql_version|postgresqlVersion| +|**--citus-version**|choice|The Citus version of server group.|citus_version|citusVersion| +|**--enable-mx**|boolean|If Citus MX is enabled or not for the server group.|enable_mx|enableMx| +|**--enable-zfs**|boolean|If ZFS compression is enabled or not for the server group.|enable_zfs|enableZfs| +|**--enable-shards-on-coordinator**|boolean|If shards on coordinator is enabled or not for the server group.|enable_shards_on_coordinator|enableShardsOnCoordinator| +|**--server-role-groups**|array|The list of server role groups.|server_role_groups|serverRoleGroups| +|**--maintenance-window**|object|Maintenance window of a server group.|maintenance_window|maintenanceWindow| +|**--availability-zone**|string|Availability Zone information of the server group.|availability_zone|availabilityZone| +|**--standby-availability-zone**|string|Standby Availability Zone information of the server group.|standby_availability_zone|standbyAvailabilityZone| +|**--source-subscription-id**|string|The source subscription id to restore from. It's required when 'createMode' is 'PointInTimeRestore'|source_subscription_id|sourceSubscriptionId| +|**--source-resource-group-name**|string|The source resource group name to restore from. It's required when 'createMode' is 'PointInTimeRestore'|source_resource_group_name|sourceResourceGroupName| +|**--source-server-group-name**|string|The source server group name to restore from. It's required when 'createMode' is 'PointInTimeRestore'|source_server_group_name|sourceServerGroupName| +|**--source-location**|string|The source server group location to restore from. It's required when 'createMode' is 'PointInTimeRestore'|source_location|sourceLocation| +|**--point-in-time-utc**|date-time|Restore point creation time (ISO8601 format), specifying the time to restore from. It's required when 'createMode' is 'PointInTimeRestore'|point_in_time_utc|pointInTimeUTC| +|**--delegated-subnet-arguments-subnet-arm-resource-id**|string|delegated subnet arm resource id.|subnet_arm_resource_id|subnetArmResourceId| + +#### Command `az postgresqlhsc server-group update` + +##### Example +``` +az postgresqlhsc server-group update --location "westus" --server-role-groups name="" role="Worker" server-count=10 \ +--resource-group "TestGroup" --name "hsctestsg" +``` +##### Example +``` +az postgresqlhsc server-group update --location "westus" --server-role-groups name="" role="Coordinator" v-cores=16 \ +--resource-group "TestGroup" --name "hsctestsg" +``` +##### Example +``` +az postgresqlhsc server-group update --location "westus" --server-role-groups name="" role="Worker" \ +storage-quota-in-mb=8388608 --resource-group "TestGroup" --name "hsctestsg" +``` +##### Example +``` +az postgresqlhsc server-group update --maintenance-window custom-window="Enabled" day-of-week=0 start-hour=8 \ +start-minute=0 --resource-group "TestGroup" --name "hsctestsg" +``` +##### Example +``` +az postgresqlhsc server-group update --administrator-login-password "secret" --backup-retention-days 30 \ +--postgresql-version "12" --server-role-groups name="" enable-ha=false role="Coordinator" server-count=1 \ +server-edition="GeneralPurpose" storage-quota-in-mb=1048576 v-cores=8 --server-role-groups name="" enable-ha=true \ +role="Worker" server-count=4 server-edition="MemoryOptimized" storage-quota-in-mb=524288 v-cores=4 --tags \ +ElasticServer="2" --resource-group "TestGroup" --name "hsctestsg" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group. The name is case insensitive.|resource_group_name|resourceGroupName| +|**--server-group-name**|string|The name of the server group.|server_group_name|serverGroupName| +|**--location**|string|The location the resource resides in.|location|location| +|**--tags**|dictionary|Application-specific metadata in the form of key-value pairs.|tags|tags| +|**--administrator-login-password**|credential|The password of the administrator login.|administrator_login_password|administratorLoginPassword| +|**--backup-retention-days**|integer|The backup retention days for server group.|backup_retention_days|backupRetentionDays| +|**--postgresql-version**|choice|The PostgreSQL version of server group.|postgresql_version|postgresqlVersion| +|**--citus-version**|choice|The Citus version of server group.|citus_version|citusVersion| +|**--enable-shards-on-coordinator**|boolean|If shards on coordinator is enabled or not for the server group.|enable_shards_on_coordinator|enableShardsOnCoordinator| +|**--server-role-groups**|array|The list of server role groups.|server_role_groups|serverRoleGroups| +|**--maintenance-window**|object|Maintenance window of a server group.|maintenance_window|maintenanceWindow| +|**--availability-zone**|string|Availability Zone information of the server group.|availability_zone|availabilityZone| +|**--standby-availability-zone**|string|Standby Availability Zone information of the server group.|standby_availability_zone|standbyAvailabilityZone| + +#### Command `az postgresqlhsc server-group delete` + +##### Example +``` +az postgresqlhsc server-group delete --resource-group "TestGroup" --name "testservergroup" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group. The name is case insensitive.|resource_group_name|resourceGroupName| +|**--server-group-name**|string|The name of the server group.|server_group_name|serverGroupName| + +#### Command `az postgresqlhsc server-group restart` + +##### Example +``` +az postgresqlhsc server-group restart --resource-group "TestGroup" --name "hsctestsg1" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group. The name is case insensitive.|resource_group_name|resourceGroupName| +|**--server-group-name**|string|The name of the server group.|server_group_name|serverGroupName| + +#### Command `az postgresqlhsc server-group start` + +##### Example +``` +az postgresqlhsc server-group start --resource-group "TestGroup" --name "hsctestsg1" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group. The name is case insensitive.|resource_group_name|resourceGroupName| +|**--server-group-name**|string|The name of the server group.|server_group_name|serverGroupName| + +#### Command `az postgresqlhsc server-group stop` + +##### Example +``` +az postgresqlhsc server-group stop --resource-group "TestGroup" --name "hsctestsg1" +``` +##### Parameters +|Option|Type|Description|Path (SDK)|Swagger name| +|------|----|-----------|----------|------------| +|**--resource-group-name**|string|The name of the resource group. The name is case insensitive.|resource_group_name|resourceGroupName| +|**--server-group-name**|string|The name of the server group.|server_group_name|serverGroupName| diff --git a/src/postgresqlhsc/setup.cfg b/src/postgresqlhsc/setup.cfg new file mode 100644 index 00000000000..2fdd96e5d39 --- /dev/null +++ b/src/postgresqlhsc/setup.cfg @@ -0,0 +1 @@ +#setup.cfg \ No newline at end of file diff --git a/src/postgresqlhsc/setup.py b/src/postgresqlhsc/setup.py new file mode 100644 index 00000000000..a77c05a98c8 --- /dev/null +++ b/src/postgresqlhsc/setup.py @@ -0,0 +1,58 @@ +#!/usr/bin/env python + +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + + +from codecs import open +from setuptools import setup, find_packages + +# HISTORY.rst entry. +VERSION = '0.1.0' +try: + from azext_postgresqlhsc.manual.version import VERSION +except ImportError: + pass + +# The full list of classifiers is available at +# https://pypi.python.org/pypi?%3Aaction=list_classifiers +CLASSIFIERS = [ + 'Development Status :: 4 - Beta', + 'Intended Audience :: Developers', + 'Intended Audience :: System Administrators', + 'Programming Language :: Python', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'License :: OSI Approved :: MIT License', +] + +DEPENDENCIES = [] + +try: + from azext_postgresqlhsc.manual.dependency import DEPENDENCIES +except ImportError: + pass + +with open('README.md', 'r', encoding='utf-8') as f: + README = f.read() +with open('HISTORY.rst', 'r', encoding='utf-8') as f: + HISTORY = f.read() + +setup( + name='postgresqlhsc', + version=VERSION, + description='Microsoft Azure Command-Line Tools MicrosoftPostgreSQLHyperscale Extension', + author='Microsoft Corporation', + author_email='azpycli@microsoft.com', + url='https://github.com/Azure/azure-cli-extensions/tree/master/src/postgresqlhsc', + long_description=README + '\n\n' + HISTORY, + license='MIT', + classifiers=CLASSIFIERS, + packages=find_packages(), + install_requires=DEPENDENCIES, + package_data={'azext_postgresqlhsc': ['azext_metadata.json']}, +)