Skip to content

Commit

Permalink
[AutoRelease] t2-network-2023-06-26-52251(can only be merged by SDK o…
Browse files Browse the repository at this point in the history
…wner) (Azure#30882)

* code and test

* update

* update

---------

Co-authored-by: PythonSdkPipelines <PythonSdkPipelines>
Co-authored-by: Yuchao Yan <yuchaoyan@microsoft.com>
  • Loading branch information
azure-sdk and msyyc authored Jun 26, 2023
1 parent 7738969 commit a2519c2
Show file tree
Hide file tree
Showing 7 changed files with 721 additions and 710 deletions.
2 changes: 1 addition & 1 deletion sdk/network/azure-mgmt-network/_meta.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"commit": "1b33e81bbdc28fcd6644a1315b8d7b1b6d030590",
"commit": "02acc29a5618a6998469a7fcc750e301f130a19f",
"repository_url": "https://github.com/Azure/azure-rest-api-specs",
"autorest": "3.9.2",
"use": [
Expand Down
310 changes: 155 additions & 155 deletions sdk/network/azure-mgmt-network/azure/mgmt/network/_client.py

Large diffs are not rendered by default.

54 changes: 25 additions & 29 deletions sdk/network/azure-mgmt-network/azure/mgmt/network/_validation.py
Original file line number Diff line number Diff line change
@@ -1,53 +1,49 @@


# --------------------------------------------------------------------------
# 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.
# --------------------------------------------------------------------------
from typing import Optional, Dict, List
import functools


class api_version_validation:
def __init__(
self,
*,
api_versions: Optional[List[str]] = None,
params: Optional[Dict[str, List[str]]] = None,
):
self.api_versions = api_versions or []
self.params = params or {}
def api_version_validation(**kwargs):
params_valid_on = kwargs.pop("params_valid_on", {})
method_valid_on = kwargs.pop("method_valid_on", {})

def __call__(self, func):
api_versions = self.api_versions
params = self.params
def wrapper(self, *args, **kwargs):
def decorator(func):
@functools.wraps(func)
def wrapper(*args, **kwargs):
func_name = func.__name__
if hasattr(self, "_get_api_version"):
client_api_version = self._get_api_version(func_name)
else:
client_api_version = self._api_version
if api_versions and client_api_version not in api_versions:
try:
client = args[0]
client_api_version = client._get_api_version(func_name) # pylint: disable=protected-access
except AttributeError:
client_api_version = client._api_version # pylint: disable=protected-access

if method_valid_on and client_api_version not in method_valid_on:
raise ValueError(
f"'{func_name}' is not available in API version "
f"{client_api_version}. Pass service API version {api_versions[0]} or newer to your client."
f"{client_api_version}. All valid API version are {', '.join(method_valid_on)}."
)
unsupported = [
parameter
for parameter, api_versions in params.items()

unsupported = {
parameter: ", ".join(api_versions)
for parameter, api_versions in params_valid_on.items()
if parameter in kwargs and client_api_version not in api_versions
]
}
if unsupported:
raise ValueError(
"".join(
[
f"'{param}' is not available in API version {client_api_version}. "
f"Use service API version {params[param][0]} or newer.\n"
for param, version in unsupported
f"All valid API version are {versions} \n"
for param, versions in unsupported.items()
]
)
)
return func(self, *args, **kwargs)
return func(*args, **kwargs)

return wrapper

return decorator
Loading

0 comments on commit a2519c2

Please sign in to comment.