Skip to content

Commit 96472be

Browse files
author
SDKAuto
committed
CodeGen from PR 21424 in Azure/azure-rest-api-specs
Merge ef004edcd771fc275dd3a884c7a42db6ccba3ee1 into f78fc208f59848e035e9e9879033efd843d945dc
1 parent 339aa5b commit 96472be

File tree

13 files changed

+379
-12
lines changed

13 files changed

+379
-12
lines changed
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
2-
"commit": "60be34ab72f1483aef8feede852bc9f2f1921897",
2+
"commit": "25ad02dd2b1c8100d946bef710c6e8efd2efa720",
33
"repository_url": "https://github.com/Azure/azure-rest-api-specs",
44
"autorest": "3.9.2",
55
"use": [
66
"@autorest/[email protected]",
77
"@autorest/[email protected]"
88
],
9-
"autorest_command": "autorest specification/postgresql/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/home/vsts/work/1/azure-sdk-for-python/sdk --use=@autorest/[email protected] --use=@autorest/[email protected] --version=3.9.2 --version-tolerant=False",
9+
"autorest_command": "autorest specification/postgresql/resource-manager/readme.md --generate-sample=True --include-x-ms-examples-original-file=True --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --use=@autorest/[email protected] --use=@autorest/[email protected] --version=3.9.2 --version-tolerant=False",
1010
"readme": "specification/postgresql/resource-manager/readme.md"
1111
}

sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
77
# --------------------------------------------------------------------------
88

9-
VERSION = "10.2.0b4"
9+
VERSION = "1.0.0b1"

sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/_postgre_sql_management_client.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
GetPrivateDnsZoneSuffixOperations,
2727
LocationBasedCapabilitiesOperations,
2828
Operations,
29+
ReplicasOperations,
2930
ServersOperations,
3031
VirtualNetworkSubnetUsageOperations,
3132
)
@@ -70,6 +71,8 @@ class PostgreSQLManagementClient: # pylint: disable=client-accepts-api-version-
7071
:ivar get_private_dns_zone_suffix: GetPrivateDnsZoneSuffixOperations operations
7172
:vartype get_private_dns_zone_suffix:
7273
azure.mgmt.rdbms.postgresql_flexibleservers.operations.GetPrivateDnsZoneSuffixOperations
74+
:ivar replicas: ReplicasOperations operations
75+
:vartype replicas: azure.mgmt.rdbms.postgresql_flexibleservers.operations.ReplicasOperations
7376
:ivar virtual_network_subnet_usage: VirtualNetworkSubnetUsageOperations operations
7477
:vartype virtual_network_subnet_usage:
7578
azure.mgmt.rdbms.postgresql_flexibleservers.operations.VirtualNetworkSubnetUsageOperations
@@ -121,6 +124,7 @@ def __init__(
121124
self.get_private_dns_zone_suffix = GetPrivateDnsZoneSuffixOperations(
122125
self._client, self._config, self._serialize, self._deserialize
123126
)
127+
self.replicas = ReplicasOperations(self._client, self._config, self._serialize, self._deserialize)
124128
self.virtual_network_subnet_usage = VirtualNetworkSubnetUsageOperations(
125129
self._client, self._config, self._serialize, self._deserialize
126130
)

sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/_version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,4 @@
66
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
77
# --------------------------------------------------------------------------
88

9-
VERSION = "10.2.0b4"
9+
VERSION = "1.0.0b1"

sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/_postgre_sql_management_client.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
GetPrivateDnsZoneSuffixOperations,
2727
LocationBasedCapabilitiesOperations,
2828
Operations,
29+
ReplicasOperations,
2930
ServersOperations,
3031
VirtualNetworkSubnetUsageOperations,
3132
)
@@ -71,6 +72,9 @@ class PostgreSQLManagementClient: # pylint: disable=client-accepts-api-version-
7172
:ivar get_private_dns_zone_suffix: GetPrivateDnsZoneSuffixOperations operations
7273
:vartype get_private_dns_zone_suffix:
7374
azure.mgmt.rdbms.postgresql_flexibleservers.aio.operations.GetPrivateDnsZoneSuffixOperations
75+
:ivar replicas: ReplicasOperations operations
76+
:vartype replicas:
77+
azure.mgmt.rdbms.postgresql_flexibleservers.aio.operations.ReplicasOperations
7478
:ivar virtual_network_subnet_usage: VirtualNetworkSubnetUsageOperations operations
7579
:vartype virtual_network_subnet_usage:
7680
azure.mgmt.rdbms.postgresql_flexibleservers.aio.operations.VirtualNetworkSubnetUsageOperations
@@ -122,6 +126,7 @@ def __init__(
122126
self.get_private_dns_zone_suffix = GetPrivateDnsZoneSuffixOperations(
123127
self._client, self._config, self._serialize, self._deserialize
124128
)
129+
self.replicas = ReplicasOperations(self._client, self._config, self._serialize, self._deserialize)
125130
self.virtual_network_subnet_usage = VirtualNetworkSubnetUsageOperations(
126131
self._client, self._config, self._serialize, self._deserialize
127132
)

sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/__init__.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
from ._servers_operations import ServersOperations
1818
from ._operations import Operations
1919
from ._get_private_dns_zone_suffix_operations import GetPrivateDnsZoneSuffixOperations
20+
from ._replicas_operations import ReplicasOperations
2021
from ._virtual_network_subnet_usage_operations import VirtualNetworkSubnetUsageOperations
2122

2223
from ._patch import __all__ as _patch_all
@@ -35,6 +36,7 @@
3536
"ServersOperations",
3637
"Operations",
3738
"GetPrivateDnsZoneSuffixOperations",
39+
"ReplicasOperations",
3840
"VirtualNetworkSubnetUsageOperations",
3941
]
4042
__all__.extend([p for p in _patch_all if p not in __all__])

sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/aio/operations/_administrators_operations.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ async def _create_initial(
7272
object_id: str,
7373
parameters: Union[_models.ActiveDirectoryAdministratorAdd, IO],
7474
**kwargs: Any
75-
) -> _models.ActiveDirectoryAdministrator:
75+
) -> Optional[_models.ActiveDirectoryAdministrator]:
7676
error_map = {
7777
401: ClientAuthenticationError,
7878
404: ResourceNotFoundError,
@@ -88,7 +88,7 @@ async def _create_initial(
8888
"api_version", _params.pop("api-version", self._config.api_version)
8989
) # type: Literal["2022-03-08-preview"]
9090
content_type = kwargs.pop("content_type", _headers.pop("Content-Type", None)) # type: Optional[str]
91-
cls = kwargs.pop("cls", None) # type: ClsType[_models.ActiveDirectoryAdministrator]
91+
cls = kwargs.pop("cls", None) # type: ClsType[Optional[_models.ActiveDirectoryAdministrator]]
9292

9393
content_type = content_type or "application/json"
9494
_json = None
@@ -120,11 +120,12 @@ async def _create_initial(
120120

121121
response = pipeline_response.http_response
122122

123-
if response.status_code not in [200, 201]:
123+
if response.status_code not in [200, 201, 202]:
124124
map_error(status_code=response.status_code, response=response, error_map=error_map)
125125
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
126126
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
127127

128+
deserialized = None
128129
if response.status_code == 200:
129130
deserialized = self._deserialize("ActiveDirectoryAdministrator", pipeline_response)
130131

Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
# pylint: disable=too-many-lines
2+
# coding=utf-8
3+
# --------------------------------------------------------------------------
4+
# Copyright (c) Microsoft Corporation. All rights reserved.
5+
# Licensed under the MIT License. See License.txt in the project root for license information.
6+
# Code generated by Microsoft (R) AutoRest Code Generator.
7+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
8+
# --------------------------------------------------------------------------
9+
import sys
10+
from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar
11+
import urllib.parse
12+
13+
from azure.core.async_paging import AsyncItemPaged, AsyncList
14+
from azure.core.exceptions import (
15+
ClientAuthenticationError,
16+
HttpResponseError,
17+
ResourceExistsError,
18+
ResourceNotFoundError,
19+
ResourceNotModifiedError,
20+
map_error,
21+
)
22+
from azure.core.pipeline import PipelineResponse
23+
from azure.core.pipeline.transport import AsyncHttpResponse
24+
from azure.core.rest import HttpRequest
25+
from azure.core.tracing.decorator import distributed_trace
26+
from azure.core.utils import case_insensitive_dict
27+
from azure.mgmt.core.exceptions import ARMErrorFormat
28+
29+
from ... import models as _models
30+
from ..._vendor import _convert_request
31+
from ...operations._replicas_operations import build_list_by_server_request
32+
33+
if sys.version_info >= (3, 8):
34+
from typing import Literal # pylint: disable=no-name-in-module, ungrouped-imports
35+
else:
36+
from typing_extensions import Literal # type: ignore # pylint: disable=ungrouped-imports
37+
T = TypeVar("T")
38+
ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
39+
40+
41+
class ReplicasOperations:
42+
"""
43+
.. warning::
44+
**DO NOT** instantiate this class directly.
45+
46+
Instead, you should access the following operations through
47+
:class:`~azure.mgmt.rdbms.postgresql_flexibleservers.aio.PostgreSQLManagementClient`'s
48+
:attr:`replicas` attribute.
49+
"""
50+
51+
models = _models
52+
53+
def __init__(self, *args, **kwargs) -> None:
54+
input_args = list(args)
55+
self._client = input_args.pop(0) if input_args else kwargs.pop("client")
56+
self._config = input_args.pop(0) if input_args else kwargs.pop("config")
57+
self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
58+
self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
59+
60+
@distributed_trace
61+
def list_by_server(
62+
self, resource_group_name: str, server_name: str, **kwargs: Any
63+
) -> AsyncIterable["_models.Server"]:
64+
"""List all the replicas for a given server.
65+
66+
:param resource_group_name: The name of the resource group. The name is case insensitive.
67+
Required.
68+
:type resource_group_name: str
69+
:param server_name: The name of the server. Required.
70+
:type server_name: str
71+
:keyword callable cls: A custom type or function that will be passed the direct response
72+
:return: An iterator like instance of either Server or the result of cls(response)
73+
:rtype:
74+
~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.rdbms.postgresql_flexibleservers.models.Server]
75+
:raises ~azure.core.exceptions.HttpResponseError:
76+
"""
77+
_headers = kwargs.pop("headers", {}) or {}
78+
_params = case_insensitive_dict(kwargs.pop("params", {}) or {})
79+
80+
api_version = kwargs.pop(
81+
"api_version", _params.pop("api-version", self._config.api_version)
82+
) # type: Literal["2022-03-08-preview"]
83+
cls = kwargs.pop("cls", None) # type: ClsType[_models.ServerListResult]
84+
85+
error_map = {
86+
401: ClientAuthenticationError,
87+
404: ResourceNotFoundError,
88+
409: ResourceExistsError,
89+
304: ResourceNotModifiedError,
90+
}
91+
error_map.update(kwargs.pop("error_map", {}) or {})
92+
93+
def prepare_request(next_link=None):
94+
if not next_link:
95+
96+
request = build_list_by_server_request(
97+
resource_group_name=resource_group_name,
98+
server_name=server_name,
99+
subscription_id=self._config.subscription_id,
100+
api_version=api_version,
101+
template_url=self.list_by_server.metadata["url"],
102+
headers=_headers,
103+
params=_params,
104+
)
105+
request = _convert_request(request)
106+
request.url = self._client.format_url(request.url) # type: ignore
107+
108+
else:
109+
# make call to next link with the client's api-version
110+
_parsed_next_link = urllib.parse.urlparse(next_link)
111+
_next_request_params = case_insensitive_dict(
112+
{
113+
key: [urllib.parse.quote(v) for v in value]
114+
for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
115+
}
116+
)
117+
_next_request_params["api-version"] = self._config.api_version
118+
request = HttpRequest(
119+
"GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
120+
)
121+
request = _convert_request(request)
122+
request.url = self._client.format_url(request.url) # type: ignore
123+
request.method = "GET"
124+
return request
125+
126+
async def extract_data(pipeline_response):
127+
deserialized = self._deserialize("ServerListResult", pipeline_response)
128+
list_of_elem = deserialized.value
129+
if cls:
130+
list_of_elem = cls(list_of_elem)
131+
return None, AsyncList(list_of_elem)
132+
133+
async def get_next(next_link=None):
134+
request = prepare_request(next_link)
135+
136+
pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access
137+
request, stream=False, **kwargs
138+
)
139+
response = pipeline_response.http_response
140+
141+
if response.status_code not in [200]:
142+
map_error(status_code=response.status_code, response=response, error_map=error_map)
143+
error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response)
144+
raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat)
145+
146+
return pipeline_response
147+
148+
return AsyncItemPaged(get_next, extract_data)
149+
150+
list_by_server.metadata = {"url": "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.DBforPostgreSQL/flexibleServers/{serverName}/replicas"} # type: ignore

sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/models/_models_py3.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1651,7 +1651,7 @@ class Server(TrackedResource): # pylint: disable=too-many-instance-attributes
16511651
:vartype point_in_time_utc: ~datetime.datetime
16521652
:ivar availability_zone: availability zone information of the server.
16531653
:vartype availability_zone: str
1654-
:ivar replication_role: Replication role of the server. Known values are: "Primary",
1654+
:ivar replication_role: Replication role of the server. Known values are: "None", "Primary",
16551655
"Secondary", "WalReplica", "SyncReplica", "AsyncReplica", "GeoSyncReplica", and
16561656
"GeoAsyncReplica".
16571657
:vartype replication_role: str or
@@ -1770,7 +1770,7 @@ def __init__( # pylint: disable=too-many-locals
17701770
:paramtype point_in_time_utc: ~datetime.datetime
17711771
:keyword availability_zone: availability zone information of the server.
17721772
:paramtype availability_zone: str
1773-
:keyword replication_role: Replication role of the server. Known values are: "Primary",
1773+
:keyword replication_role: Replication role of the server. Known values are: "None", "Primary",
17741774
"Secondary", "WalReplica", "SyncReplica", "AsyncReplica", "GeoSyncReplica", and
17751775
"GeoAsyncReplica".
17761776
:paramtype replication_role: str or
@@ -1927,6 +1927,11 @@ class ServerForUpdate(_serialization.Model): # pylint: disable=too-many-instanc
19271927
"Update".
19281928
:vartype create_mode: str or
19291929
~azure.mgmt.rdbms.postgresql_flexibleservers.models.CreateModeForUpdate
1930+
:ivar replication_role: Replication role of the server. Known values are: "None", "Primary",
1931+
"Secondary", "WalReplica", "SyncReplica", "AsyncReplica", "GeoSyncReplica", and
1932+
"GeoAsyncReplica".
1933+
:vartype replication_role: str or
1934+
~azure.mgmt.rdbms.postgresql_flexibleservers.models.ReplicationRole
19301935
"""
19311936

19321937
_attribute_map = {
@@ -1942,6 +1947,7 @@ class ServerForUpdate(_serialization.Model): # pylint: disable=too-many-instanc
19421947
"auth_config": {"key": "properties.authConfig", "type": "AuthConfig"},
19431948
"data_encryption": {"key": "properties.dataEncryption", "type": "DataEncryption"},
19441949
"create_mode": {"key": "properties.createMode", "type": "str"},
1950+
"replication_role": {"key": "properties.replicationRole", "type": "str"},
19451951
}
19461952

19471953
def __init__(
@@ -1959,6 +1965,7 @@ def __init__(
19591965
auth_config: Optional["_models.AuthConfig"] = None,
19601966
data_encryption: Optional["_models.DataEncryption"] = None,
19611967
create_mode: Optional[Union[str, "_models.CreateModeForUpdate"]] = None,
1968+
replication_role: Optional[Union[str, "_models.ReplicationRole"]] = None,
19621969
**kwargs
19631970
):
19641971
"""
@@ -1990,6 +1997,11 @@ def __init__(
19901997
and "Update".
19911998
:paramtype create_mode: str or
19921999
~azure.mgmt.rdbms.postgresql_flexibleservers.models.CreateModeForUpdate
2000+
:keyword replication_role: Replication role of the server. Known values are: "None", "Primary",
2001+
"Secondary", "WalReplica", "SyncReplica", "AsyncReplica", "GeoSyncReplica", and
2002+
"GeoAsyncReplica".
2003+
:paramtype replication_role: str or
2004+
~azure.mgmt.rdbms.postgresql_flexibleservers.models.ReplicationRole
19932005
"""
19942006
super().__init__(**kwargs)
19952007
self.sku = sku
@@ -2004,6 +2016,7 @@ def __init__(
20042016
self.auth_config = auth_config
20052017
self.data_encryption = data_encryption
20062018
self.create_mode = create_mode
2019+
self.replication_role = replication_role
20072020

20082021

20092022
class ServerListResult(_serialization.Model):

sdk/rdbms/azure-mgmt-rdbms/azure/mgmt/rdbms/postgresql_flexibleservers/models/_postgre_sql_management_client_enums.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ class PrincipalType(str, Enum, metaclass=CaseInsensitiveEnumMeta):
120120
class ReplicationRole(str, Enum, metaclass=CaseInsensitiveEnumMeta):
121121
"""Used to indicate role of the server in replication set."""
122122

123+
NONE = "None"
123124
PRIMARY = "Primary"
124125
SECONDARY = "Secondary"
125126
WAL_REPLICA = "WalReplica"

0 commit comments

Comments
 (0)