Skip to content

Commit

Permalink
{RDBMS} Update Python SDK for PostgreSQL flexible servers to version …
Browse files Browse the repository at this point in the history
…API to 2024-11-01-preview (#30257)

* SDK version update to preview

* Current updates to tests

* update locations for records

* byok and geo

* revive

* fix styling
  • Loading branch information
nasc17 authored Nov 11, 2024
1 parent 468a011 commit 4ac17d6
Show file tree
Hide file tree
Showing 37 changed files with 43,923 additions and 70,159 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@ def _postgres_parse_list_capability(result):
if not result:
raise InvalidArgumentValueError("No available SKUs in this location")

if result[0].restricted == "Enabled":
offer_restricted = [feature for feature in result[0].supported_features if feature.name == "OfferRestricted"]

if offer_restricted[0].status == "Enabled":
raise InvalidArgumentValueError("The location is restricted for provisioning of flexible servers. Please try using another region.")

if result[0].restricted != "Disabled":
if offer_restricted[0].status != "Disabled":
raise InvalidArgumentValueError("No available SKUs in this location.")

single_az = result[0].zone_redundant_ha_supported != "Enabled"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,8 +124,7 @@ def flexible_server_create(cmd, client,
high_availability = postgresql_flexibleservers.models.HighAvailability(mode=high_availability,
standby_availability_zone=standby_availability_zone)

password_auth_enabled = password_auth.lower() == 'enabled'
administrator_login_password = generate_password(administrator_login_password) if password_auth_enabled else None
administrator_login_password = generate_password(administrator_login_password)

identity, data_encryption = build_identity_and_data_encryption(db_engine='postgres',
byok_identity=byok_identity,
Expand Down Expand Up @@ -636,12 +635,15 @@ def flexible_server_georestore(cmd, client, resource_group_name, server_name, so

pg_byok_validator(byok_identity, byok_key, backup_byok_identity, backup_byok_key, geo_redundant_backup)

storage = postgresql_flexibleservers.models.Storage(type=None)

parameters = postgresql_flexibleservers.models.Server(
point_in_time_utc=get_current_time(),
location=location,
source_server_resource_id=source_server_id,
create_mode="GeoRestore",
availability_zone=zone
availability_zone=zone,
storage=storage
)

if source_server_object.network.public_network_access == 'Disabled':
Expand Down Expand Up @@ -700,12 +702,15 @@ def flexible_server_revivedropped(cmd, client, resource_group_name, server_name,

pg_byok_validator(byok_identity, byok_key, backup_byok_identity, backup_byok_key, geo_redundant_backup)

storage = postgresql_flexibleservers.models.Storage(type=None)

parameters = postgresql_flexibleservers.models.Server(
point_in_time_utc=get_current_time(),
location=location,
source_server_resource_id=source_server_id,
create_mode="ReviveDropped",
availability_zone=zone
availability_zone=zone,
storage=storage
)

if vnet is not None or vnet_address_prefix is not None or subnet is not None or \
Expand Down Expand Up @@ -1016,10 +1021,9 @@ def flexible_server_provision_network_resource(cmd, resource_group_name, server_

start_ip = -1
end_ip = -1
network = None
network = postgresql_flexibleservers.models.Network()

if subnet is not None or vnet is not None:
network = postgresql_flexibleservers.models.Network()
subnet_id = prepare_private_network(cmd,
resource_group_name,
server_name,
Expand All @@ -1043,6 +1047,7 @@ def flexible_server_provision_network_resource(cmd, resource_group_name, server_
raise RequiredArgumentMissingError("Private DNS zone can only be used with private access setting. Use vnet or/and subnet parameters.")
else:
start_ip, end_ip = prepare_public_network(public_access, yes=yes)
network.public_network_access = public_access if str(public_access).lower() in ['disabled', 'enabled'] else 'Enabled'

return network, start_ip, end_ip

Expand Down

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -3,31 +3,14 @@
# Licensed under the MIT License. See License.txt in the project root for license information.
# --------------------------------------------------------------------------------------------
import os
import time
import pathlib
import getopt
import uuid
import sys
from knack.log import get_logger

from datetime import datetime
from time import sleep
from dateutil.tz import tzutc # pylint: disable=import-error
from azure.cli.testsdk.scenario_tests import AllowLargeResponse
from azure.cli.core.util import CLIError
from azure.cli.core.util import parse_proxy_resource_id
from azure.cli.testsdk.base import execute
from azure.cli.testsdk.exceptions import CliTestError # pylint: disable=unused-import
from azure.cli.testsdk.scenario_tests.const import ENV_LIVE_TEST
from azure.cli.testsdk import (
JMESPathCheck,
NoneCheck,
ResourceGroupPreparer,
ScenarioTest,
StringContainCheck,
live_only)
from azure.cli.testsdk.preparers import (
AbstractPreparer,
SingleValueReplacer)
ScenarioTest)

logger = get_logger(__name__)

Expand All @@ -39,13 +22,13 @@ def test_postgres_flexible_server_migration(self):
self._test_server_migration('postgres')

def test_postgres_flexible_server_onpremise_migration(self):
self._test_server_migration_onpremise('postgres', True, "f31b6595-74d4-4d3c-91bd-fb93af61d8f9")
self._test_server_migration_onpremise('postgres', False, "c73c308e-1e4e-4cfd-bc1f-7db572422598")
self._test_server_migration_onpremise('postgres', True, "ddf073d8-7efe-49da-a201-078d8d312581")
self._test_server_migration_onpremise('postgres', False, "09d5e9a8-45c5-4e95-a60f-003e0e26efcd")

def _test_server_migration(self, database_engine):
# Set this to True or False depending on whether we are in live mode or test mode
# livemode = True
livemode = False
livemode = os.environ.get(ENV_LIVE_TEST, False)

if livemode:
# Live mode values
Expand All @@ -54,7 +37,7 @@ def _test_server_migration(self, database_engine):
else:
# Mock test mode values
target_subscription_id = "00000000-0000-0000-0000-000000000000"
migration_name = "d2419e1d-4e05-4149-95d9-1d1c094e5ac5"
migration_name = "c6396bb5-ab46-432f-884d-b11e013ec6e8"

target_resource_group_name = "autobot-resourcegroup-pg-eastus2euap"
target_server_name = "autobot-e2e-pg-fs-eastus2euap"
Expand Down Expand Up @@ -98,7 +81,7 @@ def _test_server_migration(self, database_engine):
def _test_server_migration_onpremise(self, database_engine, validateOnly=False, migration_name=None):
# Set this to True or False depending on whether we are in live mode or test mode
# livemode = True
livemode = False
livemode = os.environ.get(ENV_LIVE_TEST, False)

if livemode:
# Live mode values
Expand Down
2 changes: 1 addition & 1 deletion src/azure-cli/requirements.py3.Darwin.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ azure-mgmt-monitor==5.0.0
azure-mgmt-msi==7.0.0
azure-mgmt-netapp==10.1.0
azure-mgmt-policyinsights==1.1.0b4
azure-mgmt-postgresqlflexibleservers==1.0.0
azure-mgmt-postgresqlflexibleservers==1.1.0b1
azure-mgmt-privatedns==1.0.0
azure-mgmt-rdbms==10.2.0b17
azure-mgmt-mysqlflexibleservers==1.0.0b2
Expand Down
2 changes: 1 addition & 1 deletion src/azure-cli/requirements.py3.Linux.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ azure-mgmt-monitor==5.0.0
azure-mgmt-msi==7.0.0
azure-mgmt-netapp==10.1.0
azure-mgmt-policyinsights==1.1.0b4
azure-mgmt-postgresqlflexibleservers==1.0.0
azure-mgmt-postgresqlflexibleservers==1.1.0b1
azure-mgmt-privatedns==1.0.0
azure-mgmt-rdbms==10.2.0b17
azure-mgmt-mysqlflexibleservers==1.0.0b2
Expand Down
2 changes: 1 addition & 1 deletion src/azure-cli/requirements.py3.windows.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ azure-mgmt-monitor==5.0.0
azure-mgmt-msi==7.0.0
azure-mgmt-netapp==10.1.0
azure-mgmt-policyinsights==1.1.0b4
azure-mgmt-postgresqlflexibleservers==1.0.0
azure-mgmt-postgresqlflexibleservers==1.1.0b1
azure-mgmt-privatedns==1.0.0
azure-mgmt-rdbms==10.2.0b17
azure-mgmt-mysqlflexibleservers==1.0.0b2
Expand Down
2 changes: 1 addition & 1 deletion src/azure-cli/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@
'azure-mgmt-msi~=7.0.0',
'azure-mgmt-netapp~=10.1.0',
'azure-mgmt-policyinsights==1.1.0b4',
'azure-mgmt-postgresqlflexibleservers==1.0.0',
'azure-mgmt-postgresqlflexibleservers==1.1.0b1',
'azure-mgmt-privatedns~=1.0.0',
'azure-mgmt-rdbms==10.2.0b17',
'azure-mgmt-mysqlflexibleservers==1.0.0b2',
Expand Down

0 comments on commit 4ac17d6

Please sign in to comment.