diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/CHANGELOG.md b/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/CHANGELOG.md index 696965b3582a..b9becd6d1936 100644 --- a/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/CHANGELOG.md +++ b/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/CHANGELOG.md @@ -1,5 +1,13 @@ # Release History +## 1.0.0b3 (2025-12-09) + +### Features Added +- Added support for service version 2025-11-01. + +### Other Changes +- Updated deployment samples (sync and async) to demonstrate usage with both 2025-11-01 (GA) and 2025-11-15-preview service versions. + ## 1.0.0b2 (2025-11-14) ### Features Added diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/README.md b/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/README.md index 4a5443a7696a..87d93b12509b 100644 --- a/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/README.md +++ b/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/README.md @@ -36,6 +36,14 @@ pip install azure-ai-language-conversations-authoring > Note: This version of the client library defaults to the 2025-11-15-preview version of the service +This table shows the relationship between SDK versions and supported API versions of the service + +| SDK version | Supported API version of service | +| ------------ | --------------------------------- | +| 1.0.0b3 - Latest preview release | 2023-04-01, 2025-11-01, 2025-05-15-preview, 2025-11-15-preview (default) | +| 1.0.0b2 | 2023-04-01, 2025-05-15-preview, 2025-11-15-preview (default) | +| 1.0.0b1 | 2023-04-01, 2024-11-15-preview, 2025-05-15-preview (default) | + ### Authenticate the client To interact with the Conversation Authoring service, you'll need to create an instance of the `ConversationAuthoringClient`. You will need an **endpoint** and an **API key** to instantiate a client object. For more information regarding authenticating with Cognitive Services, see [Authenticate requests to Azure Cognitive Services][cognitive_auth]. diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/apiview-properties.json b/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/apiview-properties.json index 18f8563ccea2..6c01ee107a54 100644 --- a/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/apiview-properties.json +++ b/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/apiview-properties.json @@ -20,7 +20,6 @@ "azure.ai.language.conversations.authoring.models.DataGenerationConnectionInfo": "Language.Conversations.Authoring.AnalyzeConversationAuthoringDataGenerationConnectionInfo", "azure.ai.language.conversations.authoring.models.DataGenerationSettings": "Language.Conversations.Authoring.AnalyzeConversationAuthoringDataGenerationSettings", "azure.ai.language.conversations.authoring.models.DeploymentDeleteFromResourcesState": "Language.Conversations.Authoring.AnalyzeConversationAuthoringDeploymentDeleteFromResourcesJobState", - "azure.ai.language.conversations.authoring.models.DeploymentResource": "Language.Conversations.Authoring.AnalyzeConversationAuthoringDeploymentResource", "azure.ai.language.conversations.authoring.models.DeploymentState": "Language.Conversations.Authoring.AnalyzeConversationAuthoringDeploymentJobState", "azure.ai.language.conversations.authoring.models.EntitiesEvaluationSummary": "Language.Conversations.Authoring.AnalyzeConversationAuthoringEntitiesEvaluationSummary", "azure.ai.language.conversations.authoring.models.EntityEvaluationSummary": "Language.Conversations.Authoring.AnalyzeConversationAuthoringEntityEvaluationSummary", @@ -99,12 +98,6 @@ "azure.ai.language.conversations.authoring.aio.ConversationAuthoringClient.create_project": "Language.ConversationsAuthoringClientCustomizations.ConversationAuthoringClient.createProject", "azure.ai.language.conversations.authoring.ConversationAuthoringClient.get_project": "Language.ConversationsAuthoringClientCustomizations.ConversationAuthoringClient.getProject", "azure.ai.language.conversations.authoring.aio.ConversationAuthoringClient.get_project": "Language.ConversationsAuthoringClientCustomizations.ConversationAuthoringClient.getProject", - "azure.ai.language.conversations.authoring.ConversationAuthoringClient.begin_delete_project": "Language.ConversationsAuthoringClientCustomizations.ConversationAuthoringClient.deleteProject", - "azure.ai.language.conversations.authoring.aio.ConversationAuthoringClient.begin_delete_project": "Language.ConversationsAuthoringClientCustomizations.ConversationAuthoringClient.deleteProject", - "azure.ai.language.conversations.authoring.ConversationAuthoringClient.get_export_status": "Language.ConversationsAuthoringClientCustomizations.ConversationAuthoringClient.getExportStatus", - "azure.ai.language.conversations.authoring.aio.ConversationAuthoringClient.get_export_status": "Language.ConversationsAuthoringClientCustomizations.ConversationAuthoringClient.getExportStatus", - "azure.ai.language.conversations.authoring.ConversationAuthoringClient.get_import_status": "Language.ConversationsAuthoringClientCustomizations.ConversationAuthoringClient.getImportStatus", - "azure.ai.language.conversations.authoring.aio.ConversationAuthoringClient.get_import_status": "Language.ConversationsAuthoringClientCustomizations.ConversationAuthoringClient.getImportStatus", "azure.ai.language.conversations.authoring.operations.DeploymentOperations.get_deployment": "Language.ConversationsAuthoringClientCustomizations.ConversationAuthoringProjectClient.DeploymentOperations.getDeployment", "azure.ai.language.conversations.authoring.aio.operations.DeploymentOperations.get_deployment": "Language.ConversationsAuthoringClientCustomizations.ConversationAuthoringProjectClient.DeploymentOperations.getDeployment", "azure.ai.language.conversations.authoring.operations.DeploymentOperations.begin_deploy_project": "Language.ConversationsAuthoringClientCustomizations.ConversationAuthoringProjectClient.DeploymentOperations.deployProject", diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/assets.json b/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/assets.json index b46c9cfc5dae..2fd21627fcc8 100644 --- a/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/assets.json +++ b/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/assets.json @@ -2,5 +2,5 @@ "AssetsRepo": "Azure/azure-sdk-assets", "AssetsRepoPrefixPath": "python", "TagPrefix": "python/cognitivelanguage/azure-ai-language-conversations-authoring", - "Tag": "python/cognitivelanguage/azure-ai-language-conversations-authoring_20102747af" + "Tag": "python/cognitivelanguage/azure-ai-language-conversations-authoring_94c35e32fe" } diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/azure/ai/language/conversations/authoring/_client.py b/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/azure/ai/language/conversations/authoring/_client.py index 01d76d5075e7..047b4a6db134 100644 --- a/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/azure/ai/language/conversations/authoring/_client.py +++ b/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/azure/ai/language/conversations/authoring/_client.py @@ -43,8 +43,6 @@ class ConversationAuthoringClient(_ConversationAuthoringClientOperationsMixin): "2025-11-15-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. """ def __init__(self, endpoint: str, credential: Union[AzureKeyCredential, "TokenCredential"], **kwargs: Any) -> None: diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/azure/ai/language/conversations/authoring/_patch.py b/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/azure/ai/language/conversations/authoring/_patch.py index eec33eaeda1c..b22255eb48de 100644 --- a/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/azure/ai/language/conversations/authoring/_patch.py +++ b/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/azure/ai/language/conversations/authoring/_patch.py @@ -84,6 +84,7 @@ def get_project_client(self, project_name: str) -> ConversationAuthoringProjectC endpoint=self._config.endpoint, credential=self._config.credential, project_name=project_name, + api_version=self._config.api_version, ) diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/azure/ai/language/conversations/authoring/_version.py b/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/azure/ai/language/conversations/authoring/_version.py index bbcd28b4aa67..c43fdbc2e239 100644 --- a/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/azure/ai/language/conversations/authoring/_version.py +++ b/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/azure/ai/language/conversations/authoring/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.0.0b2" +VERSION = "1.0.0b3" diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/azure/ai/language/conversations/authoring/aio/_client.py b/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/azure/ai/language/conversations/authoring/aio/_client.py index 650dad14a28b..2857b302e5db 100644 --- a/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/azure/ai/language/conversations/authoring/aio/_client.py +++ b/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/azure/ai/language/conversations/authoring/aio/_client.py @@ -43,8 +43,6 @@ class ConversationAuthoringClient(_ConversationAuthoringClientOperationsMixin): "2025-11-15-preview". Note that overriding this default value may result in unsupported behavior. :paramtype api_version: str - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no - Retry-After header is present. """ def __init__( diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/azure/ai/language/conversations/authoring/aio/_patch.py b/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/azure/ai/language/conversations/authoring/aio/_patch.py index 6475d80052f3..16c2c2e44957 100644 --- a/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/azure/ai/language/conversations/authoring/aio/_patch.py +++ b/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/azure/ai/language/conversations/authoring/aio/_patch.py @@ -84,6 +84,7 @@ def get_project_client(self, project_name: str) -> ConversationAuthoringProjectC endpoint=self._config.endpoint, credential=self._config.credential, project_name=project_name, + api_version=self._config.api_version, ) diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/azure/ai/language/conversations/authoring/aio/operations/_deployment_op_patch.py b/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/azure/ai/language/conversations/authoring/aio/operations/_deployment_op_patch.py new file mode 100644 index 000000000000..04eff4b0dcd6 --- /dev/null +++ b/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/azure/ai/language/conversations/authoring/aio/operations/_deployment_op_patch.py @@ -0,0 +1,88 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- +"""Customize generated code here. +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" + +from typing import Any, Optional, Union + +from azure.core.polling import AsyncLROPoller +from azure.core.tracing.decorator import distributed_trace + +from ._operations import DeploymentOperations as _GeneratedDeploymentOperations, JSON +from ...models import CreateDeploymentDetails + + +class DeploymentOperations(_GeneratedDeploymentOperations): + """Deployment operations that handle both: + - 2025-11-15-preview: azureResourceIds = List[AssignedProjectResource] + - 2025-11-01: azureResourceIds = List[str] + """ + + @distributed_trace + async def begin_deploy_project( # type: ignore[override] + self, + deployment_name: str, + body: Union[CreateDeploymentDetails, JSON, Any], + **kwargs: Any, + ) -> AsyncLROPoller[None]: + api_version: Optional[str] = getattr(self._config, "api_version", None) + + if not isinstance(body, CreateDeploymentDetails): + return await super().begin_deploy_project( + deployment_name=deployment_name, + body=body, + **kwargs, + ) + + # If no api_version or preview → use preview shape + if api_version in (None, "2025-11-15-preview"): + # For preview, we require assigned resources, because region is needed. + if body.azure_resource_ids is None: + # user tried to use GA-style strings but preview needs region + if getattr(body, "_azure_resource_ids_strings", None): + raise ValueError( + "For api_version '2025-11-15-preview', azure_resource_ids must " + "be a list of AssignedProjectResource (with region), not plain strings." + ) + # Just send the model as-is + return await super().begin_deploy_project( + deployment_name=deployment_name, + body=body, + **kwargs, + ) + + # GA 2025-11-01 → azureResourceIds is List[str] + if api_version == "2025-11-01": + trained_model_label = body.trained_model_label + + # Prefer GA-style strings if user gave them + str_ids = getattr(body, "_azure_resource_ids_strings", None) + if str_ids is not None: + azure_ids = str_ids + else: + # Otherwise derive from AssignedProjectResource list + azure_ids = None + if body.azure_resource_ids is not None: + azure_ids = [r.resource_id for r in body.azure_resource_ids] + + json_body: JSON = {"trainedModelLabel": trained_model_label} + if azure_ids is not None: + json_body["azureResourceIds"] = azure_ids + + return await super().begin_deploy_project( + deployment_name=deployment_name, + body=json_body, # GA wire + **kwargs, + ) + + # Any other version: fall back to default behavior + return await super().begin_deploy_project( + deployment_name=deployment_name, + body=body, + **kwargs, + ) diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/azure/ai/language/conversations/authoring/aio/operations/_operations.py b/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/azure/ai/language/conversations/authoring/aio/operations/_operations.py index 32e8759647ed..4f52cf764e54 100644 --- a/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/azure/ai/language/conversations/authoring/aio/operations/_operations.py +++ b/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/azure/ai/language/conversations/authoring/aio/operations/_operations.py @@ -902,7 +902,7 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return AsyncLROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace_async - async def get_export_status(self, project_name: str, job_id: str, **kwargs: Any) -> _models.ExportProjectState: + async def _get_export_status(self, project_name: str, job_id: str, **kwargs: Any) -> _models.ExportProjectState: """Gets the status of an export job. Once job completes, returns the project metadata, and assets. :param project_name: The new project name. Required. @@ -965,7 +965,7 @@ async def get_export_status(self, project_name: str, job_id: str, **kwargs: Any) return deserialized # type: ignore @distributed_trace_async - async def get_import_status(self, project_name: str, job_id: str, **kwargs: Any) -> _models.ImportProjectState: + async def _get_import_status(self, project_name: str, job_id: str, **kwargs: Any) -> _models.ImportProjectState: """Gets the status for an import. :param project_name: The new project name. Required. diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/azure/ai/language/conversations/authoring/aio/operations/_patch.py b/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/azure/ai/language/conversations/authoring/aio/operations/_patch.py index d16191ea330a..8f26525b0e0f 100644 --- a/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/azure/ai/language/conversations/authoring/aio/operations/_patch.py +++ b/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/azure/ai/language/conversations/authoring/aio/operations/_patch.py @@ -8,7 +8,7 @@ Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ from ._project_op_patch import ProjectOperations - +from ._deployment_op_patch import DeploymentOperations def patch_sdk(): """Do not remove from this file. @@ -18,4 +18,4 @@ def patch_sdk(): """ -__all__ = ["ProjectOperations"] +__all__ = ["ProjectOperations", "DeploymentOperations"] diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/azure/ai/language/conversations/authoring/models/__init__.py b/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/azure/ai/language/conversations/authoring/models/__init__.py index cf78e10fa6c9..5cb63ea11731 100644 --- a/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/azure/ai/language/conversations/authoring/models/__init__.py +++ b/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/azure/ai/language/conversations/authoring/models/__init__.py @@ -32,7 +32,6 @@ DataGenerationConnectionInfo, DataGenerationSettings, DeploymentDeleteFromResourcesState, - DeploymentResource, DeploymentState, EntitiesEvaluationSummary, EntityEvaluationSummary, @@ -125,7 +124,6 @@ "DataGenerationConnectionInfo", "DataGenerationSettings", "DeploymentDeleteFromResourcesState", - "DeploymentResource", "DeploymentState", "EntitiesEvaluationSummary", "EntityEvaluationSummary", diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/azure/ai/language/conversations/authoring/models/_models.py b/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/azure/ai/language/conversations/authoring/models/_models.py index 1a7d9787fed1..4613e275aabd 100644 --- a/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/azure/ai/language/conversations/authoring/models/_models.py +++ b/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/azure/ai/language/conversations/authoring/models/_models.py @@ -109,7 +109,7 @@ class AssignedProjectResource(_Model): ~azure.ai.language.conversations.authoring.models.DataGenerationConnectionInfo """ - resource_id: str = rest_field(name="azureResourceId", visibility=["read"]) + resource_id: str = rest_field(name="azureResourceId", visibility=["read", "create"]) """The Azure resource ID of the language or AI resource. Required.""" region: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) """The Azure resource region. Required.""" @@ -122,6 +122,7 @@ class AssignedProjectResource(_Model): def __init__( self, *, + resource_id: str, region: str, assigned_aoai_resource: Optional["_models.DataGenerationConnectionInfo"] = None, ) -> None: ... @@ -634,30 +635,30 @@ class CreateDeploymentDetails(_Model): :ivar trained_model_label: Represents the trained model label. Required. :vartype trained_model_label: str - :ivar assigned_resources: Represents the resources to be assigned to the deployment. If - provided, the deployment will be rolled out to the resources provided here as well as the - original resource in which the project is created. - :vartype assigned_resources: - list[~azure.ai.language.conversations.authoring.models.DeploymentResource] + :ivar azure_resource_ids: Represents the Language or AIService resource IDs that if + provided, the deployment will be rolled out to the resources provided here as + well as the original resource in which the project is created. + :vartype azure_resource_ids: + list[~azure.ai.language.conversations.authoring.models.AssignedProjectResource] """ trained_model_label: str = rest_field( name="trainedModelLabel", visibility=["read", "create", "update", "delete", "query"] ) """Represents the trained model label. Required.""" - assigned_resources: Optional[list["_models.DeploymentResource"]] = rest_field( - name="assignedResources", visibility=["read", "create", "update", "delete", "query"] + azure_resource_ids: Optional[list["_models.AssignedProjectResource"]] = rest_field( + name="azureResourceIds", visibility=["read", "create", "update", "delete", "query"] ) - """Represents the resources to be assigned to the deployment. If provided, the deployment will be - rolled out to the resources provided here as well as the original resource in which the project - is created.""" + """Represents the Language or AIService resource IDs that if provided, the deployment + will be rolled out to the resources provided here as well as the original resource in which the + project is created.""" @overload def __init__( self, *, trained_model_label: str, - assigned_resources: Optional[list["_models.DeploymentResource"]] = None, + azure_resource_ids: Optional[list["_models.AssignedProjectResource"]] = None, ) -> None: ... @overload @@ -895,47 +896,6 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class DeploymentResource(_Model): - """Represents an Azure resource assigned to a deployment. - - :ivar resource_id: Represents the Azure resource Id. Required. - :vartype resource_id: str - :ivar region: Represents the resource region. Required. - :vartype region: str - :ivar assigned_aoai_resource: Represents the AOAI resource assigned for data generation. - :vartype assigned_aoai_resource: - ~azure.ai.language.conversations.authoring.models.DataGenerationConnectionInfo - """ - - resource_id: str = rest_field(name="resourceId", visibility=["read", "create", "update", "delete", "query"]) - """Represents the Azure resource Id. Required.""" - region: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """Represents the resource region. Required.""" - assigned_aoai_resource: Optional["_models.DataGenerationConnectionInfo"] = rest_field( - name="assignedAoaiResource", visibility=["read", "create", "update", "delete", "query"] - ) - """Represents the AOAI resource assigned for data generation.""" - - @overload - def __init__( - self, - *, - resource_id: str, - region: str, - assigned_aoai_resource: Optional["_models.DataGenerationConnectionInfo"] = None, - ) -> None: ... - - @overload - def __init__(self, mapping: Mapping[str, Any]) -> None: - """ - :param mapping: raw JSON to initialize the model. - :type mapping: Mapping[str, Any] - """ - - def __init__(self, *args: Any, **kwargs: Any) -> None: - super().__init__(*args, **kwargs) - - class DeploymentState(_Model): """Represents the state of a deployment job. diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/azure/ai/language/conversations/authoring/models/_patch.py b/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/azure/ai/language/conversations/authoring/models/_patch.py index 0772ff2eeb67..2640def455c6 100644 --- a/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/azure/ai/language/conversations/authoring/models/_patch.py +++ b/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/azure/ai/language/conversations/authoring/models/_patch.py @@ -8,7 +8,7 @@ Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ from collections.abc import MutableMapping, Awaitable # pylint:disable=import-error -from typing import Any, Callable, Optional, Tuple, TypeVar, cast +from typing import Any, Callable, Tuple, TypeVar, cast, Mapping, Optional, List import base64 import functools @@ -26,13 +26,14 @@ from ._enums import ExportedProjectFormat from ._models import ( + AssignedProjectResource, CopyProjectDetails, CopyProjectState, ConversationExportedEntity, ConversationExportedIntent, ConversationExportedProjectAsset, ConversationExportedUtterance, - CreateDeploymentDetails, + CreateDeploymentDetails as _GeneratedCreateDeploymentDetails, DeploymentDeleteFromResourcesState, DeploymentState, EvaluationJobResult, @@ -341,6 +342,51 @@ def from_continuation_token(cls, continuation_token: str, **kwargs: Any) -> Tupl initial_response = pickle.loads(base64.b64decode(continuation_token)) # nosec return client, initial_response, deserialization_callback +class CreateDeploymentDetails(_GeneratedCreateDeploymentDetails): + """Represents the options for creating or updating a project deployment. + + :ivar trained_model_label: Represents the trained model label. + :vartype trained_model_label: str + :ivar azure_resource_ids: Language or AIService resource IDs associated with this deployment. + For service version 2025-11-15-preview, this is represented as a list of + class:`AssignedProjectResource`. For service version 2025-11-01, it may be + constructed from a list of resource ID strings. + :vartype azure_resource_ids: + list[~azure.ai.language.conversations.authoring.models.AssignedProjectResource] or list[str] + """ + + _azure_resource_ids_strings: Optional[List[str]] + + def __init__(self, *args: Any, **kwargs: Any) -> None: + # Case 1: mapping initializer → let generated code handle it + if args and isinstance(args[0], Mapping): + super().__init__(*args, **kwargs) + self._azure_resource_ids_strings = None + return + + azure_ids = kwargs.pop("azure_resource_ids", None) + self._azure_resource_ids_strings = None + + if azure_ids is None: + # nothing special, just call base + super().__init__(*args, azure_resource_ids=None, **kwargs) + return + + # If user passed AssignedProjectResource list → original behavior + if all(isinstance(x, AssignedProjectResource) for x in azure_ids): + super().__init__(*args, azure_resource_ids=azure_ids, **kwargs) + return + + # If user passed plain strings → GA style, remember them and *don't* + # try to turn them into AssignedProjectResource here. + if all(isinstance(x, str) for x in azure_ids): + self._azure_resource_ids_strings = list(azure_ids) + super().__init__(*args, azure_resource_ids=None, **kwargs) + return + + raise TypeError( + "azure_resource_ids must be a list of str or a list of AssignedProjectResource." + ) def patch_sdk(): """Do not remove from this file. diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/azure/ai/language/conversations/authoring/operations/_deployment_op_patch.py b/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/azure/ai/language/conversations/authoring/operations/_deployment_op_patch.py new file mode 100644 index 000000000000..f4eca5018167 --- /dev/null +++ b/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/azure/ai/language/conversations/authoring/operations/_deployment_op_patch.py @@ -0,0 +1,88 @@ +# pylint: disable=line-too-long,useless-suppression +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------- +"""Customize generated code here. +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" + +from typing import Any, Optional, Union + +from azure.core.polling import LROPoller +from azure.core.tracing.decorator import distributed_trace + +from ._operations import DeploymentOperations as _GeneratedDeploymentOperations, JSON +from ..models import CreateDeploymentDetails + + +class DeploymentOperations(_GeneratedDeploymentOperations): + """Deployment operations that handle both: + - 2025-11-15-preview: azureResourceIds = List[AssignedProjectResource] + - 2025-11-01: azureResourceIds = List[str] + """ + + @distributed_trace + def begin_deploy_project( # type: ignore[override] + self, + deployment_name: str, + body: Union[CreateDeploymentDetails, JSON, Any], + **kwargs: Any, + ) -> LROPoller[None]: + api_version: Optional[str] = getattr(self._config, "api_version", None) + + if not isinstance(body, CreateDeploymentDetails): + return super().begin_deploy_project( + deployment_name=deployment_name, + body=body, + **kwargs, + ) + + # If no api_version or preview → use preview shape + if api_version in (None, "2025-11-15-preview"): + # For preview, we require assigned resources, because region is needed. + if body.azure_resource_ids is None: + # user tried to use GA-style strings but preview needs region + if getattr(body, "_azure_resource_ids_strings", None): + raise ValueError( + "For api_version '2025-11-15-preview', azure_resource_ids must " + "be a list of AssignedProjectResource (with region), not plain strings." + ) + # Just send the model as-is + return super().begin_deploy_project( + deployment_name=deployment_name, + body=body, + **kwargs, + ) + + # GA 2025-11-01 → azureResourceIds is List[str] + if api_version == "2025-11-01": + trained_model_label = body.trained_model_label + + # Prefer GA-style strings if user gave them + str_ids = getattr(body, "_azure_resource_ids_strings", None) + if str_ids is not None: + azure_ids = str_ids + else: + # Otherwise derive from AssignedProjectResource list + azure_ids = None + if body.azure_resource_ids is not None: + azure_ids = [r.resource_id for r in body.azure_resource_ids] + + json_body: JSON = {"trainedModelLabel": trained_model_label} + if azure_ids is not None: + json_body["azureResourceIds"] = azure_ids + + return super().begin_deploy_project( + deployment_name=deployment_name, + body=json_body, # GA wire + **kwargs, + ) + + # Any other version: fall back to default behavior + return super().begin_deploy_project( + deployment_name=deployment_name, + body=body, + **kwargs, + ) diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/azure/ai/language/conversations/authoring/operations/_operations.py b/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/azure/ai/language/conversations/authoring/operations/_operations.py index c6bb26044905..61b95b741eff 100644 --- a/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/azure/ai/language/conversations/authoring/operations/_operations.py +++ b/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/azure/ai/language/conversations/authoring/operations/_operations.py @@ -2251,7 +2251,7 @@ def get_long_running_output(pipeline_response): # pylint: disable=inconsistent- return LROPoller[None](self._client, raw_result, get_long_running_output, polling_method) # type: ignore @distributed_trace - def get_export_status(self, project_name: str, job_id: str, **kwargs: Any) -> _models.ExportProjectState: + def _get_export_status(self, project_name: str, job_id: str, **kwargs: Any) -> _models.ExportProjectState: """Gets the status of an export job. Once job completes, returns the project metadata, and assets. :param project_name: The new project name. Required. @@ -2314,7 +2314,7 @@ def get_export_status(self, project_name: str, job_id: str, **kwargs: Any) -> _m return deserialized # type: ignore @distributed_trace - def get_import_status(self, project_name: str, job_id: str, **kwargs: Any) -> _models.ImportProjectState: + def _get_import_status(self, project_name: str, job_id: str, **kwargs: Any) -> _models.ImportProjectState: """Gets the status for an import. :param project_name: The new project name. Required. diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/azure/ai/language/conversations/authoring/operations/_patch.py b/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/azure/ai/language/conversations/authoring/operations/_patch.py index d16191ea330a..8f26525b0e0f 100644 --- a/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/azure/ai/language/conversations/authoring/operations/_patch.py +++ b/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/azure/ai/language/conversations/authoring/operations/_patch.py @@ -8,7 +8,7 @@ Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize """ from ._project_op_patch import ProjectOperations - +from ._deployment_op_patch import DeploymentOperations def patch_sdk(): """Do not remove from this file. @@ -18,4 +18,4 @@ def patch_sdk(): """ -__all__ = ["ProjectOperations"] +__all__ = ["ProjectOperations", "DeploymentOperations"] diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/azure/ai/language/conversations/authoring/operations/_project_op_patch.py b/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/azure/ai/language/conversations/authoring/operations/_project_op_patch.py index 8945d2652d62..9ccab0a9baa5 100644 --- a/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/azure/ai/language/conversations/authoring/operations/_project_op_patch.py +++ b/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/azure/ai/language/conversations/authoring/operations/_project_op_patch.py @@ -105,6 +105,3 @@ def get_long_running_output(pipeline_response): get_long_running_output, polling_method, # type: ignore ) - # return super()._begin_cancel_training_job( - # project_name=self._project_name, job_id=job_id, **kwargs - # ) diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/samples/async/sample_deploy_project_async.py b/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/samples/async/sample_deploy_project_async.py index 0b14aabae08b..8879f1625a6c 100644 --- a/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/samples/async/sample_deploy_project_async.py +++ b/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/samples/async/sample_deploy_project_async.py @@ -9,6 +9,14 @@ DESCRIPTION: This sample demonstrates how to deploy a trained model to a deployment slot in a Conversation Authoring project (async). + + NOTE ABOUT API VERSIONS: + - In the 2025-11-01 GA service version: + * `azureResourceIds` is a list of strings (resource IDs). + - In the 2025-11-15-preview service version: + * `azureResourceIds` is a list of AssignedProjectResource objects + (includes resource ID, region, and optional data-generation settings). + USAGE: python sample_deploy_project_async.py @@ -35,24 +43,74 @@ from azure.identity import DefaultAzureCredential from azure.core.exceptions import HttpResponseError from azure.ai.language.conversations.authoring.aio import ConversationAuthoringClient -from azure.ai.language.conversations.authoring.models import CreateDeploymentDetails +from azure.ai.language.conversations.authoring.models import ( + CreateDeploymentDetails, + AssignedProjectResource, + # DataGenerationConnectionInfo, # uncomment if you need AOAI data generation settings +) async def sample_deploy_project_async(): - # settings + # Settings endpoint = os.environ["AZURE_CONVERSATIONS_AUTHORING_ENDPOINT"] project_name = os.environ.get("PROJECT_NAME", "") deployment_name = os.environ.get("DEPLOYMENT_NAME", "") trained_model_label = os.environ.get("TRAINED_MODEL", "") credential = DefaultAzureCredential() + + # 1) 2025-11-01 GA: + # async with ConversationAuthoringClient( + # endpoint, + # credential=credential, + # api_version="2025-11-01", + # ) as client: + + # 2) 2025-11-15-preview (current default): async with ConversationAuthoringClient(endpoint, credential=credential) as client: project_client = client.get_project_client(project_name) - # build deployment request + # Minimal request (works for both versions). details = CreateDeploymentDetails(trained_model_label=trained_model_label) - # start deploy (async long-running operation) + # --- Example for 2025-11-01 GA: azureResourceIds as list[str] ---------------- + # + # azure_resource_ids = [ + # "/subscriptions//resourceGroups//" + # "providers/Microsoft.CognitiveServices/accounts/", + # "/subscriptions//resourceGroups//" + # "providers/Microsoft.CognitiveServices/accounts/", + # ] + # + # details = CreateDeploymentDetails( + # trained_model_label=trained_model_label, + # azure_resource_ids=azure_resource_ids, + # ) + + # --- Example for 2025-11-15-preview: azureResourceIds as AssignedProjectResource -- + # + # assigned_resource = AssignedProjectResource( + # resource_id=( + # "/subscriptions//resourceGroups//" + # "providers/Microsoft.CognitiveServices/accounts/" + # ), + # region="", # e.g. "westus2" + # # assigned_aoai_resource=DataGenerationConnectionInfo( + # # kind="AzureOpenAI", + # # deployment_name="", + # # resource_id=( + # # "/subscriptions//resourceGroups//" + # # "providers/Microsoft.CognitiveServices/accounts/" + # # ), + # # ), + # ) + # + # details = CreateDeploymentDetails( + # trained_model_label=trained_model_label, + # azure_resource_ids=[assigned_resource], + # ) + + # Start deploy poller = await project_client.deployment.begin_deploy_project( deployment_name=deployment_name, body=details, diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/samples/sample_deploy_project.py b/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/samples/sample_deploy_project.py index a08f132454d6..467eaf93746b 100644 --- a/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/samples/sample_deploy_project.py +++ b/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/samples/sample_deploy_project.py @@ -9,6 +9,14 @@ DESCRIPTION: This sample demonstrates how to deploy a trained model to a deployment slot in a Conversation Authoring project. + + NOTE ABOUT API VERSIONS: + - In the 2025-11-01 GA service version: + * `azureResourceIds` is a list of strings (resource IDs). + - In the 2025-11-15-preview service version: + * `azureResourceIds` is a list of AssignedProjectResource objects + (includes resource ID, region, and optional data-generation settings). + USAGE: python sample_deploy_project.py @@ -34,25 +42,77 @@ from azure.identity import DefaultAzureCredential from azure.core.exceptions import HttpResponseError from azure.ai.language.conversations.authoring import ConversationAuthoringClient -from azure.ai.language.conversations.authoring.models import CreateDeploymentDetails +from azure.ai.language.conversations.authoring.models import ( + CreateDeploymentDetails, + AssignedProjectResource, + # DataGenerationConnectionInfo, # uncomment if you need AOAI data generation settings +) def sample_deploy_project(): - # settings + # Settings endpoint = os.environ["AZURE_CONVERSATIONS_AUTHORING_ENDPOINT"] project_name = os.environ.get("PROJECT_NAME", "") deployment_name = os.environ.get("DEPLOYMENT_NAME", "") trained_model_label = os.environ.get("TRAINED_MODEL", "") - # create a client with AAD + # Create a client with AAD credential = DefaultAzureCredential() + + # 1) 2025-11-01 GA: + # client = ConversationAuthoringClient( + # endpoint, + # credential=credential, + # api_version="2025-11-01", + # ) + + # 2) 2025-11-15-preview (current default): client = ConversationAuthoringClient(endpoint, credential=credential) + project_client = client.get_project_client(project_name) - # build deployment request + # Minimal request (works for both versions). details = CreateDeploymentDetails(trained_model_label=trained_model_label) - # start deploy (long-running operation) + # --- Example for 2025-11-01 GA: azureResourceIds as list[str] ---------------- + # Use this pattern when you are targeting the 2025-11-01 GA version + # azure_resource_ids = [ + # "/subscriptions//resourceGroups//" + # "providers/Microsoft.CognitiveServices/accounts/", + # "/subscriptions//resourceGroups//" + # "providers/Microsoft.CognitiveServices/accounts/", + # ] + # + # details = CreateDeploymentDetails( + # trained_model_label=trained_model_label, + # azure_resource_ids=azure_resource_ids, + # ) + + # --- Example for 2025-11-15-preview: azureResourceIds as AssignedProjectResource -- + # Use this pattern when you are targeting the 2025-11-15-preview version + # + # assigned_resource = AssignedProjectResource( + # resource_id=( + # "/subscriptions//resourceGroups//" + # "providers/Microsoft.CognitiveServices/accounts/" + # ), + # region="", # e.g. "westus2" + # # assigned_aoai_resource=DataGenerationConnectionInfo( + # # kind="AzureOpenAI", + # # deployment_name="", + # # resource_id=( + # # "/subscriptions//resourceGroups//" + # # "providers/Microsoft.CognitiveServices/accounts/" + # # ), + # # ), + # ) + # + # details = CreateDeploymentDetails( + # trained_model_label=trained_model_label, + # azure_resource_ids=[assigned_resource], + # ) + + # Deploy the project poller = project_client.deployment.begin_deploy_project( deployment_name=deployment_name, body=details, @@ -76,4 +136,4 @@ def main(): if __name__ == "__main__": - main() + main() \ No newline at end of file diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/tests/conftest.py b/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/tests/conftest.py index 2eee1ac4747d..fdc882e5cf09 100644 --- a/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/tests/conftest.py +++ b/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/tests/conftest.py @@ -1,9 +1,23 @@ import pytest +from devtools_testutils import EnvironmentVariableLoader +# Environment variable keys +ENV_ENDPOINT = "AUTHORING_ENDPOINT" +ENV_KEY = "AUTHORING_KEY" -# autouse=True will trigger this fixture on each pytest run, even if it's not explicitly used by a test method +@pytest.fixture(scope="session") +def authoring_endpoint(environment_variables: EnvironmentVariableLoader) -> str: + """Endpoint for Authoring tests.""" + return environment_variables.get(ENV_ENDPOINT) + +@pytest.fixture(scope="session") +def authoring_key(environment_variables: EnvironmentVariableLoader) -> str: + """API key for Authoring tests.""" + return environment_variables.get(ENV_KEY) + +# autouse=True will trigger this fixture on each pytest run # test_proxy auto-starts the test proxy -# patch_sleep and patch_async_sleep streamline tests by disabling wait times during LRO polling +# patch_sleep and patch_async_sleep remove wait times during polling @pytest.fixture(scope="session", autouse=True) def start_proxy(test_proxy, patch_sleep, patch_async_sleep): - return + return \ No newline at end of file diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/tests/test_deploy_project.py b/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/tests/test_deploy_project.py index c81759b4424c..e433b35709a1 100644 --- a/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/tests/test_deploy_project.py +++ b/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/tests/test_deploy_project.py @@ -5,7 +5,7 @@ from azure.core.credentials import AzureKeyCredential from azure.core.exceptions import HttpResponseError from azure.ai.language.conversations.authoring import ConversationAuthoringClient -from azure.ai.language.conversations.authoring.models import CreateDeploymentDetails, DeploymentState +from azure.ai.language.conversations.authoring.models import CreateDeploymentDetails, AssignedProjectResource ConversationsPreparer = functools.partial( EnvironmentVariableLoader, @@ -26,14 +26,21 @@ class TestConversationsDeployProjectSync(TestConversations): def test_deploy_project(self, authoring_endpoint, authoring_key): client = self.create_client(authoring_endpoint, authoring_key) - project_name = "EmailApp" + project_name = "EmailAppEnglish" deployment_name = "staging0828" - trained_model_label = "Model1" + trained_model_label = "ModelWithDG" project_client = client.get_project_client(project_name) # Build request body for deployment - details = CreateDeploymentDetails(trained_model_label=trained_model_label) + details = CreateDeploymentDetails(trained_model_label=trained_model_label, + azure_resource_ids=[ + AssignedProjectResource( + resource_id="/subscriptions/b72743ec-8bb3-453f-83ad-a53e8a50712e/resourceGroups/language-sdk-rg/providers/Microsoft.CognitiveServices/accounts/sdk-test-02", + region="eastus2", + ) + ], + ) # Act: begin deploy and wait for completion poller = project_client.deployment.begin_deploy_project( diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/tests/test_deploy_project_async.py b/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/tests/test_deploy_project_async.py index 39a7136c031d..10bcd98b4e40 100644 --- a/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/tests/test_deploy_project_async.py +++ b/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/tests/test_deploy_project_async.py @@ -7,7 +7,7 @@ from azure.core.credentials import AzureKeyCredential from azure.core.exceptions import HttpResponseError from azure.ai.language.conversations.authoring.aio import ConversationAuthoringClient -from azure.ai.language.conversations.authoring.models import CreateDeploymentDetails, DeploymentState +from azure.ai.language.conversations.authoring.models import CreateDeploymentDetails, AssignedProjectResource ConversationsPreparer = functools.partial( EnvironmentVariableLoader, @@ -29,14 +29,21 @@ class TestConversationsDeployProjectAsync(TestConversationsAsync): async def test_deploy_project_async(self, authoring_endpoint, authoring_key): client = await self.create_client(authoring_endpoint, authoring_key) async with client: - project_name = "EmailApp" - deployment_name = "0828Deployment" - trained_model_label = "Model1" + project_name = "EmailAppEnglish" + deployment_name = "staging0828" + trained_model_label = "ModelWithDG" project_client = client.get_project_client(project_name) # Build request body for deployment - details = CreateDeploymentDetails(trained_model_label=trained_model_label) + details = CreateDeploymentDetails(trained_model_label=trained_model_label, + azure_resource_ids=[ + AssignedProjectResource( + resource_id="/subscriptions/b72743ec-8bb3-453f-83ad-a53e8a50712e/resourceGroups/language-sdk-rg/providers/Microsoft.CognitiveServices/accounts/sdk-test-02", + region="eastus2", + ) + ], + ) # Act: begin deploy and wait for completion poller = await project_client.deployment.begin_deploy_project( diff --git a/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/tsp-location.yaml b/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/tsp-location.yaml index 8f1d414b7cc9..4c0573e27169 100644 --- a/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/tsp-location.yaml +++ b/sdk/cognitivelanguage/azure-ai-language-conversations-authoring/tsp-location.yaml @@ -1,4 +1,4 @@ directory: specification/cognitiveservices/data-plane/LanguageAnalyzeConversationsAuthoring -commit: 220549c6a9ec23f681e4e3eda90189beacb7937b +commit: f12896221fcba181f270233087874d183e312910 repo: Azure/azure-rest-api-specs additionalDirectories: