forked from Azure/azure-sdk-for-python
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CodeGen from PR 3476 in test-repo-billy/azure-rest-api-specs
Merge 3b1b4d74387434852ae9cee725f5b1e80f7176ff into 7287b054bc3863f8fe7c1e3818243277440694e4
- Loading branch information
SDKAuto
committed
Aug 15, 2024
1 parent
f4cd3b7
commit 8130572
Showing
19 changed files
with
2,901 additions
and
461 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
"typespec_src": "specification/mongocluster/DocumentDB.MongoCluster.Management", | ||
"@azure-tools/typespec-python": "0.24.3", | ||
"@autorest/python": "6.14.3" | ||
"commit": "8387ea3d827cb70dbfd8c4a6627e669d7598d5aa", | ||
"repository_url": "https://github.com/test-repo-billy/azure-rest-api-specs", | ||
"typespec_src": "specification/mongoclustertest/DocumentDB.MongoCluster.Management", | ||
"@azure-tools/typespec-python": "0.28.0" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
50 changes: 50 additions & 0 deletions
50
sdk/mongocluster/azure-mgmt-mongocluster/azure/mgmt/mongocluster/_validation.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.