Skip to content

Commit

Permalink
CodeGen from PR 32939 in Azure/azure-rest-api-specs
Browse files Browse the repository at this point in the history
Merge e33404d37170c8cee12ae0ea730fd1cbe1763700 into af57daeaf232c2a59bf4ba6a522479c265e2002e
  • Loading branch information
SDKAuto committed Mar 7, 2025
1 parent 8c14799 commit 65bc97b
Show file tree
Hide file tree
Showing 36 changed files with 2,902 additions and 936 deletions.
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": "a31f47c3a37a074d550e5647834b96fd74b67132",
"repository_url": "https://github.com/Azure/azure-rest-api-specs",
"typespec_src": "specification/cognitiveservices/ContentSafety",
"@azure-tools/typespec-python": "0.39.0"
}
41 changes: 41 additions & 0 deletions sdk/contentsafety/azure-ai-contentsafety/apiview-properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"CrossLanguagePackageId": "ContentSafety",
"CrossLanguageDefinitionId": {
"azure.ai.contentsafety.models.AddOrUpdateTextBlocklistItemsOptions": "ContentSafety.AddOrUpdateTextBlocklistItemsOptions",
"azure.ai.contentsafety.models.AddOrUpdateTextBlocklistItemsResult": "ContentSafety.AddOrUpdateTextBlocklistItemsResult",
"azure.ai.contentsafety.models.AnalyzeImageOptions": "ContentSafety.AnalyzeImageOptions",
"azure.ai.contentsafety.models.AnalyzeImageResult": "ContentSafety.AnalyzeImageResult",
"azure.ai.contentsafety.models.AnalyzeTextOptions": "ContentSafety.AnalyzeTextOptions",
"azure.ai.contentsafety.models.AnalyzeTextResult": "ContentSafety.AnalyzeTextResult",
"azure.ai.contentsafety.models.DetectTextProtectedMaterialOptions": "ContentSafety.DetectTextProtectedMaterialOptions",
"azure.ai.contentsafety.models.DetectTextProtectedMaterialResult": "ContentSafety.DetectTextProtectedMaterialResult",
"azure.ai.contentsafety.models.DocumentInjectionAnalysisResult": "ContentSafety.DocumentInjectionAnalysisResult",
"azure.ai.contentsafety.models.ImageCategoriesAnalysis": "ContentSafety.ImageCategoriesAnalysis",
"azure.ai.contentsafety.models.ImageData": "ContentSafety.ImageData",
"azure.ai.contentsafety.models.RemoveTextBlocklistItemsOptions": "ContentSafety.RemoveTextBlocklistItemsOptions",
"azure.ai.contentsafety.models.ShieldPromptOptions": "ContentSafety.ShieldPromptOptions",
"azure.ai.contentsafety.models.ShieldPromptResult": "ContentSafety.ShieldPromptResult",
"azure.ai.contentsafety.models.TextBlocklist": "ContentSafety.TextBlocklist",
"azure.ai.contentsafety.models.TextBlocklistItem": "ContentSafety.TextBlocklistItem",
"azure.ai.contentsafety.models.TextBlocklistMatch": "ContentSafety.TextBlocklistMatch",
"azure.ai.contentsafety.models.TextCategoriesAnalysis": "ContentSafety.TextCategoriesAnalysis",
"azure.ai.contentsafety.models.TextProtectedMaterialAnalysisResult": "ContentSafety.TextProtectedMaterialAnalysisResult",
"azure.ai.contentsafety.models.UserPromptInjectionAnalysisResult": "ContentSafety.UserPromptInjectionAnalysisResult",
"azure.ai.contentsafety.models.ImageCategory": "ContentSafety.ImageCategory",
"azure.ai.contentsafety.models.AnalyzeImageOutputType": "ContentSafety.AnalyzeImageOutputType",
"azure.ai.contentsafety.models.TextCategory": "ContentSafety.TextCategory",
"azure.ai.contentsafety.models.AnalyzeTextOutputType": "ContentSafety.AnalyzeTextOutputType",
"azure.ai.contentsafety.ContentSafetyClient.analyze_image": "Customizations.ContentSafetyClient.analyzeImage",
"azure.ai.contentsafety.ContentSafetyClient.analyze_text": "Customizations.ContentSafetyClient.analyzeText",
"azure.ai.contentsafety.ContentSafetyClient.detect_text_protected_material": "Customizations.ContentSafetyClient.detectTextProtectedMaterial",
"azure.ai.contentsafety.ContentSafetyClient.shield_prompt": "Customizations.ContentSafetyClient.shieldPrompt",
"azure.ai.contentsafety.BlocklistClient.add_or_update_blocklist_items": "Customizations.BlocklistClient.addOrUpdateBlocklistItems",
"azure.ai.contentsafety.BlocklistClient.create_or_update_text_blocklist": "Customizations.BlocklistClient.createOrUpdateTextBlocklist",
"azure.ai.contentsafety.BlocklistClient.delete_text_blocklist": "Customizations.BlocklistClient.deleteTextBlocklist",
"azure.ai.contentsafety.BlocklistClient.get_text_blocklist": "Customizations.BlocklistClient.getTextBlocklist",
"azure.ai.contentsafety.BlocklistClient.get_text_blocklist_item": "Customizations.BlocklistClient.getTextBlocklistItem",
"azure.ai.contentsafety.BlocklistClient.list_text_blocklist_items": "Customizations.BlocklistClient.listTextBlocklistItems",
"azure.ai.contentsafety.BlocklistClient.list_text_blocklists": "Customizations.BlocklistClient.listTextBlocklists",
"azure.ai.contentsafety.BlocklistClient.remove_blocklist_items": "Customizations.BlocklistClient.removeBlocklistItems"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,22 @@
# Code generated by Microsoft (R) Python Code Generator.
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
# --------------------------------------------------------------------------
# pylint: disable=wrong-import-position

from ._client import ContentSafetyClient
from ._client import BlocklistClient
from typing import TYPE_CHECKING

if TYPE_CHECKING:
from ._patch import * # pylint: disable=unused-wildcard-import

from ._client import ContentSafetyClient # type: ignore
from ._client import BlocklistClient # type: ignore
from ._version import VERSION

__version__ = VERSION

try:
from ._patch import __all__ as _patch_all
from ._patch import * # pylint: disable=unused-wildcard-import
from ._patch import *
except ImportError:
_patch_all = []
from ._patch import patch_sdk as _patch_sdk
Expand All @@ -23,6 +29,6 @@
"ContentSafetyClient",
"BlocklistClient",
]
__all__.extend([p for p in _patch_all if p not in __all__])
__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore

_patch_sdk()
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

from copy import deepcopy
from typing import Any, TYPE_CHECKING, Union
from typing_extensions import Self

from azure.core import PipelineClient
from azure.core.credentials import AzureKeyCredential
Expand All @@ -19,21 +20,20 @@
from ._serialization import Deserializer, Serializer

if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from azure.core.credentials import TokenCredential


class ContentSafetyClient(ContentSafetyClientOperationsMixin): # pylint: disable=client-accepts-api-version-keyword
class ContentSafetyClient(ContentSafetyClientOperationsMixin):
"""ContentSafetyClient.
:param endpoint: Supported Cognitive Services endpoints (protocol and hostname, for example:
https://:code:`<resource-name>`.cognitiveservices.azure.com). Required.
https://\\\\ :code:`<resource-name>`.cognitiveservices.azure.com). Required.
:type endpoint: str
:param credential: Credential needed for the client to connect to Azure. Is either a
AzureKeyCredential type or a TokenCredential type. Required.
:param credential: Credential used to authenticate requests to the service. Is either a key
credential type or a token credential 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".
:keyword api_version: The API version to use for this operation. Default value is "2024-09-01".
Note that overriding this default value may result in unsupported behavior.
:paramtype api_version: str
"""
Expand Down Expand Up @@ -84,7 +84,7 @@ def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs:

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

request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments)
Expand All @@ -93,25 +93,25 @@ def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs:
def close(self) -> None:
self._client.close()

def __enter__(self) -> "ContentSafetyClient":
def __enter__(self) -> Self:
self._client.__enter__()
return self

def __exit__(self, *exc_details: Any) -> None:
self._client.__exit__(*exc_details)


class BlocklistClient(BlocklistClientOperationsMixin): # pylint: disable=client-accepts-api-version-keyword
class BlocklistClient(BlocklistClientOperationsMixin):
"""BlocklistClient.
:param endpoint: Supported Cognitive Services endpoints (protocol and hostname, for example:
https://:code:`<resource-name>`.cognitiveservices.azure.com). Required.
https://\\\\ :code:`<resource-name>`.cognitiveservices.azure.com). Required.
:type endpoint: str
:param credential: Credential needed for the client to connect to Azure. Is either a
AzureKeyCredential type or a TokenCredential type. Required.
:param credential: Credential used to authenticate requests to the service. Is either a key
credential type or a token credential 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".
:keyword api_version: The API version to use for this operation. Default value is "2024-09-01".
Note that overriding this default value may result in unsupported behavior.
:paramtype api_version: str
"""
Expand Down Expand Up @@ -162,7 +162,7 @@ def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs:

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

request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments)
Expand All @@ -171,7 +171,7 @@ def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs:
def close(self) -> None:
self._client.close()

def __enter__(self) -> "BlocklistClient":
def __enter__(self) -> Self:
self._client.__enter__()
return self

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,30 +14,29 @@
from ._version import VERSION

if TYPE_CHECKING:
# pylint: disable=unused-import,ungrouped-imports
from azure.core.credentials import TokenCredential


class ContentSafetyClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long
class ContentSafetyClientConfiguration: # pylint: disable=too-many-instance-attributes
"""Configuration for ContentSafetyClient.
Note that all parameters used to create this instance are saved as instance
attributes.
:param endpoint: Supported Cognitive Services endpoints (protocol and hostname, for example:
https://:code:`<resource-name>`.cognitiveservices.azure.com). Required.
https://\\ :code:`<resource-name>`.cognitiveservices.azure.com). Required.
:type endpoint: str
:param credential: Credential needed for the client to connect to Azure. Is either a
AzureKeyCredential type or a TokenCredential type. Required.
:param credential: Credential used to authenticate requests to the service. Is either a key
credential type or a token credential 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".
:keyword api_version: The API version to use for this operation. Default value is "2024-09-01".
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", "2024-09-01")

if endpoint is None:
raise ValueError("Parameter 'endpoint' must not be None.")
Expand Down Expand Up @@ -73,26 +72,26 @@ def _configure(self, **kwargs: Any) -> None:
self.authentication_policy = self._infer_policy(**kwargs)


class BlocklistClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long
class BlocklistClientConfiguration: # pylint: disable=too-many-instance-attributes
"""Configuration for BlocklistClient.
Note that all parameters used to create this instance are saved as instance
attributes.
:param endpoint: Supported Cognitive Services endpoints (protocol and hostname, for example:
https://:code:`<resource-name>`.cognitiveservices.azure.com). Required.
https://\\ :code:`<resource-name>`.cognitiveservices.azure.com). Required.
:type endpoint: str
:param credential: Credential needed for the client to connect to Azure. Is either a
AzureKeyCredential type or a TokenCredential type. Required.
:param credential: Credential used to authenticate requests to the service. Is either a key
credential type or a token credential 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".
:keyword api_version: The API version to use for this operation. Default value is "2024-09-01".
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", "2024-09-01")

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

0 comments on commit 65bc97b

Please # to comment.