Skip to content
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
2 changes: 1 addition & 1 deletion sdk/contentsafety/azure-ai-contentsafety/MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ include azure/ai/contentsafety/py.typed
recursive-include tests *.py
recursive-include samples *.py *.md
include azure/__init__.py
include azure/ai/__init__.py
include azure/ai/__init__.py
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": "1f578543d267d08febc1bebf4e33ffe14363ddfc",
"repository_url": "https://github.com/Azure/azure-rest-api-specs",
"typespec_src": "specification/cognitiveservices/ContentSafety",
"@azure-tools/typespec-python": "0.44.1"
}
53 changes: 53 additions & 0 deletions sdk/contentsafety/azure-ai-contentsafety/apiview-properties.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
"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.aio.ContentSafetyClient.analyze_image": "Customizations.ContentSafetyClient.analyzeImage",
"azure.ai.contentsafety.ContentSafetyClient.analyze_text": "Customizations.ContentSafetyClient.analyzeText",
"azure.ai.contentsafety.aio.ContentSafetyClient.analyze_text": "Customizations.ContentSafetyClient.analyzeText",
"azure.ai.contentsafety.ContentSafetyClient.detect_text_protected_material": "Customizations.ContentSafetyClient.detectTextProtectedMaterial",
"azure.ai.contentsafety.aio.ContentSafetyClient.detect_text_protected_material": "Customizations.ContentSafetyClient.detectTextProtectedMaterial",
"azure.ai.contentsafety.ContentSafetyClient.shield_prompt": "Customizations.ContentSafetyClient.shieldPrompt",
"azure.ai.contentsafety.aio.ContentSafetyClient.shield_prompt": "Customizations.ContentSafetyClient.shieldPrompt",
"azure.ai.contentsafety.BlocklistClient.add_or_update_blocklist_items": "Customizations.BlocklistClient.addOrUpdateBlocklistItems",
"azure.ai.contentsafety.aio.BlocklistClient.add_or_update_blocklist_items": "Customizations.BlocklistClient.addOrUpdateBlocklistItems",
"azure.ai.contentsafety.BlocklistClient.create_or_update_text_blocklist": "Customizations.BlocklistClient.createOrUpdateTextBlocklist",
"azure.ai.contentsafety.aio.BlocklistClient.create_or_update_text_blocklist": "Customizations.BlocklistClient.createOrUpdateTextBlocklist",
"azure.ai.contentsafety.BlocklistClient.delete_text_blocklist": "Customizations.BlocklistClient.deleteTextBlocklist",
"azure.ai.contentsafety.aio.BlocklistClient.delete_text_blocklist": "Customizations.BlocklistClient.deleteTextBlocklist",
"azure.ai.contentsafety.BlocklistClient.get_text_blocklist": "Customizations.BlocklistClient.getTextBlocklist",
"azure.ai.contentsafety.aio.BlocklistClient.get_text_blocklist": "Customizations.BlocklistClient.getTextBlocklist",
"azure.ai.contentsafety.BlocklistClient.get_text_blocklist_item": "Customizations.BlocklistClient.getTextBlocklistItem",
"azure.ai.contentsafety.aio.BlocklistClient.get_text_blocklist_item": "Customizations.BlocklistClient.getTextBlocklistItem",
"azure.ai.contentsafety.BlocklistClient.list_text_blocklist_items": "Customizations.BlocklistClient.listTextBlocklistItems",
"azure.ai.contentsafety.aio.BlocklistClient.list_text_blocklist_items": "Customizations.BlocklistClient.listTextBlocklistItems",
"azure.ai.contentsafety.BlocklistClient.list_text_blocklists": "Customizations.BlocklistClient.listTextBlocklists",
"azure.ai.contentsafety.aio.BlocklistClient.list_text_blocklists": "Customizations.BlocklistClient.listTextBlocklists",
"azure.ai.contentsafety.BlocklistClient.remove_blocklist_items": "Customizations.BlocklistClient.removeBlocklistItems",
"azure.ai.contentsafety.aio.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 @@ -16,31 +17,31 @@

from ._configuration import BlocklistClientConfiguration, ContentSafetyClientConfiguration
from ._operations import BlocklistClientOperationsMixin, ContentSafetyClientOperationsMixin
from ._serialization import Deserializer, Serializer
from ._utils.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://<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:
_endpoint = "{endpoint}/contentsafety"
self._config = ContentSafetyClientConfiguration(endpoint=endpoint, credential=credential, **kwargs)

_policies = kwargs.pop("policies", None)
if _policies is None:
_policies = [
Expand Down Expand Up @@ -84,7 +85,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,32 +94,33 @@ 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://<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:
_endpoint = "{endpoint}/contentsafety"
self._config = BlocklistClientConfiguration(endpoint=endpoint, credential=credential, **kwargs)

_policies = kwargs.pop("policies", None)
if _policies is None:
_policies = [
Expand Down Expand Up @@ -162,7 +164,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 +173,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://<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://<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
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,23 @@
# 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 ._operations import ContentSafetyClientOperationsMixin
from ._operations import BlocklistClientOperationsMixin
from typing import TYPE_CHECKING

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

from ._operations import ContentSafetyClientOperationsMixin # type: ignore
from ._operations import BlocklistClientOperationsMixin # type: ignore

from ._patch import __all__ as _patch_all
from ._patch import * # pylint: disable=unused-wildcard-import
from ._patch import *
from ._patch import patch_sdk as _patch_sdk

__all__ = [
"ContentSafetyClientOperationsMixin",
"BlocklistClientOperationsMixin",
]
__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()
Loading