Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[AutoPR azure-mgmt-mongocluster] Test mix mode for multiple services #8218

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions sdk/mongocluster/azure-mgmt-mongocluster/_meta.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"commit": "abad0096677005817d2c19df2364663e5583c8fc",
"repository_url": "https://github.com/Azure/azure-rest-api-specs",
"commit": "e80c25cc62c8a7c5eb0728481f7e758b23a39d1c",
"repository_url": "https://github.com/test-repo-billy/azure-rest-api-specs",
"typespec_src": "specification/mongocluster/DocumentDB.MongoCluster.Management",
"@azure-tools/typespec-python": "0.24.3",
"@autorest/python": "6.14.3"
"@azure-tools/typespec-python": "0.28.0"
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
Operations,
PrivateEndpointConnectionsOperations,
PrivateLinksOperations,
ReplicasOperations,
)

if TYPE_CHECKING:
Expand All @@ -45,15 +46,16 @@ class MongoClusterMgmtClient: # pylint: disable=client-accepts-api-version-keyw
azure.mgmt.mongocluster.operations.PrivateEndpointConnectionsOperations
:ivar private_links: PrivateLinksOperations operations
:vartype private_links: azure.mgmt.mongocluster.operations.PrivateLinksOperations
:ivar replicas: ReplicasOperations operations
:vartype replicas: azure.mgmt.mongocluster.operations.ReplicasOperations
:param credential: Credential used to authenticate requests to the service. Required.
:type credential: ~azure.core.credentials.TokenCredential
:param subscription_id: The ID of the target subscription. The value must be an UUID. Required.
:type subscription_id: str
:param base_url: Service host. Default value is "https://management.azure.com".
:type base_url: str
:keyword api_version: The API version to use for this operation. Default value is
"2024-03-01-preview". Note that overriding this default value may result in unsupported
behavior.
:keyword api_version: The API version to use for this operation. Default value is "2024-07-01".
Note that overriding this default value may result in unsupported behavior.
:paramtype api_version: str
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
Expand All @@ -66,8 +68,9 @@ def __init__(
base_url: str = "https://management.azure.com",
**kwargs: Any
) -> None:
_endpoint = "{endpoint}"
self._config = MongoClusterMgmtClientConfiguration(
credential=credential, subscription_id=subscription_id, **kwargs
credential=credential, subscription_id=subscription_id, base_url=base_url, **kwargs
)
_policies = kwargs.pop("policies", None)
if _policies is None:
Expand All @@ -87,7 +90,7 @@ def __init__(
policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None,
self._config.http_logging_policy,
]
self._client: ARMPipelineClient = ARMPipelineClient(base_url=base_url, policies=_policies, **kwargs)
self._client: ARMPipelineClient = ARMPipelineClient(base_url=_endpoint, policies=_policies, **kwargs)

self._serialize = Serializer()
self._deserialize = Deserializer()
Expand All @@ -99,6 +102,7 @@ def __init__(
self._client, self._config, self._serialize, self._deserialize
)
self.private_links = PrivateLinksOperations(self._client, self._config, self._serialize, self._deserialize)
self.replicas = ReplicasOperations(self._client, self._config, self._serialize, self._deserialize)

def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse:
"""Runs the network request through the client's chained policies.
Expand All @@ -119,7 +123,11 @@ def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs:
"""

request_copy = deepcopy(request)
request_copy.url = self._client.format_url(request_copy.url)
path_format_arguments = {
"endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True),
}

request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments)
return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore

def close(self) -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,21 @@ class MongoClusterMgmtClientConfiguration: # pylint: disable=too-many-instance-
:type credential: ~azure.core.credentials.TokenCredential
:param subscription_id: The ID of the target subscription. The value must be an UUID. Required.
:type subscription_id: str
:keyword api_version: The API version to use for this operation. Default value is
"2024-03-01-preview". Note that overriding this default value may result in unsupported
behavior.
:param base_url: Service host. Default value is "https://management.azure.com".
:type base_url: str
:keyword api_version: The API version to use for this operation. Default value is "2024-07-01".
Note that overriding this default value may result in unsupported behavior.
:paramtype api_version: str
"""

def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs: Any) -> None:
api_version: str = kwargs.pop("api_version", "2024-03-01-preview")
def __init__(
self,
credential: "TokenCredential",
subscription_id: str,
base_url: str = "https://management.azure.com",
**kwargs: Any
) -> None:
api_version: str = kwargs.pop("api_version", "2024-07-01")

if credential is None:
raise ValueError("Parameter 'credential' must not be None.")
Expand All @@ -44,6 +51,7 @@ def __init__(self, credential: "TokenCredential", subscription_id: str, **kwargs

self.credential = credential
self.subscription_id = subscription_id
self.base_url = base_url
self.api_version = api_version
self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"])
kwargs.setdefault("sdk_moniker", "mgmt-mongocluster/{}".format(VERSION))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,7 @@ def as_dict(self, *, exclude_readonly: bool = False) -> typing.Dict[str, typing.
"""

result = {}
readonly_props = []
if exclude_readonly:
readonly_props = [p._rest_name for p in self._attr_to_rest_field.values() if _is_readonly(p)]
for k, v in self.items():
Expand Down
Original file line number Diff line number Diff line change
@@ -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) Python Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------
import functools


def api_version_validation(**kwargs):
params_added_on = kwargs.pop("params_added_on", {})
method_added_on = kwargs.pop("method_added_on", "")

def decorator(func):
@functools.wraps(func)
def wrapper(*args, **kwargs):
try:
# this assumes the client has an _api_version attribute
client = args[0]
client_api_version = client._config.api_version # pylint: disable=protected-access
except AttributeError:
return func(*args, **kwargs)

if method_added_on > client_api_version:
raise ValueError(
f"'{func.__name__}' is not available in API version "
f"{client_api_version}. Pass service API version {method_added_on} or newer to your client."
)

unsupported = {
parameter: api_version
for api_version, parameters in params_added_on.items()
for parameter in parameters
if parameter in kwargs and api_version > client_api_version
}
if unsupported:
raise ValueError(
"".join(
[
f"'{param}' is not available in API version {client_api_version}. "
f"Use service API version {version} or newer.\n"
for param, version in unsupported.items()
]
)
)
return func(*args, **kwargs)

return wrapper

return decorator
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
Operations,
PrivateEndpointConnectionsOperations,
PrivateLinksOperations,
ReplicasOperations,
)

if TYPE_CHECKING:
Expand All @@ -45,15 +46,16 @@ class MongoClusterMgmtClient: # pylint: disable=client-accepts-api-version-keyw
azure.mgmt.mongocluster.aio.operations.PrivateEndpointConnectionsOperations
:ivar private_links: PrivateLinksOperations operations
:vartype private_links: azure.mgmt.mongocluster.aio.operations.PrivateLinksOperations
:ivar replicas: ReplicasOperations operations
:vartype replicas: azure.mgmt.mongocluster.aio.operations.ReplicasOperations
:param credential: Credential used to authenticate requests to the service. Required.
:type credential: ~azure.core.credentials_async.AsyncTokenCredential
:param subscription_id: The ID of the target subscription. The value must be an UUID. Required.
:type subscription_id: str
:param base_url: Service host. Default value is "https://management.azure.com".
:type base_url: str
:keyword api_version: The API version to use for this operation. Default value is
"2024-03-01-preview". Note that overriding this default value may result in unsupported
behavior.
:keyword api_version: The API version to use for this operation. Default value is "2024-07-01".
Note that overriding this default value may result in unsupported behavior.
:paramtype api_version: str
:keyword int polling_interval: Default waiting time between two polls for LRO operations if no
Retry-After header is present.
Expand All @@ -66,8 +68,9 @@ def __init__(
base_url: str = "https://management.azure.com",
**kwargs: Any
) -> None:
_endpoint = "{endpoint}"
self._config = MongoClusterMgmtClientConfiguration(
credential=credential, subscription_id=subscription_id, **kwargs
credential=credential, subscription_id=subscription_id, base_url=base_url, **kwargs
)
_policies = kwargs.pop("policies", None)
if _policies is None:
Expand All @@ -87,7 +90,7 @@ def __init__(
policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None,
self._config.http_logging_policy,
]
self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=base_url, policies=_policies, **kwargs)
self._client: AsyncARMPipelineClient = AsyncARMPipelineClient(base_url=_endpoint, policies=_policies, **kwargs)

self._serialize = Serializer()
self._deserialize = Deserializer()
Expand All @@ -99,6 +102,7 @@ def __init__(
self._client, self._config, self._serialize, self._deserialize
)
self.private_links = PrivateLinksOperations(self._client, self._config, self._serialize, self._deserialize)
self.replicas = ReplicasOperations(self._client, self._config, self._serialize, self._deserialize)

def send_request(
self, request: HttpRequest, *, stream: bool = False, **kwargs: Any
Expand All @@ -121,7 +125,11 @@ def send_request(
"""

request_copy = deepcopy(request)
request_copy.url = self._client.format_url(request_copy.url)
path_format_arguments = {
"endpoint": self._serialize.url("self._config.base_url", self._config.base_url, "str", skip_quote=True),
}

request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments)
return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore

async def close(self) -> None:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,21 @@ class MongoClusterMgmtClientConfiguration: # pylint: disable=too-many-instance-
:type credential: ~azure.core.credentials_async.AsyncTokenCredential
:param subscription_id: The ID of the target subscription. The value must be an UUID. Required.
:type subscription_id: str
:keyword api_version: The API version to use for this operation. Default value is
"2024-03-01-preview". Note that overriding this default value may result in unsupported
behavior.
:param base_url: Service host. Default value is "https://management.azure.com".
:type base_url: str
:keyword api_version: The API version to use for this operation. Default value is "2024-07-01".
Note that overriding this default value may result in unsupported behavior.
:paramtype api_version: str
"""

def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **kwargs: Any) -> None:
api_version: str = kwargs.pop("api_version", "2024-03-01-preview")
def __init__(
self,
credential: "AsyncTokenCredential",
subscription_id: str,
base_url: str = "https://management.azure.com",
**kwargs: Any
) -> None:
api_version: str = kwargs.pop("api_version", "2024-07-01")

if credential is None:
raise ValueError("Parameter 'credential' must not be None.")
Expand All @@ -44,6 +51,7 @@ def __init__(self, credential: "AsyncTokenCredential", subscription_id: str, **k

self.credential = credential
self.subscription_id = subscription_id
self.base_url = base_url
self.api_version = api_version
self.credential_scopes = kwargs.pop("credential_scopes", ["https://management.azure.com/.default"])
kwargs.setdefault("sdk_moniker", "mgmt-mongocluster/{}".format(VERSION))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from ._operations import FirewallRulesOperations
from ._operations import PrivateEndpointConnectionsOperations
from ._operations import PrivateLinksOperations
from ._operations import ReplicasOperations

from ._patch import __all__ as _patch_all
from ._patch import * # pylint: disable=unused-wildcard-import
Expand All @@ -22,6 +23,7 @@
"FirewallRulesOperations",
"PrivateEndpointConnectionsOperations",
"PrivateLinksOperations",
"ReplicasOperations",
]
__all__.extend([p for p in _patch_all if p not in __all__])
_patch_sdk()
Loading