Skip to content

Commit ead2373

Browse files
author
SDKAuto
committed
CodeGen from PR 33495 in Azure/azure-rest-api-specs
Merge ccdcbff4d314bd37fda7921d087d5c45880a4be0 into b5838c4f5469766558f700d9a6d06ee04ac83750
1 parent fe880b7 commit ead2373

40 files changed

+2919
-897
lines changed

sdk/contentsafety/azure-ai-contentsafety/CHANGELOG.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,41 @@
11
# Release History
22

3+
## 1.1.0 (2025-03-26)
4+
5+
### Features Added
6+
7+
- Client `ContentSafetyClient` added method `detect_text_protected_material`
8+
- Client `ContentSafetyClient` added method `shield_prompt`
9+
- Model `TextBlocklistItem` added property `is_regex`
10+
- Added model `DetectTextProtectedMaterialOptions`
11+
- Added model `DetectTextProtectedMaterialResult`
12+
- Added model `DocumentInjectionAnalysisResult`
13+
- Added model `ShieldPromptOptions`
14+
- Added model `ShieldPromptResult`
15+
- Added model `TextProtectedMaterialAnalysisResult`
16+
- Added model `UserPromptInjectionAnalysisResult`
17+
- Method `ContentSafetyClient.detect_text_protected_material` has a new overload `def detect_text_protected_material(self: None, options: DetectTextProtectedMaterialOptions, content_type: str)`
18+
- Method `ContentSafetyClient.detect_text_protected_material` has a new overload `def detect_text_protected_material(self: None, options: JSON, content_type: str)`
19+
- Method `ContentSafetyClient.detect_text_protected_material` has a new overload `def detect_text_protected_material(self: None, options: IO[bytes], content_type: str)`
20+
- Method `ContentSafetyClient.shield_prompt` has a new overload `def shield_prompt(self: None, options: ShieldPromptOptions, content_type: str)`
21+
- Method `ContentSafetyClient.shield_prompt` has a new overload `def shield_prompt(self: None, options: JSON, content_type: str)`
22+
- Method `ContentSafetyClient.shield_prompt` has a new overload `def shield_prompt(self: None, options: IO[bytes], content_type: str)`
23+
- Method `TextBlocklistItem.__init__` has a new overload `def __init__(self: None, text: str, description: Optional[str], is_regex: Optional[bool])`
24+
- Method `DetectTextProtectedMaterialOptions.__init__` has a new overload `def __init__(self: None, text: str)`
25+
- Method `DetectTextProtectedMaterialOptions.__init__` has a new overload `def __init__(self: None, mapping: Mapping[str, Any])`
26+
- Method `DetectTextProtectedMaterialResult.__init__` has a new overload `def __init__(self: None, protected_material_analysis: _models.TextProtectedMaterialAnalysisResult)`
27+
- Method `DetectTextProtectedMaterialResult.__init__` has a new overload `def __init__(self: None, mapping: Mapping[str, Any])`
28+
- Method `DocumentInjectionAnalysisResult.__init__` has a new overload `def __init__(self: None, attack_detected: bool)`
29+
- Method `DocumentInjectionAnalysisResult.__init__` has a new overload `def __init__(self: None, mapping: Mapping[str, Any])`
30+
- Method `ShieldPromptOptions.__init__` has a new overload `def __init__(self: None, user_prompt: Optional[str], documents: Optional[List[str]])`
31+
- Method `ShieldPromptOptions.__init__` has a new overload `def __init__(self: None, mapping: Mapping[str, Any])`
32+
- Method `ShieldPromptResult.__init__` has a new overload `def __init__(self: None, user_prompt_analysis: Optional[_models.UserPromptInjectionAnalysisResult], documents_analysis: Optional[List[_models.DocumentInjectionAnalysisResult]])`
33+
- Method `ShieldPromptResult.__init__` has a new overload `def __init__(self: None, mapping: Mapping[str, Any])`
34+
- Method `TextProtectedMaterialAnalysisResult.__init__` has a new overload `def __init__(self: None, detected: bool)`
35+
- Method `TextProtectedMaterialAnalysisResult.__init__` has a new overload `def __init__(self: None, mapping: Mapping[str, Any])`
36+
- Method `UserPromptInjectionAnalysisResult.__init__` has a new overload `def __init__(self: None, attack_detected: bool)`
37+
- Method `UserPromptInjectionAnalysisResult.__init__` has a new overload `def __init__(self: None, mapping: Mapping[str, Any])`
38+
339
## 1.0.0 (2023-12-15)
440

541
### Features Added
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"commit": "d3c67401ac66e8d961adbf71394a2338fd2f03e9",
3+
"repository_url": "https://github.com/Azure/azure-rest-api-specs",
4+
"typespec_src": "specification/cognitiveservices/ContentSafety",
5+
"@azure-tools/typespec-python": "0.40.0"
6+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
{
2+
"CrossLanguagePackageId": "ContentSafety",
3+
"CrossLanguageDefinitionId": {
4+
"azure.ai.contentsafety.models.AddOrUpdateTextBlocklistItemsOptions": "ContentSafety.AddOrUpdateTextBlocklistItemsOptions",
5+
"azure.ai.contentsafety.models.AddOrUpdateTextBlocklistItemsResult": "ContentSafety.AddOrUpdateTextBlocklistItemsResult",
6+
"azure.ai.contentsafety.models.AnalyzeImageOptions": "ContentSafety.AnalyzeImageOptions",
7+
"azure.ai.contentsafety.models.AnalyzeImageResult": "ContentSafety.AnalyzeImageResult",
8+
"azure.ai.contentsafety.models.AnalyzeTextOptions": "ContentSafety.AnalyzeTextOptions",
9+
"azure.ai.contentsafety.models.AnalyzeTextResult": "ContentSafety.AnalyzeTextResult",
10+
"azure.ai.contentsafety.models.DetectTextProtectedMaterialOptions": "ContentSafety.DetectTextProtectedMaterialOptions",
11+
"azure.ai.contentsafety.models.DetectTextProtectedMaterialResult": "ContentSafety.DetectTextProtectedMaterialResult",
12+
"azure.ai.contentsafety.models.DocumentInjectionAnalysisResult": "ContentSafety.DocumentInjectionAnalysisResult",
13+
"azure.ai.contentsafety.models.ImageCategoriesAnalysis": "ContentSafety.ImageCategoriesAnalysis",
14+
"azure.ai.contentsafety.models.ImageData": "ContentSafety.ImageData",
15+
"azure.ai.contentsafety.models.RemoveTextBlocklistItemsOptions": "ContentSafety.RemoveTextBlocklistItemsOptions",
16+
"azure.ai.contentsafety.models.ShieldPromptOptions": "ContentSafety.ShieldPromptOptions",
17+
"azure.ai.contentsafety.models.ShieldPromptResult": "ContentSafety.ShieldPromptResult",
18+
"azure.ai.contentsafety.models.TextBlocklist": "ContentSafety.TextBlocklist",
19+
"azure.ai.contentsafety.models.TextBlocklistItem": "ContentSafety.TextBlocklistItem",
20+
"azure.ai.contentsafety.models.TextBlocklistMatch": "ContentSafety.TextBlocklistMatch",
21+
"azure.ai.contentsafety.models.TextCategoriesAnalysis": "ContentSafety.TextCategoriesAnalysis",
22+
"azure.ai.contentsafety.models.TextProtectedMaterialAnalysisResult": "ContentSafety.TextProtectedMaterialAnalysisResult",
23+
"azure.ai.contentsafety.models.UserPromptInjectionAnalysisResult": "ContentSafety.UserPromptInjectionAnalysisResult",
24+
"azure.ai.contentsafety.models.ImageCategory": "ContentSafety.ImageCategory",
25+
"azure.ai.contentsafety.models.AnalyzeImageOutputType": "ContentSafety.AnalyzeImageOutputType",
26+
"azure.ai.contentsafety.models.TextCategory": "ContentSafety.TextCategory",
27+
"azure.ai.contentsafety.models.AnalyzeTextOutputType": "ContentSafety.AnalyzeTextOutputType",
28+
"azure.ai.contentsafety.ContentSafetyClient.analyze_image": "Customizations.ContentSafetyClient.analyzeImage",
29+
"azure.ai.contentsafety.ContentSafetyClient.analyze_text": "Customizations.ContentSafetyClient.analyzeText",
30+
"azure.ai.contentsafety.ContentSafetyClient.detect_text_protected_material": "Customizations.ContentSafetyClient.detectTextProtectedMaterial",
31+
"azure.ai.contentsafety.ContentSafetyClient.shield_prompt": "Customizations.ContentSafetyClient.shieldPrompt",
32+
"azure.ai.contentsafety.BlocklistClient.add_or_update_blocklist_items": "Customizations.BlocklistClient.addOrUpdateBlocklistItems",
33+
"azure.ai.contentsafety.BlocklistClient.create_or_update_text_blocklist": "Customizations.BlocklistClient.createOrUpdateTextBlocklist",
34+
"azure.ai.contentsafety.BlocklistClient.delete_text_blocklist": "Customizations.BlocklistClient.deleteTextBlocklist",
35+
"azure.ai.contentsafety.BlocklistClient.get_text_blocklist": "Customizations.BlocklistClient.getTextBlocklist",
36+
"azure.ai.contentsafety.BlocklistClient.get_text_blocklist_item": "Customizations.BlocklistClient.getTextBlocklistItem",
37+
"azure.ai.contentsafety.BlocklistClient.list_text_blocklist_items": "Customizations.BlocklistClient.listTextBlocklistItems",
38+
"azure.ai.contentsafety.BlocklistClient.list_text_blocklists": "Customizations.BlocklistClient.listTextBlocklists",
39+
"azure.ai.contentsafety.BlocklistClient.remove_blocklist_items": "Customizations.BlocklistClient.removeBlocklistItems"
40+
}
41+
}

sdk/contentsafety/azure-ai-contentsafety/azure/ai/contentsafety/__init__.py

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,22 @@
55
# Code generated by Microsoft (R) Python Code Generator.
66
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
77
# --------------------------------------------------------------------------
8+
# pylint: disable=wrong-import-position
89

9-
from ._client import ContentSafetyClient
10-
from ._client import BlocklistClient
10+
from typing import TYPE_CHECKING
11+
12+
if TYPE_CHECKING:
13+
from ._patch import * # pylint: disable=unused-wildcard-import
14+
15+
from ._client import ContentSafetyClient # type: ignore
16+
from ._client import BlocklistClient # type: ignore
1117
from ._version import VERSION
1218

1319
__version__ = VERSION
1420

1521
try:
1622
from ._patch import __all__ as _patch_all
17-
from ._patch import * # pylint: disable=unused-wildcard-import
23+
from ._patch import *
1824
except ImportError:
1925
_patch_all = []
2026
from ._patch import patch_sdk as _patch_sdk
@@ -23,6 +29,6 @@
2329
"ContentSafetyClient",
2430
"BlocklistClient",
2531
]
26-
__all__.extend([p for p in _patch_all if p not in __all__])
32+
__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore
2733

2834
_patch_sdk()

sdk/contentsafety/azure-ai-contentsafety/azure/ai/contentsafety/_client.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
from copy import deepcopy
1010
from typing import Any, TYPE_CHECKING, Union
11+
from typing_extensions import Self
1112

1213
from azure.core import PipelineClient
1314
from azure.core.credentials import AzureKeyCredential
@@ -19,21 +20,20 @@
1920
from ._serialization import Deserializer, Serializer
2021

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

2525

26-
class ContentSafetyClient(ContentSafetyClientOperationsMixin): # pylint: disable=client-accepts-api-version-keyword
26+
class ContentSafetyClient(ContentSafetyClientOperationsMixin):
2727
"""ContentSafetyClient.
2828
2929
:param endpoint: Supported Cognitive Services endpoints (protocol and hostname, for example:
30-
https://:code:`<resource-name>`.cognitiveservices.azure.com). Required.
30+
https://<resource-name>.cognitiveservices.azure.com). Required.
3131
:type endpoint: str
32-
:param credential: Credential needed for the client to connect to Azure. Is either a
33-
AzureKeyCredential type or a TokenCredential type. Required.
32+
:param credential: Credential used to authenticate requests to the service. Is either a key
33+
credential type or a token credential type. Required.
3434
:type credential: ~azure.core.credentials.AzureKeyCredential or
3535
~azure.core.credentials.TokenCredential
36-
:keyword api_version: The API version to use for this operation. Default value is "2023-10-01".
36+
:keyword api_version: The API version to use for this operation. Default value is "2024-09-01".
3737
Note that overriding this default value may result in unsupported behavior.
3838
:paramtype api_version: str
3939
"""
@@ -93,25 +93,25 @@ def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs:
9393
def close(self) -> None:
9494
self._client.close()
9595

96-
def __enter__(self) -> "ContentSafetyClient":
96+
def __enter__(self) -> Self:
9797
self._client.__enter__()
9898
return self
9999

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

103103

104-
class BlocklistClient(BlocklistClientOperationsMixin): # pylint: disable=client-accepts-api-version-keyword
104+
class BlocklistClient(BlocklistClientOperationsMixin):
105105
"""BlocklistClient.
106106
107107
:param endpoint: Supported Cognitive Services endpoints (protocol and hostname, for example:
108-
https://:code:`<resource-name>`.cognitiveservices.azure.com). Required.
108+
https://<resource-name>.cognitiveservices.azure.com). Required.
109109
:type endpoint: str
110-
:param credential: Credential needed for the client to connect to Azure. Is either a
111-
AzureKeyCredential type or a TokenCredential type. Required.
110+
:param credential: Credential used to authenticate requests to the service. Is either a key
111+
credential type or a token credential type. Required.
112112
:type credential: ~azure.core.credentials.AzureKeyCredential or
113113
~azure.core.credentials.TokenCredential
114-
:keyword api_version: The API version to use for this operation. Default value is "2023-10-01".
114+
:keyword api_version: The API version to use for this operation. Default value is "2024-09-01".
115115
Note that overriding this default value may result in unsupported behavior.
116116
:paramtype api_version: str
117117
"""
@@ -171,7 +171,7 @@ def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs:
171171
def close(self) -> None:
172172
self._client.close()
173173

174-
def __enter__(self) -> "BlocklistClient":
174+
def __enter__(self) -> Self:
175175
self._client.__enter__()
176176
return self
177177

sdk/contentsafety/azure-ai-contentsafety/azure/ai/contentsafety/_configuration.py

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -14,30 +14,29 @@
1414
from ._version import VERSION
1515

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

2019

21-
class ContentSafetyClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long
20+
class ContentSafetyClientConfiguration: # pylint: disable=too-many-instance-attributes
2221
"""Configuration for ContentSafetyClient.
2322
2423
Note that all parameters used to create this instance are saved as instance
2524
attributes.
2625
2726
:param endpoint: Supported Cognitive Services endpoints (protocol and hostname, for example:
28-
https://:code:`<resource-name>`.cognitiveservices.azure.com). Required.
27+
https://<resource-name>.cognitiveservices.azure.com). Required.
2928
:type endpoint: str
30-
:param credential: Credential needed for the client to connect to Azure. Is either a
31-
AzureKeyCredential type or a TokenCredential type. Required.
29+
:param credential: Credential used to authenticate requests to the service. Is either a key
30+
credential type or a token credential type. Required.
3231
:type credential: ~azure.core.credentials.AzureKeyCredential or
3332
~azure.core.credentials.TokenCredential
34-
:keyword api_version: The API version to use for this operation. Default value is "2023-10-01".
33+
:keyword api_version: The API version to use for this operation. Default value is "2024-09-01".
3534
Note that overriding this default value may result in unsupported behavior.
3635
:paramtype api_version: str
3736
"""
3837

3938
def __init__(self, endpoint: str, credential: Union[AzureKeyCredential, "TokenCredential"], **kwargs: Any) -> None:
40-
api_version: str = kwargs.pop("api_version", "2023-10-01")
39+
api_version: str = kwargs.pop("api_version", "2024-09-01")
4140

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

7574

76-
class BlocklistClientConfiguration: # pylint: disable=too-many-instance-attributes,name-too-long
75+
class BlocklistClientConfiguration: # pylint: disable=too-many-instance-attributes
7776
"""Configuration for BlocklistClient.
7877
7978
Note that all parameters used to create this instance are saved as instance
8079
attributes.
8180
8281
:param endpoint: Supported Cognitive Services endpoints (protocol and hostname, for example:
83-
https://:code:`<resource-name>`.cognitiveservices.azure.com). Required.
82+
https://<resource-name>.cognitiveservices.azure.com). Required.
8483
:type endpoint: str
85-
:param credential: Credential needed for the client to connect to Azure. Is either a
86-
AzureKeyCredential type or a TokenCredential type. Required.
84+
:param credential: Credential used to authenticate requests to the service. Is either a key
85+
credential type or a token credential type. Required.
8786
:type credential: ~azure.core.credentials.AzureKeyCredential or
8887
~azure.core.credentials.TokenCredential
89-
:keyword api_version: The API version to use for this operation. Default value is "2023-10-01".
88+
:keyword api_version: The API version to use for this operation. Default value is "2024-09-01".
9089
Note that overriding this default value may result in unsupported behavior.
9190
:paramtype api_version: str
9291
"""
9392

9493
def __init__(self, endpoint: str, credential: Union[AzureKeyCredential, "TokenCredential"], **kwargs: Any) -> None:
95-
api_version: str = kwargs.pop("api_version", "2023-10-01")
94+
api_version: str = kwargs.pop("api_version", "2024-09-01")
9695

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

0 commit comments

Comments
 (0)