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-ai-contentsafety] [Cognitive Services - Azure AI Content Safety] - 2023-10-15-preview Public Preview #5103

Closed
wants to merge 1 commit into from
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
6 changes: 6 additions & 0 deletions sdk/contentsafety/azure-ai-contentsafety/_meta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"commit": "f6df1620ee317ac5f4067a4255131b6384657baf",
"repository_url": "https://github.com/Azure/azure-rest-api-specs",
"typespec_src": "specification/cognitiveservices/ContentSafety",
"@azure-tools/typespec-python": "0.16.3"
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,9 @@ class ContentSafetyClient(ContentSafetyClientOperationsMixin): # pylint: disabl
AzureKeyCredential type or a TokenCredential type. Required.
:type credential: ~azure.core.credentials.AzureKeyCredential or
~azure.core.credentials.TokenCredential
:keyword api_version: The API version to use for this operation. Default value is "2023-10-01".
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
"2023-10-15-preview". Note that overriding this default value may result in unsupported
behavior.
:paramtype api_version: str
"""

Expand Down Expand Up @@ -111,8 +112,9 @@ class BlocklistClient(BlocklistClientOperationsMixin): # pylint: disable=client
AzureKeyCredential type or a TokenCredential type. Required.
:type credential: ~azure.core.credentials.AzureKeyCredential or
~azure.core.credentials.TokenCredential
:keyword api_version: The API version to use for this operation. Default value is "2023-10-01".
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
"2023-10-15-preview". Note that overriding this default value may result in unsupported
behavior.
:paramtype api_version: str
"""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,14 @@ class ContentSafetyClientConfiguration: # pylint: disable=too-many-instance-att
AzureKeyCredential type or a TokenCredential type. Required.
:type credential: ~azure.core.credentials.AzureKeyCredential or
~azure.core.credentials.TokenCredential
:keyword api_version: The API version to use for this operation. Default value is "2023-10-01".
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
"2023-10-15-preview". Note that overriding this default value may result in unsupported
behavior.
:paramtype api_version: str
"""

def __init__(self, endpoint: str, credential: Union[AzureKeyCredential, "TokenCredential"], **kwargs: Any) -> None:
api_version: str = kwargs.pop("api_version", "2023-10-01")
api_version: str = kwargs.pop("api_version", "2023-10-15-preview")

if endpoint is None:
raise ValueError("Parameter 'endpoint' must not be None.")
Expand Down Expand Up @@ -86,13 +87,14 @@ class BlocklistClientConfiguration: # pylint: disable=too-many-instance-attribu
AzureKeyCredential type or a TokenCredential type. Required.
:type credential: ~azure.core.credentials.AzureKeyCredential or
~azure.core.credentials.TokenCredential
:keyword api_version: The API version to use for this operation. Default value is "2023-10-01".
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
"2023-10-15-preview". Note that overriding this default value may result in unsupported
behavior.
:paramtype api_version: str
"""

def __init__(self, endpoint: str, credential: Union[AzureKeyCredential, "TokenCredential"], **kwargs: Any) -> None:
api_version: str = kwargs.pop("api_version", "2023-10-01")
api_version: str = kwargs.pop("api_version", "2023-10-15-preview")

if endpoint is None:
raise ValueError("Parameter 'endpoint' must not be None.")
Expand Down

Large diffs are not rendered by default.

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 @@ -33,8 +33,9 @@ class ContentSafetyClient(ContentSafetyClientOperationsMixin): # pylint: disabl
AzureKeyCredential type or a TokenCredential type. Required.
:type credential: ~azure.core.credentials.AzureKeyCredential or
~azure.core.credentials_async.AsyncTokenCredential
:keyword api_version: The API version to use for this operation. Default value is "2023-10-01".
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
"2023-10-15-preview". Note that overriding this default value may result in unsupported
behavior.
:paramtype api_version: str
"""

Expand Down Expand Up @@ -115,8 +116,9 @@ class BlocklistClient(BlocklistClientOperationsMixin): # pylint: disable=client
AzureKeyCredential type or a TokenCredential type. Required.
:type credential: ~azure.core.credentials.AzureKeyCredential or
~azure.core.credentials_async.AsyncTokenCredential
:keyword api_version: The API version to use for this operation. Default value is "2023-10-01".
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
"2023-10-15-preview". Note that overriding this default value may result in unsupported
behavior.
:paramtype api_version: str
"""

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,16 @@ class ContentSafetyClientConfiguration: # pylint: disable=too-many-instance-att
AzureKeyCredential type or a TokenCredential type. Required.
:type credential: ~azure.core.credentials.AzureKeyCredential or
~azure.core.credentials_async.AsyncTokenCredential
:keyword api_version: The API version to use for this operation. Default value is "2023-10-01".
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
"2023-10-15-preview". Note that overriding this default value may result in unsupported
behavior.
:paramtype api_version: str
"""

def __init__(
self, endpoint: str, credential: Union[AzureKeyCredential, "AsyncTokenCredential"], **kwargs: Any
) -> None:
api_version: str = kwargs.pop("api_version", "2023-10-01")
api_version: str = kwargs.pop("api_version", "2023-10-15-preview")

if endpoint is None:
raise ValueError("Parameter 'endpoint' must not be None.")
Expand Down Expand Up @@ -88,15 +89,16 @@ class BlocklistClientConfiguration: # pylint: disable=too-many-instance-attribu
AzureKeyCredential type or a TokenCredential type. Required.
:type credential: ~azure.core.credentials.AzureKeyCredential or
~azure.core.credentials_async.AsyncTokenCredential
:keyword api_version: The API version to use for this operation. Default value is "2023-10-01".
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
"2023-10-15-preview". Note that overriding this default value may result in unsupported
behavior.
:paramtype api_version: str
"""

def __init__(
self, endpoint: str, credential: Union[AzureKeyCredential, "AsyncTokenCredential"], **kwargs: Any
) -> None:
api_version: str = kwargs.pop("api_version", "2023-10-01")
api_version: str = kwargs.pop("api_version", "2023-10-15-preview")

if endpoint is None:
raise ValueError("Parameter 'endpoint' must not be None.")
Expand Down
Loading