diff --git a/sdk/ai/azure-ai-projects/CHANGELOG.md b/sdk/ai/azure-ai-projects/CHANGELOG.md index 617ef01614f8..268e077cc801 100644 --- a/sdk/ai/azure-ai-projects/CHANGELOG.md +++ b/sdk/ai/azure-ai-projects/CHANGELOG.md @@ -2,9 +2,20 @@ ## 2.6.0 (Unreleased) +### Features Added + +* Added the preview `.beta.agent_insight_monitors` subclient with operations to create, get, list, update, delete, and reset monitors; create, get, list, and cancel runs; and get, list, and update insights. `begin_create_run` returns a new `AgentInsightRunLROPoller` whose `details` property exposes the run ID. Added 20 supporting `AgentInsight*` models and six enums covering monitors, runs, generated insights, proposed fixes, highlighted and linked traces, costs, token usage, severity, status, and run triggers. +* Added Microsoft 365 agent publishing through `.agents.publish_to_microsoft365`, `.agents.get_microsoft365_package`, and `.agents.get_microsoft365_publish_defaults`, along with `Microsoft365PermissionScopes`, `Microsoft365PublishDefaults`, `Microsoft365PublishResult`, and `Microsoft365PublishScope`. +* Added the optional `AgentDetails.digital_worker_type` property and the new `DigitalWorkerType` enum for Microsoft 365 digital workers. Added activity-protocol access boundaries and the read-only `AgentEndpointConfig.publish_approval_status` property with the new `ActivityProtocolAccessBoundary` and `PublishApprovalStatus` enums. +* Added optional Hosted Agent session defaults through `HostedAgentDefinition.session_configuration` and `SessionConfiguration`, including idle-timeout configuration. +* Added the optional `authorization` argument to `.beta.routines.create_or_update`, with `RoutineAuthorization` and `RoutineDispatchIdentity` for selecting the agent or routine creator identity. +* Added `ShellToolboxTool` and supporting container environment and network policy models, with the new `ToolboxToolType.SHELL` enum member. +* Added `WebIQPreviewTool` and `WebIQPreviewToolboxTool`, with new `ToolType.WEB_IQ_PREVIEW` and `ToolboxToolType.WEB_IQ_PREVIEW` enum members. These API and model additions are included in [GitHub pull request 48795](https://github.com/Azure/azure-sdk-for-python/pull/48795). + ### Bugs Fixed * Fixed Responses API instrumentation for `with_raw_response` streaming calls ([GitHub issue 48646](https://github.com/Azure/azure-sdk-for-python/issues/48646)). +* Fixed preview header composition so non-voice Agent requests no longer include the `VoiceAgents=V1Preview` opt-in ([GitHub pull request 48795](https://github.com/Azure/azure-sdk-for-python/pull/48795)). ## 2.5.0 (2026-08-20) diff --git a/sdk/ai/azure-ai-projects/api.md b/sdk/ai/azure-ai-projects/api.md index a2e744e83a4f..7ebc65377d74 100644 --- a/sdk/ai/azure-ai-projects/api.md +++ b/sdk/ai/azure-ai-projects/api.md @@ -282,6 +282,60 @@ namespace azure.ai.projects.aio.operations **kwargs: Any ) -> AgentDetails: ... + @overload + async def get_microsoft365_package( + self, + agent_name: str, + *, + access_boundaries: Optional[List[Union[str, ActivityProtocolAccessBoundary]]] = ..., + agent_display_name: Optional[str] = ..., + app_version: Optional[str] = ..., + bot_service_arm_id: Optional[str] = ..., + can_respond_without_mention: Optional[bool] = ..., + color_icon_base64: Optional[str] = ..., + content_type: str = "application/json", + developer_name: Optional[str] = ..., + developer_website_url: Optional[str] = ..., + full_description: Optional[str] = ..., + optional_permission_scopes: Optional[List[Microsoft365PermissionScopes]] = ..., + outline_icon_base64: Optional[str] = ..., + privacy_url: Optional[str] = ..., + publish_as_autopilot: Optional[bool] = ..., + publish_scope: Union[str, Microsoft365PublishScope], + short_description: Optional[str] = ..., + terms_of_use_url: Optional[str] = ..., + **kwargs: Any + ) -> AsyncIterator[bytes]: ... + + @overload + async def get_microsoft365_package( + self, + agent_name: str, + body: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncIterator[bytes]: ... + + @overload + async def get_microsoft365_package( + self, + agent_name: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncIterator[bytes]: ... + + @distributed_trace_async + async def get_microsoft365_publish_defaults( + self, + agent_name: str, + *, + publish_as_digital_worker: Optional[bool] = ..., + **kwargs: Any + ) -> Microsoft365PublishDefaults: ... + @distributed_trace_async async def get_session( self, @@ -354,6 +408,51 @@ namespace azure.ai.projects.aio.operations **kwargs: Any ) -> AsyncItemPaged[AgentVersionDetails]: ... + @overload + async def publish_to_microsoft365( + self, + agent_name: str, + *, + access_boundaries: Optional[List[Union[str, ActivityProtocolAccessBoundary]]] = ..., + agent_display_name: Optional[str] = ..., + app_version: Optional[str] = ..., + bot_service_arm_id: Optional[str] = ..., + can_respond_without_mention: Optional[bool] = ..., + color_icon_base64: Optional[str] = ..., + content_type: str = "application/json", + developer_name: Optional[str] = ..., + developer_website_url: Optional[str] = ..., + full_description: Optional[str] = ..., + optional_permission_scopes: Optional[List[Microsoft365PermissionScopes]] = ..., + outline_icon_base64: Optional[str] = ..., + privacy_url: Optional[str] = ..., + publish_as_autopilot: Optional[bool] = ..., + publish_scope: Union[str, Microsoft365PublishScope], + short_description: Optional[str] = ..., + terms_of_use_url: Optional[str] = ..., + **kwargs: Any + ) -> Microsoft365PublishResult: ... + + @overload + async def publish_to_microsoft365( + self, + agent_name: str, + body: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Microsoft365PublishResult: ... + + @overload + async def publish_to_microsoft365( + self, + agent_name: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Microsoft365PublishResult: ... + @distributed_trace_async async def stop_session( self, @@ -418,6 +517,221 @@ namespace azure.ai.projects.aio.operations ) -> SessionFileWriteResult: ... + class azure.ai.projects.aio.operations.BetaAgentInsightMonitorsOperations(BetaAgentInsightMonitorsOperationsGenerated): + + def __init__( + self, + *args, + **kwargs + ) -> None: ... + + @overload + async def begin_create_run( + self, + monitor_id: str, + run: AgentInsightRunCreate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncAgentInsightRunLROPoller: ... + + @overload + async def begin_create_run( + self, + monitor_id: str, + run: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncAgentInsightRunLROPoller: ... + + @overload + async def begin_create_run( + self, + monitor_id: str, + run: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AsyncAgentInsightRunLROPoller: ... + + @distributed_trace_async + async def cancel_run( + self, + monitor_id: str, + run_id: str, + **kwargs: Any + ) -> AgentInsightRun: ... + + @overload + async def create( + self, + monitor: AgentInsightMonitorCreate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AgentInsightMonitor: ... + + @overload + async def create( + self, + monitor: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AgentInsightMonitor: ... + + @overload + async def create( + self, + monitor: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AgentInsightMonitor: ... + + @distributed_trace_async + async def delete( + self, + monitor_id: str, + **kwargs: Any + ) -> None: ... + + @distributed_trace_async + async def get( + self, + monitor_id: str, + **kwargs: Any + ) -> AgentInsightMonitor: ... + + @distributed_trace_async + async def get_insight( + self, + monitor_id: str, + insight_id: str, + *, + include_details: Optional[bool] = ..., + **kwargs: Any + ) -> AgentInsight: ... + + @distributed_trace_async + async def get_run( + self, + monitor_id: str, + run_id: str, + **kwargs: Any + ) -> AgentInsightRun: ... + + @distributed_trace + def list( + self, + *, + agent_name: Optional[str] = ..., + before: Optional[str] = ..., + limit: Optional[int] = ..., + order: Optional[Union[str, PageOrder]] = ..., + **kwargs: Any + ) -> AsyncItemPaged[AgentInsightMonitorListItem]: ... + + @distributed_trace + def list_insights( + self, + monitor_id: str, + *, + before: Optional[str] = ..., + category: Optional[str] = ..., + include_details: Optional[bool] = ..., + limit: Optional[int] = ..., + order: Optional[Union[str, PageOrder]] = ..., + severity: Optional[Union[str, AgentInsightSeverity]] = ..., + status: Optional[Union[str, AgentInsightStatus]] = ..., + **kwargs: Any + ) -> AsyncItemPaged[AgentInsight]: ... + + @distributed_trace + def list_runs( + self, + monitor_id: str, + *, + before: Optional[str] = ..., + limit: Optional[int] = ..., + order: Optional[Union[str, PageOrder]] = ..., + status: Optional[Union[str, JobStatus]] = ..., + trigger: Optional[Union[str, AgentInsightRunTrigger]] = ..., + **kwargs: Any + ) -> AsyncItemPaged[AgentInsightRun]: ... + + @distributed_trace_async + async def reset( + self, + monitor_id: str, + **kwargs: Any + ) -> None: ... + + @overload + async def update( + self, + monitor_id: str, + monitor: AgentInsightMonitorUpdate, + *, + content_type: str = "application/merge-patch+json", + **kwargs: Any + ) -> AgentInsightMonitor: ... + + @overload + async def update( + self, + monitor_id: str, + monitor: JSON, + *, + content_type: str = "application/merge-patch+json", + **kwargs: Any + ) -> AgentInsightMonitor: ... + + @overload + async def update( + self, + monitor_id: str, + monitor: IO[bytes], + *, + content_type: str = "application/merge-patch+json", + **kwargs: Any + ) -> AgentInsightMonitor: ... + + @overload + async def update_insight( + self, + monitor_id: str, + insight_id: str, + update: AgentInsightUpdate, + *, + content_type: str = "application/merge-patch+json", + **kwargs: Any + ) -> AgentInsight: ... + + @overload + async def update_insight( + self, + monitor_id: str, + insight_id: str, + update: JSON, + *, + content_type: str = "application/merge-patch+json", + **kwargs: Any + ) -> AgentInsight: ... + + @overload + async def update_insight( + self, + monitor_id: str, + insight_id: str, + update: IO[bytes], + *, + content_type: str = "application/merge-patch+json", + **kwargs: Any + ) -> AgentInsight: ... + + class azure.ai.projects.aio.operations.BetaAgentsOperations(BetaAgentsOperationsGenerated): def __init__( @@ -1458,6 +1772,7 @@ namespace azure.ai.projects.aio.operations class azure.ai.projects.aio.operations.BetaOperations(GeneratedBetaOperations): + agent_insight_monitors: BetaAgentInsightMonitorsOperations agents: BetaAgentsOperations datasets: BetaDatasetsOperations evaluation_taxonomies: BetaEvaluationTaxonomiesOperations @@ -1537,6 +1852,7 @@ namespace azure.ai.projects.aio.operations routine_name: str, *, action: Optional[RoutineAction] = ..., + authorization: Optional[RoutineAuthorization] = ..., content_type: str = "application/json", description: Optional[str] = ..., enabled: Optional[bool] = ..., @@ -2467,7 +2783,29 @@ namespace azure.ai.projects.models def __init__(self, mapping: Mapping[str, Any]) -> None: ... + class azure.ai.projects.models.ActivityProtocolAccessBoundary(str, Enum, metaclass=CaseInsensitiveEnumMeta): + READ1_ON1_ALLOWLISTED = "read.1on1.allowlisted" + READ1_ON1_DEVELOPERS = "read.1on1.developers" + READ1_ON1_MANAGER = "read.1on1.manager" + READ1_ON1_TENANT = "read.1on1.tenant" + READ_GROUP_ALLOWLISTED = "read.group.allowlisted" + READ_GROUP_DEVELOPERS = "read.group.developers" + READ_GROUP_MANAGER_INVITED = "read.group.manager-invited" + READ_GROUP_MANAGER_PRESENT = "read.group.manager-present" + READ_GROUP_TENANT = "read.group.tenant" + WRITE1_ON1_ALLOWLISTED = "write.1on1.allowlisted" + WRITE1_ON1_DEVELOPERS = "write.1on1.developers" + WRITE1_ON1_MANAGER = "write.1on1.manager" + WRITE1_ON1_TENANT = "write.1on1.tenant" + WRITE_GROUP_ALLOWLISTED = "write.group.allowlisted" + WRITE_GROUP_DEVELOPERS = "write.group.developers" + WRITE_GROUP_MANAGER_INVITED = "write.group.manager-invited" + WRITE_GROUP_MANAGER_PRESENT = "write.group.manager-present" + WRITE_GROUP_TENANT = "write.group.tenant" + + class azure.ai.projects.models.ActivityProtocolConfiguration(_Model): + access_boundaries: Optional[list[Union[str, ActivityProtocolAccessBoundary]]] enable_m365_public_endpoint: Optional[bool] @overload @@ -2611,6 +2949,7 @@ namespace azure.ai.projects.models agent_endpoint: Optional[AgentEndpointConfig] blueprint: Optional[AgentIdentity] blueprint_reference: Optional[AgentBlueprintReference] + digital_worker_type: Optional[Union[str, DigitalWorkerType]] id: str instance_identity: Optional[AgentIdentity] name: str @@ -2625,6 +2964,7 @@ namespace azure.ai.projects.models *, agent_card: Optional[AgentCard] = ..., agent_endpoint: Optional[AgentEndpointConfig] = ..., + digital_worker_type: Optional[Union[str, DigitalWorkerType]] = ..., id: str, name: str, object: Literal[AgentObjectType.AGENT], @@ -2659,6 +2999,7 @@ namespace azure.ai.projects.models class azure.ai.projects.models.AgentEndpointConfig(_Model): authorization_schemes: Optional[list[AgentEndpointAuthorizationScheme]] protocol_configuration: Optional[ProtocolConfiguration] + publish_approval_status: Optional[Union[str, PublishApprovalStatus]] version_selector: Optional[VersionSelector] @overload @@ -2725,86 +3066,489 @@ namespace azure.ai.projects.models DISABLED = "disabled" - class azure.ai.projects.models.AgentKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): - EXTERNAL = "external" - HOSTED = "hosted" - PROMPT = "prompt" - WORKFLOW = "workflow" - - - class azure.ai.projects.models.AgentObjectType(str, Enum, metaclass=CaseInsensitiveEnumMeta): - AGENT = "agent" - AGENT_CONTAINER = "agent.container" - AGENT_DELETED = "agent.deleted" - AGENT_VERSION = "agent.version" - AGENT_VERSION_DELETED = "agent.version.deleted" + class azure.ai.projects.models.AgentInsight(_Model): + agent_name: str + agent_version: str + category: str + created_at: datetime + description: str + details: Optional[AgentInsightDetails] + id: str + monitor_id: str + severity: Union[str, AgentInsightSeverity] + status: Union[str, AgentInsightStatus] + title: str + trace_count: int + updated_at: datetime - class azure.ai.projects.models.AgentObjectVersions(_Model): - latest: AgentVersionDetails + class azure.ai.projects.models.AgentInsightDetails(_Model): + highlighted_traces: list[AgentInsightHighlightedTrace] + linked_traces: list[AgentInsightLinkedTrace] + recommended_actions: AgentInsightRecommendedAction @overload def __init__( self, *, - latest: AgentVersionDetails + highlighted_traces: list[AgentInsightHighlightedTrace], + linked_traces: list[AgentInsightLinkedTrace], + recommended_actions: AgentInsightRecommendedAction ) -> None: ... @overload def __init__(self, mapping: Mapping[str, Any]) -> None: ... - class azure.ai.projects.models.AgentOptimizationCandidate(_Model): - avg_score: float - avg_tokens: float - candidate_id: Optional[str] - eval_id: Optional[str] - eval_run_id: Optional[str] - mutations: Optional[dict[str, Any]] - name: str - promotion: Optional[PromotionInfo] + class azure.ai.projects.models.AgentInsightEstimatedCost(_Model): + amount: float + currency: Literal["USD"] @overload def __init__( self, *, - avg_score: float, - avg_tokens: float, - candidate_id: Optional[str] = ..., - eval_id: Optional[str] = ..., - eval_run_id: Optional[str] = ..., - mutations: Optional[dict[str, Any]] = ..., - name: str, - promotion: Optional[PromotionInfo] = ... + amount: float ) -> None: ... @overload def __init__(self, mapping: Mapping[str, Any]) -> None: ... - class azure.ai.projects.models.AgentOptimizationDatasetCriterion(_Model): - instruction: str - name: str + class azure.ai.projects.models.AgentInsightHighlightedTrace(_Model): + duration_ms: timedelta + summary: str + timestamp: datetime + total_tokens: Optional[int] + trace_id: str @overload def __init__( self, *, - instruction: str, - name: str + duration_ms: timedelta, + summary: str, + timestamp: datetime, + total_tokens: Optional[int] = ... ) -> None: ... @overload def __init__(self, mapping: Mapping[str, Any]) -> None: ... - class azure.ai.projects.models.AgentOptimizationDatasetInput(_Model): - type: str + class azure.ai.projects.models.AgentInsightLinkedTrace(_Model): + timestamp: datetime + trace_id: str - @overload - def __init__( - self, - *, + + class azure.ai.projects.models.AgentInsightMonitor(_Model): + agent_name: str + enabled: bool + estimated_cost: Optional[AgentInsightEstimatedCost] + id: str + model_deployment_name: str + next_scheduled_run_at: Optional[datetime] + overview: AgentInsightsOverview + run_interval_hours: float + suspension: AgentInsightSuspension + updated_at: datetime + + + class azure.ai.projects.models.AgentInsightMonitorCreate(_Model): + agent_name: str + enabled: Optional[bool] + model_deployment_name: str + run_interval_hours: Optional[float] + + @overload + def __init__( + self, + *, + agent_name: str, + enabled: Optional[bool] = ..., + model_deployment_name: str, + run_interval_hours: Optional[float] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.ai.projects.models.AgentInsightMonitorListItem(_Model): + agent_name: str + enabled: bool + estimated_cost: Optional[AgentInsightEstimatedCost] + id: str + model_deployment_name: str + next_scheduled_run_at: Optional[datetime] + run_interval_hours: float + suspension: AgentInsightSuspension + updated_at: datetime + + + class azure.ai.projects.models.AgentInsightMonitorUpdate(_Model): + enabled: Optional[bool] + model_deployment_name: Optional[str] + overview_override: Optional[AgentInsightsOverviewOverride] + run_interval_hours: Optional[float] + + @overload + def __init__( + self, + *, + enabled: Optional[bool] = ..., + model_deployment_name: Optional[str] = ..., + overview_override: Optional[AgentInsightsOverviewOverride] = ..., + run_interval_hours: Optional[float] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.ai.projects.models.AgentInsightOverviewSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): + GENERATED = "generated" + USER_OVERRIDE = "user_override" + + + class azure.ai.projects.models.AgentInsightPromptSurface(str, Enum, metaclass=CaseInsensitiveEnumMeta): + INSTRUCTIONS = "instructions" + TOOL = "tool" + + + class azure.ai.projects.models.AgentInsightProposedFix(_Model): + changes: Optional[list[AgentInsightProposedFixChange]] + kind: Union[str, AgentInsightProposedFixKind] + text: str + + @overload + def __init__( + self, + *, + changes: Optional[list[AgentInsightProposedFixChange]] = ..., + kind: Union[str, AgentInsightProposedFixKind], + text: str + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.ai.projects.models.AgentInsightProposedFixChange(_Model): + diff: Optional[str] + language: Optional[str] + new_value: Optional[Any] + old_value: Optional[Any] + path: Optional[str] + surface: Optional[Union[str, AgentInsightPromptSurface]] + target: Optional[str] + + @overload + def __init__( + self, + *, + diff: Optional[str] = ..., + language: Optional[str] = ..., + new_value: Optional[Any] = ..., + old_value: Optional[Any] = ..., + path: Optional[str] = ..., + surface: Optional[Union[str, AgentInsightPromptSurface]] = ..., + target: Optional[str] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.ai.projects.models.AgentInsightProposedFixKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): + CODE_CHANGE = "code_change" + PROMPT_CHANGE = "prompt_change" + PROSE = "prose" + + + class azure.ai.projects.models.AgentInsightRecommendedAction(_Model): + proposed_fix: AgentInsightProposedFix + + @overload + def __init__( + self, + *, + proposed_fix: AgentInsightProposedFix + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.ai.projects.models.AgentInsightRun(_Model): + agent_name: str + completed_at: Optional[datetime] + created_at: datetime + error: Optional[ApiError] + id: str + inputs: Optional[AgentInsightRunCreate] + model_deployment_name: str + monitor_id: str + result: Optional[AgentInsightRunResult] + started_at: Optional[datetime] + status: Union[str, JobStatus] + trigger: Union[str, AgentInsightRunTrigger] + updated_at: datetime + window_end: datetime + window_start: datetime + + @overload + def __init__( + self, + *, + inputs: Optional[AgentInsightRunCreate] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.ai.projects.models.AgentInsightRunCreate(_Model): + lookback_hours: Optional[float] + + @overload + def __init__( + self, + *, + lookback_hours: Optional[float] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.ai.projects.models.AgentInsightRunLROPoller(LROPoller[AgentInsightRunResult]): + property details: Mapping[str, Any] # Read-only + + def __init__( + self, + client: Any, + initial_response: Any, + deserialization_callback: Any, + polling_method: Any + ) -> None: ... + + @classmethod + def from_continuation_token( + cls, + polling_method: PollingMethod[AgentInsightRunResult], + continuation_token: str, + **kwargs: Any + ) -> AgentInsightRunLROPoller: ... + + + class azure.ai.projects.models.AgentInsightRunResult(_Model): + insights_created: int + insights_reopened: int + insights_updated: int + token_usage: AgentInsightTokenUsage + traces_analyzed: int + traces_in_window: int + + @overload + def __init__( + self, + *, + insights_created: int, + insights_reopened: int, + insights_updated: int, + token_usage: AgentInsightTokenUsage, + traces_analyzed: int, + traces_in_window: int + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.ai.projects.models.AgentInsightRunTrigger(str, Enum, metaclass=CaseInsensitiveEnumMeta): + ON_DEMAND = "on_demand" + SCHEDULED = "scheduled" + + + class azure.ai.projects.models.AgentInsightSeverity(str, Enum, metaclass=CaseInsensitiveEnumMeta): + HIGH = "high" + LOW = "low" + MEDIUM = "medium" + + + class azure.ai.projects.models.AgentInsightStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + ACTIVE = "active" + IGNORED = "ignored" + RESOLVED = "resolved" + + + class azure.ai.projects.models.AgentInsightSuspension(_Model): + code: str + details: Optional[dict[str, Any]] + message: str + occurred_at: datetime + + @overload + def __init__( + self, + *, + code: str, + details: Optional[dict[str, Any]] = ..., + message: str, + occurred_at: datetime + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.ai.projects.models.AgentInsightTokenUsage(_Model): + cached_tokens: Optional[int] + input_tokens: int + output_tokens: int + total_tokens: int + + @overload + def __init__( + self, + *, + cached_tokens: Optional[int] = ..., + input_tokens: int, + output_tokens: int, + total_tokens: int + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.ai.projects.models.AgentInsightUpdate(_Model): + status: Optional[Union[str, AgentInsightStatus]] + + @overload + def __init__( + self, + *, + status: Optional[Union[str, AgentInsightStatus]] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.ai.projects.models.AgentInsightsOverview(_Model): + content: str + source: Union[str, AgentInsightOverviewSource] + updated_at: datetime + + @overload + def __init__( + self, + *, + content: str, + source: Union[str, AgentInsightOverviewSource], + updated_at: datetime + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.ai.projects.models.AgentInsightsOverviewOverride(_Model): + content: str + + @overload + def __init__( + self, + *, + content: str + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.ai.projects.models.AgentKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): + EXTERNAL = "external" + HOSTED = "hosted" + PROMPT = "prompt" + WORKFLOW = "workflow" + + + class azure.ai.projects.models.AgentObjectType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + AGENT = "agent" + AGENT_CONTAINER = "agent.container" + AGENT_DELETED = "agent.deleted" + AGENT_VERSION = "agent.version" + AGENT_VERSION_DELETED = "agent.version.deleted" + + + class azure.ai.projects.models.AgentObjectVersions(_Model): + latest: AgentVersionDetails + + @overload + def __init__( + self, + *, + latest: AgentVersionDetails + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.ai.projects.models.AgentOptimizationCandidate(_Model): + avg_score: float + avg_tokens: float + candidate_id: Optional[str] + eval_id: Optional[str] + eval_run_id: Optional[str] + mutations: Optional[dict[str, Any]] + name: str + promotion: Optional[PromotionInfo] + + @overload + def __init__( + self, + *, + avg_score: float, + avg_tokens: float, + candidate_id: Optional[str] = ..., + eval_id: Optional[str] = ..., + eval_run_id: Optional[str] = ..., + mutations: Optional[dict[str, Any]] = ..., + name: str, + promotion: Optional[PromotionInfo] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.ai.projects.models.AgentOptimizationDatasetCriterion(_Model): + instruction: str + name: str + + @overload + def __init__( + self, + *, + instruction: str, + name: str + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.ai.projects.models.AgentOptimizationDatasetInput(_Model): + type: str + + @overload + def __init__( + self, + *, type: str ) -> None: ... @@ -3235,6 +3979,26 @@ namespace azure.ai.projects.models def __init__(self, mapping: Mapping[str, Any]) -> None: ... + class azure.ai.projects.models.AsyncAgentInsightRunLROPoller(AsyncLROPoller[AgentInsightRunResult]): + property details: Mapping[str, Any] # Read-only + + def __init__( + self, + client: Any, + initial_response: Any, + deserialization_callback: Any, + polling_method: Any + ) -> None: ... + + @classmethod + def from_continuation_token( + cls, + polling_method: AsyncPollingMethod[AgentInsightRunResult], + continuation_token: str, + **kwargs: Any + ) -> AsyncAgentInsightRunLROPoller: ... + + class azure.ai.projects.models.AsyncAgentOptimizationLROPoller(AsyncLROPoller[AgentOptimizationJobResult]): property details: Mapping[str, Any] # Read-only @@ -4936,6 +5700,10 @@ namespace azure.ai.projects.models MODEL_DEPLOYMENT = "ModelDeployment" + class azure.ai.projects.models.DigitalWorkerType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + M365 = "m365" + + class azure.ai.projects.models.Dimension(_Model): always_applicable: Optional[bool] description: str @@ -6101,6 +6869,7 @@ namespace azure.ai.projects.models memory: str protocol_versions: Optional[list[ProtocolVersionRecord]] rai_config: RaiConfig + session_configuration: Optional[SessionConfiguration] telemetry_config: Optional[TelemetryConfig] @overload @@ -6114,6 +6883,7 @@ namespace azure.ai.projects.models memory: str, protocol_versions: Optional[list[ProtocolVersionRecord]] = ..., rai_config: Optional[RaiConfig] = ..., + session_configuration: Optional[SessionConfiguration] = ..., telemetry_config: Optional[TelemetryConfig] = ... ) -> None: ... @@ -7061,6 +7831,86 @@ namespace azure.ai.projects.models SUPERSEDED = "superseded" + class azure.ai.projects.models.Microsoft365PermissionScopes(_Model): + resource_app_id: str + scopes: list[str] + + @overload + def __init__( + self, + *, + resource_app_id: str, + scopes: list[str] + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.ai.projects.models.Microsoft365PublishDefaults(_Model): + agent_display_name: Optional[str] + agent_name: Optional[str] + app_publish_scope: Optional[Union[str, Microsoft365PublishScope]] + app_registration_client_id: Optional[str] + app_version: Optional[str] + bot_service_arm_id: Optional[str] + developer_name: Optional[str] + developer_website_url: Optional[str] + full_description: Optional[str] + privacy_url: Optional[str] + recommended_next_app_version: Optional[str] + short_description: Optional[str] + teams_app_id: Optional[str] + terms_of_use_url: Optional[str] + title_id: Optional[str] + + @overload + def __init__( + self, + *, + agent_display_name: Optional[str] = ..., + agent_name: Optional[str] = ..., + app_publish_scope: Optional[Union[str, Microsoft365PublishScope]] = ..., + app_registration_client_id: Optional[str] = ..., + app_version: Optional[str] = ..., + bot_service_arm_id: Optional[str] = ..., + developer_name: Optional[str] = ..., + developer_website_url: Optional[str] = ..., + full_description: Optional[str] = ..., + privacy_url: Optional[str] = ..., + recommended_next_app_version: Optional[str] = ..., + short_description: Optional[str] = ..., + teams_app_id: Optional[str] = ..., + terms_of_use_url: Optional[str] = ..., + title_id: Optional[str] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.ai.projects.models.Microsoft365PublishResult(_Model): + teams_app_id: Optional[str] + title_id: Optional[str] + + @overload + def __init__( + self, + *, + teams_app_id: Optional[str] = ..., + title_id: Optional[str] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.ai.projects.models.Microsoft365PublishScope(str, Enum, metaclass=CaseInsensitiveEnumMeta): + PERSONAL = "Personal" + SHARED = "Shared" + TENANT = "Tenant" + + class azure.ai.projects.models.MicrosoftFabricPreviewTool(Tool, discriminator='fabric_dataagent_preview'): fabric_dataagent_preview: FabricDataAgentToolParameters type: Literal[ToolType.FABRIC_DATAAGENT_PREVIEW] @@ -7754,6 +8604,14 @@ namespace azure.ai.projects.models def __init__(self, mapping: Mapping[str, Any]) -> None: ... + class azure.ai.projects.models.PublishApprovalStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + APPROVED = "approved" + NOT_PUBLISHED = "not_published" + NO_APPROVAL_NEEDED = "no_approval_needed" + PENDING = "pending" + REJECTED = "rejected" + + class azure.ai.projects.models.RaiConfig(_Model): rai_policy_name: str @@ -8049,6 +8907,25 @@ namespace azure.ai.projects.models TIMER_DELIVERY = "timer_delivery" + class azure.ai.projects.models.RoutineAuthorization(_Model): + identity: Optional[Union[str, RoutineDispatchIdentity]] + + @overload + def __init__( + self, + *, + identity: Optional[Union[str, RoutineDispatchIdentity]] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.ai.projects.models.RoutineDispatchIdentity(str, Enum, metaclass=CaseInsensitiveEnumMeta): + AGENT = "agent" + CREATOR = "creator" + + class azure.ai.projects.models.RoutineDispatchPayload(_Model): type: str @@ -8341,6 +9218,20 @@ namespace azure.ai.projects.models MEDIUM = "medium" + class azure.ai.projects.models.SessionConfiguration(_Model): + idle_timeout_seconds: Optional[timedelta] + + @overload + def __init__( + self, + *, + idle_timeout_seconds: Optional[timedelta] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + class azure.ai.projects.models.SessionDirectoryEntry(_Model): is_directory: bool modified_time: datetime @@ -8426,6 +9317,29 @@ namespace azure.ai.projects.models def __init__(self, mapping: Mapping[str, Any]) -> None: ... + class azure.ai.projects.models.ShellToolboxTool(ToolboxTool, discriminator='shell'): + allowed_callers: Optional[list[Union[str, CallableToolAllowedCaller]]] + description: str + environment: ToolboxShellEnvironment + name: str + tool_configs: dict[str, ToolConfig] + type: Literal[ToolboxToolType.SHELL] + + @overload + def __init__( + self, + *, + allowed_callers: Optional[list[Union[str, CallableToolAllowedCaller]]] = ..., + description: Optional[str] = ..., + environment: ToolboxShellEnvironment, + name: Optional[str] = ..., + tool_configs: Optional[dict[str, ToolConfig]] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + class azure.ai.projects.models.SimpleQnADataGenerationJobOptions(DataGenerationJobOptions, discriminator='simple_qna'): max_samples: int model_options: DataGenerationModelOptions @@ -9146,6 +10060,7 @@ namespace azure.ai.projects.models SHELL = "shell" TOOLBOX_SEARCH_PREVIEW = "toolbox_search_preview" TOOL_SEARCH = "tool_search" + WEB_IQ_PREVIEW = "web_iq_preview" WEB_SEARCH = "web_search" WEB_SEARCH_PREVIEW = "web_search_preview" WORK_IQ_PREVIEW = "work_iq_preview" @@ -9212,15 +10127,89 @@ namespace azure.ai.projects.models def __init__( self, *, - description: Optional[str] = ..., - name: Optional[str] = ..., - tool_configs: Optional[dict[str, ToolConfig]] = ... + description: Optional[str] = ..., + name: Optional[str] = ..., + tool_configs: Optional[dict[str, ToolConfig]] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.ai.projects.models.ToolboxShellContainerAutoEnvironment(ToolboxShellEnvironment, discriminator='container_auto'): + file_ids: Optional[list[str]] + memory_limit: Optional[Union[str, ContainerMemoryLimit]] + network_policy: Optional[ToolboxShellNetworkPolicy] + skills: Optional[list[ContainerSkill]] + type: Literal["container_auto"] + + @overload + def __init__( + self, + *, + file_ids: Optional[list[str]] = ..., + memory_limit: Optional[Union[str, ContainerMemoryLimit]] = ..., + network_policy: Optional[ToolboxShellNetworkPolicy] = ..., + skills: Optional[list[ContainerSkill]] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.ai.projects.models.ToolboxShellContainerReferenceEnvironment(ToolboxShellEnvironment, discriminator='container_reference'): + container_id: str + type: Literal["container_reference"] + + @overload + def __init__( + self, + *, + container_id: str + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.ai.projects.models.ToolboxShellEnvironment(_Model): + type: str + + @overload + def __init__( + self, + *, + type: str + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.ai.projects.models.ToolboxShellNetworkPolicy(_Model): + type: str + + @overload + def __init__( + self, + *, + type: str ) -> None: ... @overload def __init__(self, mapping: Mapping[str, Any]) -> None: ... + class azure.ai.projects.models.ToolboxShellNetworkPolicyDisabled(ToolboxShellNetworkPolicy, discriminator='disabled'): + type: Literal["disabled"] + + @overload + def __init__(self) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + class azure.ai.projects.models.ToolboxSkill(_Model): type: str @@ -9283,8 +10272,10 @@ namespace azure.ai.projects.models MCP = "mcp" OPENAPI = "openapi" REMINDER_PREVIEW = "reminder_preview" + SHELL = "shell" TOOLBOX_SEARCH = "toolbox_search" TOOLBOX_SEARCH_PREVIEW = "toolbox_search_preview" + WEB_IQ_PREVIEW = "web_iq_preview" WEB_SEARCH = "web_search" WORK_IQ_PREVIEW = "work_iq_preview" @@ -9560,6 +10551,50 @@ namespace azure.ai.projects.models FIXED_RATIO = "FixedRatio" + class azure.ai.projects.models.WebIQPreviewTool(Tool, discriminator='web_iq_preview'): + project_connection_id: str + require_approval: Optional[Union[MCPToolRequireApproval, str]] + server_label: Optional[str] + type: Literal[ToolType.WEB_IQ_PREVIEW] + + @overload + def __init__( + self, + *, + project_connection_id: str, + require_approval: Optional[Union[MCPToolRequireApproval, str]] = ..., + server_label: Optional[str] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + + class azure.ai.projects.models.WebIQPreviewToolboxTool(ToolboxTool, discriminator='web_iq_preview'): + description: str + name: str + project_connection_id: str + require_approval: Optional[Union[MCPToolRequireApproval, str]] + server_label: Optional[str] + tool_configs: dict[str, ToolConfig] + type: Literal[ToolboxToolType.WEB_IQ_PREVIEW] + + @overload + def __init__( + self, + *, + description: Optional[str] = ..., + name: Optional[str] = ..., + project_connection_id: str, + require_approval: Optional[Union[MCPToolRequireApproval, str]] = ..., + server_label: Optional[str] = ..., + tool_configs: Optional[dict[str, ToolConfig]] = ... + ) -> None: ... + + @overload + def __init__(self, mapping: Mapping[str, Any]) -> None: ... + + class azure.ai.projects.models.WebSearchApproximateLocation(_Model): city: Optional[str] country: Optional[str] @@ -9951,6 +10986,60 @@ namespace azure.ai.projects.operations **kwargs: Any ) -> AgentDetails: ... + @overload + def get_microsoft365_package( + self, + agent_name: str, + *, + access_boundaries: Optional[List[Union[str, ActivityProtocolAccessBoundary]]] = ..., + agent_display_name: Optional[str] = ..., + app_version: Optional[str] = ..., + bot_service_arm_id: Optional[str] = ..., + can_respond_without_mention: Optional[bool] = ..., + color_icon_base64: Optional[str] = ..., + content_type: str = "application/json", + developer_name: Optional[str] = ..., + developer_website_url: Optional[str] = ..., + full_description: Optional[str] = ..., + optional_permission_scopes: Optional[List[Microsoft365PermissionScopes]] = ..., + outline_icon_base64: Optional[str] = ..., + privacy_url: Optional[str] = ..., + publish_as_autopilot: Optional[bool] = ..., + publish_scope: Union[str, Microsoft365PublishScope], + short_description: Optional[str] = ..., + terms_of_use_url: Optional[str] = ..., + **kwargs: Any + ) -> Iterator[bytes]: ... + + @overload + def get_microsoft365_package( + self, + agent_name: str, + body: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Iterator[bytes]: ... + + @overload + def get_microsoft365_package( + self, + agent_name: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Iterator[bytes]: ... + + @distributed_trace + def get_microsoft365_publish_defaults( + self, + agent_name: str, + *, + publish_as_digital_worker: Optional[bool] = ..., + **kwargs: Any + ) -> Microsoft365PublishDefaults: ... + @distributed_trace def get_session( self, @@ -10023,6 +11112,51 @@ namespace azure.ai.projects.operations **kwargs: Any ) -> ItemPaged[AgentVersionDetails]: ... + @overload + def publish_to_microsoft365( + self, + agent_name: str, + *, + access_boundaries: Optional[List[Union[str, ActivityProtocolAccessBoundary]]] = ..., + agent_display_name: Optional[str] = ..., + app_version: Optional[str] = ..., + bot_service_arm_id: Optional[str] = ..., + can_respond_without_mention: Optional[bool] = ..., + color_icon_base64: Optional[str] = ..., + content_type: str = "application/json", + developer_name: Optional[str] = ..., + developer_website_url: Optional[str] = ..., + full_description: Optional[str] = ..., + optional_permission_scopes: Optional[List[Microsoft365PermissionScopes]] = ..., + outline_icon_base64: Optional[str] = ..., + privacy_url: Optional[str] = ..., + publish_as_autopilot: Optional[bool] = ..., + publish_scope: Union[str, Microsoft365PublishScope], + short_description: Optional[str] = ..., + terms_of_use_url: Optional[str] = ..., + **kwargs: Any + ) -> Microsoft365PublishResult: ... + + @overload + def publish_to_microsoft365( + self, + agent_name: str, + body: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Microsoft365PublishResult: ... + + @overload + def publish_to_microsoft365( + self, + agent_name: str, + body: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> Microsoft365PublishResult: ... + @distributed_trace def stop_session( self, @@ -10087,6 +11221,221 @@ namespace azure.ai.projects.operations ) -> SessionFileWriteResult: ... + class azure.ai.projects.operations.BetaAgentInsightMonitorsOperations(BetaAgentInsightMonitorsOperationsGenerated): + + def __init__( + self, + *args, + **kwargs + ) -> None: ... + + @overload + def begin_create_run( + self, + monitor_id: str, + run: AgentInsightRunCreate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AgentInsightRunLROPoller: ... + + @overload + def begin_create_run( + self, + monitor_id: str, + run: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AgentInsightRunLROPoller: ... + + @overload + def begin_create_run( + self, + monitor_id: str, + run: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AgentInsightRunLROPoller: ... + + @distributed_trace + def cancel_run( + self, + monitor_id: str, + run_id: str, + **kwargs: Any + ) -> AgentInsightRun: ... + + @overload + def create( + self, + monitor: AgentInsightMonitorCreate, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AgentInsightMonitor: ... + + @overload + def create( + self, + monitor: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AgentInsightMonitor: ... + + @overload + def create( + self, + monitor: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> AgentInsightMonitor: ... + + @distributed_trace + def delete( + self, + monitor_id: str, + **kwargs: Any + ) -> None: ... + + @distributed_trace + def get( + self, + monitor_id: str, + **kwargs: Any + ) -> AgentInsightMonitor: ... + + @distributed_trace + def get_insight( + self, + monitor_id: str, + insight_id: str, + *, + include_details: Optional[bool] = ..., + **kwargs: Any + ) -> AgentInsight: ... + + @distributed_trace + def get_run( + self, + monitor_id: str, + run_id: str, + **kwargs: Any + ) -> AgentInsightRun: ... + + @distributed_trace + def list( + self, + *, + agent_name: Optional[str] = ..., + before: Optional[str] = ..., + limit: Optional[int] = ..., + order: Optional[Union[str, PageOrder]] = ..., + **kwargs: Any + ) -> ItemPaged[AgentInsightMonitorListItem]: ... + + @distributed_trace + def list_insights( + self, + monitor_id: str, + *, + before: Optional[str] = ..., + category: Optional[str] = ..., + include_details: Optional[bool] = ..., + limit: Optional[int] = ..., + order: Optional[Union[str, PageOrder]] = ..., + severity: Optional[Union[str, AgentInsightSeverity]] = ..., + status: Optional[Union[str, AgentInsightStatus]] = ..., + **kwargs: Any + ) -> ItemPaged[AgentInsight]: ... + + @distributed_trace + def list_runs( + self, + monitor_id: str, + *, + before: Optional[str] = ..., + limit: Optional[int] = ..., + order: Optional[Union[str, PageOrder]] = ..., + status: Optional[Union[str, JobStatus]] = ..., + trigger: Optional[Union[str, AgentInsightRunTrigger]] = ..., + **kwargs: Any + ) -> ItemPaged[AgentInsightRun]: ... + + @distributed_trace + def reset( + self, + monitor_id: str, + **kwargs: Any + ) -> None: ... + + @overload + def update( + self, + monitor_id: str, + monitor: AgentInsightMonitorUpdate, + *, + content_type: str = "application/merge-patch+json", + **kwargs: Any + ) -> AgentInsightMonitor: ... + + @overload + def update( + self, + monitor_id: str, + monitor: JSON, + *, + content_type: str = "application/merge-patch+json", + **kwargs: Any + ) -> AgentInsightMonitor: ... + + @overload + def update( + self, + monitor_id: str, + monitor: IO[bytes], + *, + content_type: str = "application/merge-patch+json", + **kwargs: Any + ) -> AgentInsightMonitor: ... + + @overload + def update_insight( + self, + monitor_id: str, + insight_id: str, + update: AgentInsightUpdate, + *, + content_type: str = "application/merge-patch+json", + **kwargs: Any + ) -> AgentInsight: ... + + @overload + def update_insight( + self, + monitor_id: str, + insight_id: str, + update: JSON, + *, + content_type: str = "application/merge-patch+json", + **kwargs: Any + ) -> AgentInsight: ... + + @overload + def update_insight( + self, + monitor_id: str, + insight_id: str, + update: IO[bytes], + *, + content_type: str = "application/merge-patch+json", + **kwargs: Any + ) -> AgentInsight: ... + + class azure.ai.projects.operations.BetaAgentsOperations(BetaAgentsOperationsGenerated): def __init__( @@ -11129,6 +12478,7 @@ namespace azure.ai.projects.operations class azure.ai.projects.operations.BetaOperations(GeneratedBetaOperations): + agent_insight_monitors: BetaAgentInsightMonitorsOperations agents: BetaAgentsOperations datasets: BetaDatasetsOperations evaluation_taxonomies: BetaEvaluationTaxonomiesOperations @@ -11208,6 +12558,7 @@ namespace azure.ai.projects.operations routine_name: str, *, action: Optional[RoutineAction] = ..., + authorization: Optional[RoutineAuthorization] = ..., content_type: str = "application/json", description: Optional[str] = ..., enabled: Optional[bool] = ..., diff --git a/sdk/ai/azure-ai-projects/api.metadata.yml b/sdk/ai/azure-ai-projects/api.metadata.yml index 5923ed96d577..9e486f43b0d9 100644 --- a/sdk/ai/azure-ai-projects/api.metadata.yml +++ b/sdk/ai/azure-ai-projects/api.metadata.yml @@ -1,3 +1,3 @@ -apiMdSha256: 55a629feb8b0501f399dfa3740cf44231ebfef50128f7fb7c85ce0e60bbefe96 -parserVersion: 0.3.28 -pythonVersion: 3.14.3 +apiMdSha256: a6577a4af1769573060edc2c82ec338b3b10529ac01551a70cadb9957fc3c01f +parserVersion: 0.3.31 +pythonVersion: 3.12.10 diff --git a/sdk/ai/azure-ai-projects/apiview-properties.json b/sdk/ai/azure-ai-projects/apiview-properties.json index 3ce7269f875e..c1709f7b9659 100644 --- a/sdk/ai/azure-ai-projects/apiview-properties.json +++ b/sdk/ai/azure-ai-projects/apiview-properties.json @@ -27,6 +27,26 @@ "azure.ai.projects.models.BaseCredentials": "Azure.AI.Projects.BaseCredentials", "azure.ai.projects.models.AgenticIdentityPreviewCredentials": "Azure.AI.Projects.AgenticIdentityPreviewCredentials", "azure.ai.projects.models.AgentIdentity": "Azure.AI.Projects.AgentIdentity", + "azure.ai.projects.models.AgentInsight": "Azure.AI.Projects.AgentInsight", + "azure.ai.projects.models.AgentInsightDetails": "Azure.AI.Projects.AgentInsightDetails", + "azure.ai.projects.models.AgentInsightEstimatedCost": "Azure.AI.Projects.AgentInsightEstimatedCost", + "azure.ai.projects.models.AgentInsightHighlightedTrace": "Azure.AI.Projects.AgentInsightHighlightedTrace", + "azure.ai.projects.models.AgentInsightLinkedTrace": "Azure.AI.Projects.AgentInsightLinkedTrace", + "azure.ai.projects.models.AgentInsightMonitor": "Azure.AI.Projects.AgentInsightMonitor", + "azure.ai.projects.models.AgentInsightMonitorCreate": "Azure.AI.Projects.AgentInsightMonitorCreate", + "azure.ai.projects.models.AgentInsightMonitorListItem": "Azure.AI.Projects.AgentInsightMonitorListItem", + "azure.ai.projects.models.AgentInsightMonitorUpdate": "Azure.AI.Projects.AgentInsightMonitorUpdate", + "azure.ai.projects.models.AgentInsightProposedFix": "Azure.AI.Projects.AgentInsightProposedFix", + "azure.ai.projects.models.AgentInsightProposedFixChange": "Azure.AI.Projects.AgentInsightProposedFixChange", + "azure.ai.projects.models.AgentInsightRecommendedAction": "Azure.AI.Projects.AgentInsightRecommendedAction", + "azure.ai.projects.models.AgentInsightRun": "Azure.AI.Projects.AgentInsightRun", + "azure.ai.projects.models.AgentInsightRunCreate": "Azure.AI.Projects.AgentInsightRunCreate", + "azure.ai.projects.models.AgentInsightRunResult": "Azure.AI.Projects.AgentInsightRunResult", + "azure.ai.projects.models.AgentInsightsOverview": "Azure.AI.Projects.AgentInsightsOverview", + "azure.ai.projects.models.AgentInsightsOverviewOverride": "Azure.AI.Projects.AgentInsightsOverviewOverride", + "azure.ai.projects.models.AgentInsightSuspension": "Azure.AI.Projects.AgentInsightSuspension", + "azure.ai.projects.models.AgentInsightTokenUsage": "Azure.AI.Projects.AgentInsightTokenUsage", + "azure.ai.projects.models.AgentInsightUpdate": "Azure.AI.Projects.AgentInsightUpdate", "azure.ai.projects.models.AgentObjectVersions": "Azure.AI.Projects.AgentObject.versions.anonymous", "azure.ai.projects.models.AgentOptimizationCandidate": "Azure.AI.Projects.AgentOptimizationCandidate", "azure.ai.projects.models.AgentOptimizationDatasetCriterion": "Azure.AI.Projects.AgentOptimizationDatasetCriterion", @@ -239,6 +259,9 @@ "azure.ai.projects.models.MemoryStoreSearchResult": "Azure.AI.Projects.MemoryStoreSearchResponse", "azure.ai.projects.models.MemoryStoreUpdateCompletedResult": "Azure.AI.Projects.MemoryStoreUpdateCompletedResult", "azure.ai.projects.models.MemoryStoreUpdateResult": "Azure.AI.Projects.MemoryStoreUpdateResponse", + "azure.ai.projects.models.Microsoft365PermissionScopes": "Azure.AI.Projects.Microsoft365PermissionScopes", + "azure.ai.projects.models.Microsoft365PublishDefaults": "Azure.AI.Projects.Microsoft365PublishDefaults", + "azure.ai.projects.models.Microsoft365PublishResult": "Azure.AI.Projects.Microsoft365PublishResponse", "azure.ai.projects.models.MicrosoftFabricPreviewTool": "Azure.AI.Projects.MicrosoftFabricPreviewTool", "azure.ai.projects.models.ModelCredentialRequest": "Azure.AI.Projects.ModelCredentialRequest", "azure.ai.projects.models.ModelDeployment": "Azure.AI.Projects.ModelDeployment", @@ -287,6 +310,7 @@ "azure.ai.projects.models.ResponseUsageInputTokensDetails": "OpenAI.ResponseUsageInputTokensDetails", "azure.ai.projects.models.ResponseUsageOutputTokensDetails": "OpenAI.ResponseUsageOutputTokensDetails", "azure.ai.projects.models.Routine": "Azure.AI.Projects.Routine", + "azure.ai.projects.models.RoutineAuthorization": "Azure.AI.Projects.RoutineAuthorization", "azure.ai.projects.models.RoutineRun": "Azure.AI.Projects.RoutineRun", "azure.ai.projects.models.RubricBasedEvaluatorDefinition": "Azure.AI.Projects.RubricBasedEvaluatorDefinition", "azure.ai.projects.models.RubricGenerationInputQualityWarning": "Azure.AI.Projects.RubricGenerationInputQualityWarning", @@ -294,11 +318,13 @@ "azure.ai.projects.models.Schedule": "Azure.AI.Projects.Schedule", "azure.ai.projects.models.ScheduleRoutineTrigger": "Azure.AI.Projects.ScheduleRoutineTrigger", "azure.ai.projects.models.ScheduleRun": "Azure.AI.Projects.ScheduleRun", + "azure.ai.projects.models.SessionConfiguration": "Azure.AI.Projects.SessionConfiguration", "azure.ai.projects.models.SessionDirectoryEntry": "Azure.AI.Projects.SessionDirectoryEntry", "azure.ai.projects.models.SessionFileWriteResult": "Azure.AI.Projects.SessionFileWriteResponse", "azure.ai.projects.models.SessionLogEvent": "Azure.AI.Projects.SessionLogEvent", "azure.ai.projects.models.SharepointGroundingToolParameters": "Azure.AI.Projects.SharepointGroundingToolParameters", "azure.ai.projects.models.SharepointPreviewTool": "Azure.AI.Projects.SharepointPreviewTool", + "azure.ai.projects.models.ShellToolboxTool": "Azure.AI.Projects.ShellToolboxTool", "azure.ai.projects.models.SimpleQnADataGenerationJobOptions": "Azure.AI.Projects.SimpleQnADataGenerationJobOptions", "azure.ai.projects.models.SimulationSeedDataGenerationJobOptions": "Azure.AI.Projects.SimulationSeedDataGenerationJobOptions", "azure.ai.projects.models.SkillDetails": "Azure.AI.Projects.Skill", @@ -322,6 +348,11 @@ "azure.ai.projects.models.ToolboxObject": "Azure.AI.Projects.ToolboxObject", "azure.ai.projects.models.ToolboxPolicies": "Azure.AI.Projects.ToolboxPolicies", "azure.ai.projects.models.ToolboxSearchPreviewToolboxTool": "Azure.AI.Projects.ToolboxSearchPreviewToolboxTool", + "azure.ai.projects.models.ToolboxShellEnvironment": "Azure.AI.Projects.ToolboxShellEnvironment", + "azure.ai.projects.models.ToolboxShellContainerAutoEnvironment": "Azure.AI.Projects.ToolboxShellContainerAutoEnvironment", + "azure.ai.projects.models.ToolboxShellContainerReferenceEnvironment": "Azure.AI.Projects.ToolboxShellContainerReferenceEnvironment", + "azure.ai.projects.models.ToolboxShellNetworkPolicy": "Azure.AI.Projects.ToolboxShellNetworkPolicy", + "azure.ai.projects.models.ToolboxShellNetworkPolicyDisabled": "Azure.AI.Projects.ToolboxShellNetworkPolicyDisabled", "azure.ai.projects.models.ToolboxSkill": "Azure.AI.Projects.ToolboxSkill", "azure.ai.projects.models.ToolboxSkillReference": "Azure.AI.Projects.ToolboxSkillReference", "azure.ai.projects.models.ToolboxVersionObject": "Azure.AI.Projects.ToolboxVersionObject", @@ -352,6 +383,8 @@ "azure.ai.projects.models.VersionIndicator": "Azure.AI.Projects.VersionIndicator", "azure.ai.projects.models.VersionRefIndicator": "Azure.AI.Projects.VersionRefIndicator", "azure.ai.projects.models.VersionSelector": "Azure.AI.Projects.VersionSelector", + "azure.ai.projects.models.WebIQPreviewTool": "Azure.AI.Projects.WebIQPreviewTool", + "azure.ai.projects.models.WebIQPreviewToolboxTool": "Azure.AI.Projects.WebIQPreviewToolboxTool", "azure.ai.projects.models.WebSearchApproximateLocation": "OpenAI.WebSearchApproximateLocation", "azure.ai.projects.models.WebSearchConfiguration": "Azure.AI.Projects.WebSearchConfiguration", "azure.ai.projects.models.WebSearchPreviewTool": "OpenAI.WebSearchPreviewTool", @@ -362,6 +395,14 @@ "azure.ai.projects.models.WorkflowAgentDefinition": "Azure.AI.Projects.WorkflowAgentDefinition", "azure.ai.projects.models.WorkIQPreviewTool": "Azure.AI.Projects.WorkIQPreviewTool", "azure.ai.projects.models.WorkIQPreviewToolboxTool": "Azure.AI.Projects.WorkIQPreviewToolboxTool", + "azure.ai.projects.models.PageOrder": "Azure.AI.Projects.PageOrder", + "azure.ai.projects.models.AgentInsightOverviewSource": "Azure.AI.Projects.AgentInsightOverviewSource", + "azure.ai.projects.models.JobStatus": "Azure.AI.Projects.JobStatus", + "azure.ai.projects.models.AgentInsightRunTrigger": "Azure.AI.Projects.AgentInsightRunTrigger", + "azure.ai.projects.models.AgentInsightSeverity": "Azure.AI.Projects.AgentInsightSeverity", + "azure.ai.projects.models.AgentInsightStatus": "Azure.AI.Projects.AgentInsightStatus", + "azure.ai.projects.models.AgentInsightProposedFixKind": "Azure.AI.Projects.AgentInsightProposedFixKind", + "azure.ai.projects.models.AgentInsightPromptSurface": "Azure.AI.Projects.AgentInsightPromptSurface", "azure.ai.projects.models.EvaluationTaxonomyInputType": "Azure.AI.Projects.EvaluationTaxonomyInputType", "azure.ai.projects.models.ToolType": "OpenAI.ToolType", "azure.ai.projects.models.A2AProtocolVersion": "Azure.AI.Projects.A2AProtocolVersion", @@ -391,11 +432,9 @@ "azure.ai.projects.models.GenerationWarningType": "Azure.AI.Projects.GenerationWarningType", "azure.ai.projects.models.PendingUploadType": "Azure.AI.Projects.PendingUploadType", "azure.ai.projects.models.EvaluatorGenerationJobSourceType": "Azure.AI.Projects.EvaluatorGenerationJobSourceType", - "azure.ai.projects.models.JobStatus": "Azure.AI.Projects.JobStatus", "azure.ai.projects.models.RubricGenerationInputQualityWarningCode": "Azure.AI.Projects.RubricGenerationInputQualityWarningCode", "azure.ai.projects.models.RubricGenerationInputQualityWarningSeverity": "Azure.AI.Projects.RubricGenerationInputQualityWarningSeverity", "azure.ai.projects.models.RubricGenerationInputQualityWarningSource": "Azure.AI.Projects.RubricGenerationInputQualityWarningSource", - "azure.ai.projects.models.PageOrder": "Azure.AI.Projects.PageOrder", "azure.ai.projects.models.OperationState": "Azure.Core.Foundations.OperationState", "azure.ai.projects.models.InsightType": "Azure.AI.Projects.InsightType", "azure.ai.projects.models.SampleType": "Azure.AI.Projects.SampleType", @@ -413,6 +452,7 @@ "azure.ai.projects.models.RoutineTriggerType": "Azure.AI.Projects.RoutineTriggerType", "azure.ai.projects.models.GitHubIssueEvent": "Azure.AI.Projects.GitHubIssueEvent", "azure.ai.projects.models.RoutineActionType": "Azure.AI.Projects.RoutineActionType", + "azure.ai.projects.models.RoutineDispatchIdentity": "Azure.AI.Projects.RoutineDispatchIdentity", "azure.ai.projects.models.RoutineRunPhase": "Azure.AI.Projects.RoutineRunPhase", "azure.ai.projects.models.RoutineAttemptSource": "Azure.AI.Projects.RoutineAttemptSource", "azure.ai.projects.models.RoutineDispatchPayloadType": "Azure.AI.Projects.RoutineDispatchPayloadType", @@ -445,10 +485,14 @@ "azure.ai.projects.models.AgentIdentityStatus": "Azure.AI.Projects.AgentIdentityStatus", "azure.ai.projects.models.AgentBlueprintReferenceType": "Azure.AI.Projects.AgentBlueprintReferenceType", "azure.ai.projects.models.VersionSelectorType": "Azure.AI.Projects.VersionSelectorType", + "azure.ai.projects.models.ActivityProtocolAccessBoundary": "Azure.AI.Projects.ActivityProtocolAccessBoundary", "azure.ai.projects.models.AgentEndpointAuthorizationSchemeType": "Azure.AI.Projects.AgentEndpointAuthorizationSchemeType", + "azure.ai.projects.models.PublishApprovalStatus": "Azure.AI.Projects.PublishApprovalStatus", + "azure.ai.projects.models.DigitalWorkerType": "Azure.AI.Projects.DigitalWorkerType", "azure.ai.projects.models.VersionIndicatorType": "Azure.AI.Projects.VersionIndicatorType", "azure.ai.projects.models.AgentSessionStatus": "Azure.AI.Projects.AgentSessionStatus", "azure.ai.projects.models.SessionLogEventType": "Azure.AI.Projects.SessionLogEventType", + "azure.ai.projects.models.Microsoft365PublishScope": "Azure.AI.Projects.Microsoft365PublishScope", "azure.ai.projects.models.EvaluationRuleActionType": "Azure.AI.Projects.EvaluationRuleActionType", "azure.ai.projects.models.EvaluationRuleEventType": "Azure.AI.Projects.EvaluationRuleEventType", "azure.ai.projects.models.ConnectionType": "Azure.AI.Projects.ConnectionType", @@ -494,6 +538,12 @@ "azure.ai.projects.aio.operations.AgentsOperations.list_sessions": "Azure.AI.Projects.Agents.listSessions", "azure.ai.projects.operations.AgentsOperations.get_session_log_stream": "Azure.AI.Projects.Agents.getSessionLogStream", "azure.ai.projects.aio.operations.AgentsOperations.get_session_log_stream": "Azure.AI.Projects.Agents.getSessionLogStream", + "azure.ai.projects.operations.AgentsOperations.publish_to_microsoft365": "Azure.AI.Projects.Microsoft365Publishing.publishAgentToMicrosoft365", + "azure.ai.projects.aio.operations.AgentsOperations.publish_to_microsoft365": "Azure.AI.Projects.Microsoft365Publishing.publishAgentToMicrosoft365", + "azure.ai.projects.operations.AgentsOperations.get_microsoft365_package": "Azure.AI.Projects.Microsoft365Publishing.getMicrosoft365AppPackage", + "azure.ai.projects.aio.operations.AgentsOperations.get_microsoft365_package": "Azure.AI.Projects.Microsoft365Publishing.getMicrosoft365AppPackage", + "azure.ai.projects.operations.AgentsOperations.get_microsoft365_publish_defaults": "Azure.AI.Projects.Microsoft365Publishing.getMicrosoft365PublishDefaults", + "azure.ai.projects.aio.operations.AgentsOperations.get_microsoft365_publish_defaults": "Azure.AI.Projects.Microsoft365Publishing.getMicrosoft365PublishDefaults", "azure.ai.projects.operations.AgentsOperations.upload_session_file": "Azure.AI.Projects.AgentSessionFiles.uploadSessionFile", "azure.ai.projects.aio.operations.AgentsOperations.upload_session_file": "Azure.AI.Projects.AgentSessionFiles.uploadSessionFile", "azure.ai.projects.operations.AgentsOperations.download_session_file": "Azure.AI.Projects.AgentSessionFiles.downloadSessionFile", @@ -557,5 +607,5 @@ "azure.ai.projects.operations.ToolboxesOperations.delete_version": "Azure.AI.Projects.Toolboxes.deleteToolboxVersion", "azure.ai.projects.aio.operations.ToolboxesOperations.delete_version": "Azure.AI.Projects.Toolboxes.deleteToolboxVersion" }, - "CrossLanguageVersion": "f23cc7b21030" + "CrossLanguageVersion": "6f8b65f37cf4" } \ No newline at end of file diff --git a/sdk/ai/azure-ai-projects/azure/ai/projects/aio/operations/_operations.py b/sdk/ai/azure-ai-projects/azure/ai/projects/aio/operations/_operations.py index b9f0f19c6791..b36b4af5887a 100644 --- a/sdk/ai/azure-ai-projects/azure/ai/projects/aio/operations/_operations.py +++ b/sdk/ai/azure-ai-projects/azure/ai/projects/aio/operations/_operations.py @@ -49,6 +49,8 @@ build_agents_download_code_request, build_agents_download_session_file_request, build_agents_enable_request, + build_agents_get_microsoft365_package_request, + build_agents_get_microsoft365_publish_defaults_request, build_agents_get_request, build_agents_get_session_log_stream_request, build_agents_get_session_request, @@ -57,9 +59,23 @@ build_agents_list_session_files_request, build_agents_list_sessions_request, build_agents_list_versions_request, + build_agents_publish_to_microsoft365_request, build_agents_stop_session_request, build_agents_update_details_request, build_agents_upload_session_file_request, + build_beta_agent_insight_monitors_cancel_run_request, + build_beta_agent_insight_monitors_create_request, + build_beta_agent_insight_monitors_create_run_request, + build_beta_agent_insight_monitors_delete_request, + build_beta_agent_insight_monitors_get_insight_request, + build_beta_agent_insight_monitors_get_request, + build_beta_agent_insight_monitors_get_run_request, + build_beta_agent_insight_monitors_list_insights_request, + build_beta_agent_insight_monitors_list_request, + build_beta_agent_insight_monitors_list_runs_request, + build_beta_agent_insight_monitors_reset_request, + build_beta_agent_insight_monitors_update_insight_request, + build_beta_agent_insight_monitors_update_request, build_beta_agents_cancel_optimization_job_request, build_beta_agents_create_optimization_job_request, build_beta_agents_delete_optimization_job_request, @@ -196,6 +212,9 @@ def __init__(self, *args, **kwargs) -> None: self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self.agent_insight_monitors = BetaAgentInsightMonitorsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.evaluation_taxonomies = BetaEvaluationTaxonomiesOperations( self._client, self._config, self._serialize, self._deserialize ) @@ -479,6 +498,7 @@ async def create_version( metadata: Optional[dict[str, str]] = None, description: Optional[str] = None, blueprint_reference: Optional[_models.AgentBlueprintReference] = None, + digital_worker_type: Optional[Union[str, _models.DigitalWorkerType]] = None, draft: Optional[bool] = None, **kwargs: Any ) -> _models.AgentVersionDetails: @@ -493,8 +513,8 @@ async def create_version( * Can contain hyphens in the middle * Must not exceed 63 characters. Required. :type agent_name: str - :keyword definition: The agent definition. This can be a workflow, hosted agent, or a simple - agent definition. Required. + :keyword definition: The agent definition. This can be a prompt, workflow, hosted, external, or + voice agent definition. Required. :paramtype definition: ~azure.ai.projects.models.AgentDefinition :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". @@ -510,6 +530,9 @@ async def create_version( :paramtype description: str :keyword blueprint_reference: The blueprint reference for the agent. Default value is None. :paramtype blueprint_reference: ~azure.ai.projects.models.AgentBlueprintReference + :keyword digital_worker_type: (Preview) The type of digital worker (previously known as + ``autopilot``). If omitted, it is not a digital worker. "m365" Default value is None. + :paramtype digital_worker_type: str or ~azure.ai.projects.models.DigitalWorkerType :keyword draft: (Preview) Whether this agent version is a draft (candidate) rather than a release. The service defaults to ``false`` if a value is not specified by the caller. Draft versions are recorded but excluded from default 'latest' resolution and are not auto-promoted. @@ -580,6 +603,7 @@ async def create_version( metadata: Optional[dict[str, str]] = None, description: Optional[str] = None, blueprint_reference: Optional[_models.AgentBlueprintReference] = None, + digital_worker_type: Optional[Union[str, _models.DigitalWorkerType]] = None, draft: Optional[bool] = None, **kwargs: Any ) -> _models.AgentVersionDetails: @@ -596,8 +620,8 @@ async def create_version( :type agent_name: str :param body: Is either a JSON type or a IO[bytes] type. Required. :type body: JSON or IO[bytes] - :keyword definition: The agent definition. This can be a workflow, hosted agent, or a simple - agent definition. Required. + :keyword definition: The agent definition. This can be a prompt, workflow, hosted, external, or + voice agent definition. Required. :paramtype definition: ~azure.ai.projects.models.AgentDefinition :keyword metadata: Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured @@ -610,6 +634,9 @@ async def create_version( :paramtype description: str :keyword blueprint_reference: The blueprint reference for the agent. Default value is None. :paramtype blueprint_reference: ~azure.ai.projects.models.AgentBlueprintReference + :keyword digital_worker_type: (Preview) The type of digital worker (previously known as + ``autopilot``). If omitted, it is not a digital worker. "m365" Default value is None. + :paramtype digital_worker_type: str or ~azure.ai.projects.models.DigitalWorkerType :keyword draft: (Preview) Whether this agent version is a draft (candidate) rather than a release. The service defaults to ``false`` if a value is not specified by the caller. Draft versions are recorded but excluded from default 'latest' resolution and are not auto-promoted. @@ -640,6 +667,7 @@ async def create_version( "blueprint_reference": blueprint_reference, "definition": definition, "description": description, + "digital_worker_type": digital_worker_type, "draft": draft, "metadata": metadata, } @@ -2188,91 +2216,271 @@ async def get_session_log_stream( return deserialized # type: ignore @overload - async def upload_session_file( + async def publish_to_microsoft365( self, agent_name: str, - session_id: str, - content: bytes, *, - path: str, - content_type: str = "application/octet-stream", + publish_scope: Union[str, _models.Microsoft365PublishScope], + content_type: str = "application/json", + agent_display_name: Optional[str] = None, + bot_service_arm_id: Optional[str] = None, + publish_as_autopilot: Optional[bool] = None, + access_boundaries: Optional[List[Union[str, _models.ActivityProtocolAccessBoundary]]] = None, + optional_permission_scopes: Optional[List[_models.Microsoft365PermissionScopes]] = None, + can_respond_without_mention: Optional[bool] = None, + app_version: Optional[str] = None, + short_description: Optional[str] = None, + full_description: Optional[str] = None, + developer_name: Optional[str] = None, + developer_website_url: Optional[str] = None, + privacy_url: Optional[str] = None, + terms_of_use_url: Optional[str] = None, + color_icon_base64: Optional[str] = None, + outline_icon_base64: Optional[str] = None, **kwargs: Any - ) -> _models.SessionFileWriteResult: - """Upload a session file. + ) -> _models.Microsoft365PublishResult: + """Publish an agent to Microsoft 365. - Uploads binary file content to the specified path in the session sandbox. The service stores - the file relative to the session home directory and rejects payloads larger than 50 MB. + Publishes a Foundry agent to Microsoft 365 / Microsoft Teams and returns the published title + and Teams app ids. - :param agent_name: The name of the agent. Required. + :param agent_name: The name of the agent to publish. Required. :type agent_name: str - :param session_id: The session ID. Required. - :type session_id: str - :param content: Required. - :type content: bytes - :keyword path: The destination file path within the sandbox, relative to the session home - directory. Required. - :paramtype path: str - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/octet-stream". + :keyword publish_scope: Publish scope for the Teams app. Known values are: "Personal", + "Shared", and "Tenant". Required. + :paramtype publish_scope: str or ~azure.ai.projects.models.Microsoft365PublishScope + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". :paramtype content_type: str - :return: SessionFileWriteResult. The SessionFileWriteResult is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.SessionFileWriteResult + :keyword agent_display_name: Display name used as the published Teams app name. When omitted, + the agent name from the route is + used. Default value is None. + :paramtype agent_display_name: str + :keyword bot_service_arm_id: ARM resource id of the Azure Bot Service that fronts this agent in + Microsoft Teams. Required for + workspaces on the default bot-based Teams backend; optional for workspaces on the API-based + backend. + Must not be supplied when ``publishAsAutopilot`` is true. Default value is None. + :paramtype bot_service_arm_id: str + :keyword publish_as_autopilot: When true, the agent is published as an autopilot (digital + worker) agent: the bot id is taken from + the agent's blueprint identity and the generated Teams manifest is marked as a digital worker. + Default value is None. + :paramtype publish_as_autopilot: bool + :keyword access_boundaries: Activity-protocol access boundaries to apply to the agent when + publishing as an autopilot agent. + An empty list clears the existing boundaries. When omitted, the existing boundaries are left + unchanged. Default value is None. + :paramtype access_boundaries: list[str or + ~azure.ai.projects.models.ActivityProtocolAccessBoundary] + :keyword optional_permission_scopes: Exact selection of delegated permission scopes to grant to + the autopilot blueprint. May only be + supplied when ``publishAsAutopilot`` is true. When omitted or empty, the platform's default + permission set is used. Mandatory platform permissions are always granted and are not affected + by + this value. Default value is None. + :paramtype optional_permission_scopes: + list[~azure.ai.projects.models.Microsoft365PermissionScopes] + :keyword can_respond_without_mention: Controls how the published agent responds to Teams + messages: when true it responds to all messages + on its surfaces, when false only when it is at-mentioned. When omitted, the agent's existing + Teams + message-notification setting is left unchanged. Default value is None. + :paramtype can_respond_without_mention: bool + :keyword app_version: App version (for example ``1.2.3``) written into the Teams manifest. May + contain only digits and + periods, must not start with ``0``, and must end with a digit. When omitted, a platform + default is + used. Default value is None. + :paramtype app_version: str + :keyword short_description: Short, one-line description shown in the Teams app listing. Default + value is None. + :paramtype short_description: str + :keyword full_description: Full description shown on the Teams app details page. Default value + is None. + :paramtype full_description: str + :keyword developer_name: Display name of the developer / publisher shown in the Teams app + listing. Default value is None. + :paramtype developer_name: str + :keyword developer_website_url: Developer / publisher website URL shown in the Teams app + listing. Must be an https URL. Default value is None. + :paramtype developer_website_url: str + :keyword privacy_url: Privacy policy URL shown in the Teams app listing. Must be an http or + https URL. Default value is None. + :paramtype privacy_url: str + :keyword terms_of_use_url: Terms-of-use URL shown in the Teams app listing. Default value is + None. + :paramtype terms_of_use_url: str + :keyword color_icon_base64: Optional base64-encoded PNG used as the color (full-bleed) icon in + the Teams app package. Must be a + 192x192 PNG (perfect square, no border or rounded corners). Max 1 MB after decode. When + omitted, the + platform default color icon is used. Default value is None. + :paramtype color_icon_base64: str + :keyword outline_icon_base64: Optional base64-encoded PNG used as the outline icon in the Teams + app package. Must be a 32x32 PNG. + Max 1 MB after decode. When omitted, the platform default outline icon is used. Default value + is None. + :paramtype outline_icon_base64: str + :return: Microsoft365PublishResult. The Microsoft365PublishResult is compatible with + MutableMapping + :rtype: ~azure.ai.projects.models.Microsoft365PublishResult :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def upload_session_file( - self, - agent_name: str, - session_id: str, - content: IO[bytes], - *, - path: str, - content_type: str = "application/octet-stream", - **kwargs: Any - ) -> _models.SessionFileWriteResult: - """Upload a session file. + async def publish_to_microsoft365( + self, agent_name: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.Microsoft365PublishResult: + """Publish an agent to Microsoft 365. - Uploads binary file content to the specified path in the session sandbox. The service stores - the file relative to the session home directory and rejects payloads larger than 50 MB. + Publishes a Foundry agent to Microsoft 365 / Microsoft Teams and returns the published title + and Teams app ids. - :param agent_name: The name of the agent. Required. + :param agent_name: The name of the agent to publish. Required. :type agent_name: str - :param session_id: The session ID. Required. - :type session_id: str - :param content: Required. - :type content: IO[bytes] - :keyword path: The destination file path within the sandbox, relative to the session home - directory. Required. - :paramtype path: str + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Microsoft365PublishResult. The Microsoft365PublishResult is compatible with + MutableMapping + :rtype: ~azure.ai.projects.models.Microsoft365PublishResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def publish_to_microsoft365( + self, agent_name: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.Microsoft365PublishResult: + """Publish an agent to Microsoft 365. + + Publishes a Foundry agent to Microsoft 365 / Microsoft Teams and returns the published title + and Teams app ids. + + :param agent_name: The name of the agent to publish. Required. + :type agent_name: str + :param body: Required. + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/octet-stream". + Default value is "application/json". :paramtype content_type: str - :return: SessionFileWriteResult. The SessionFileWriteResult is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.SessionFileWriteResult + :return: Microsoft365PublishResult. The Microsoft365PublishResult is compatible with + MutableMapping + :rtype: ~azure.ai.projects.models.Microsoft365PublishResult :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def upload_session_file( - self, agent_name: str, session_id: str, content: Union[bytes, IO[bytes]], *, path: str, **kwargs: Any - ) -> _models.SessionFileWriteResult: - """Upload a session file. + async def publish_to_microsoft365( # pylint: disable=too-many-locals + self, + agent_name: str, + body: Union[JSON, IO[bytes]] = _Unset, + *, + publish_scope: Union[str, _models.Microsoft365PublishScope] = _Unset, + agent_display_name: Optional[str] = None, + bot_service_arm_id: Optional[str] = None, + publish_as_autopilot: Optional[bool] = None, + access_boundaries: Optional[List[Union[str, _models.ActivityProtocolAccessBoundary]]] = None, + optional_permission_scopes: Optional[List[_models.Microsoft365PermissionScopes]] = None, + can_respond_without_mention: Optional[bool] = None, + app_version: Optional[str] = None, + short_description: Optional[str] = None, + full_description: Optional[str] = None, + developer_name: Optional[str] = None, + developer_website_url: Optional[str] = None, + privacy_url: Optional[str] = None, + terms_of_use_url: Optional[str] = None, + color_icon_base64: Optional[str] = None, + outline_icon_base64: Optional[str] = None, + **kwargs: Any + ) -> _models.Microsoft365PublishResult: + """Publish an agent to Microsoft 365. - Uploads binary file content to the specified path in the session sandbox. The service stores - the file relative to the session home directory and rejects payloads larger than 50 MB. + Publishes a Foundry agent to Microsoft 365 / Microsoft Teams and returns the published title + and Teams app ids. - :param agent_name: The name of the agent. Required. + :param agent_name: The name of the agent to publish. Required. :type agent_name: str - :param session_id: The session ID. Required. - :type session_id: str - :param content: Is either a bytes type or a IO[bytes] type. Required. - :type content: bytes or IO[bytes] - :keyword path: The destination file path within the sandbox, relative to the session home - directory. Required. - :paramtype path: str - :return: SessionFileWriteResult. The SessionFileWriteResult is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.SessionFileWriteResult + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :keyword publish_scope: Publish scope for the Teams app. Known values are: "Personal", + "Shared", and "Tenant". Required. + :paramtype publish_scope: str or ~azure.ai.projects.models.Microsoft365PublishScope + :keyword agent_display_name: Display name used as the published Teams app name. When omitted, + the agent name from the route is + used. Default value is None. + :paramtype agent_display_name: str + :keyword bot_service_arm_id: ARM resource id of the Azure Bot Service that fronts this agent in + Microsoft Teams. Required for + workspaces on the default bot-based Teams backend; optional for workspaces on the API-based + backend. + Must not be supplied when ``publishAsAutopilot`` is true. Default value is None. + :paramtype bot_service_arm_id: str + :keyword publish_as_autopilot: When true, the agent is published as an autopilot (digital + worker) agent: the bot id is taken from + the agent's blueprint identity and the generated Teams manifest is marked as a digital worker. + Default value is None. + :paramtype publish_as_autopilot: bool + :keyword access_boundaries: Activity-protocol access boundaries to apply to the agent when + publishing as an autopilot agent. + An empty list clears the existing boundaries. When omitted, the existing boundaries are left + unchanged. Default value is None. + :paramtype access_boundaries: list[str or + ~azure.ai.projects.models.ActivityProtocolAccessBoundary] + :keyword optional_permission_scopes: Exact selection of delegated permission scopes to grant to + the autopilot blueprint. May only be + supplied when ``publishAsAutopilot`` is true. When omitted or empty, the platform's default + permission set is used. Mandatory platform permissions are always granted and are not affected + by + this value. Default value is None. + :paramtype optional_permission_scopes: + list[~azure.ai.projects.models.Microsoft365PermissionScopes] + :keyword can_respond_without_mention: Controls how the published agent responds to Teams + messages: when true it responds to all messages + on its surfaces, when false only when it is at-mentioned. When omitted, the agent's existing + Teams + message-notification setting is left unchanged. Default value is None. + :paramtype can_respond_without_mention: bool + :keyword app_version: App version (for example ``1.2.3``) written into the Teams manifest. May + contain only digits and + periods, must not start with ``0``, and must end with a digit. When omitted, a platform + default is + used. Default value is None. + :paramtype app_version: str + :keyword short_description: Short, one-line description shown in the Teams app listing. Default + value is None. + :paramtype short_description: str + :keyword full_description: Full description shown on the Teams app details page. Default value + is None. + :paramtype full_description: str + :keyword developer_name: Display name of the developer / publisher shown in the Teams app + listing. Default value is None. + :paramtype developer_name: str + :keyword developer_website_url: Developer / publisher website URL shown in the Teams app + listing. Must be an https URL. Default value is None. + :paramtype developer_website_url: str + :keyword privacy_url: Privacy policy URL shown in the Teams app listing. Must be an http or + https URL. Default value is None. + :paramtype privacy_url: str + :keyword terms_of_use_url: Terms-of-use URL shown in the Teams app listing. Default value is + None. + :paramtype terms_of_use_url: str + :keyword color_icon_base64: Optional base64-encoded PNG used as the color (full-bleed) icon in + the Teams app package. Must be a + 192x192 PNG (perfect square, no border or rounded corners). Max 1 MB after decode. When + omitted, the + platform default color icon is used. Default value is None. + :paramtype color_icon_base64: str + :keyword outline_icon_base64: Optional base64-encoded PNG used as the outline icon in the Teams + app package. Must be a 32x32 PNG. + Max 1 MB after decode. When omitted, the platform default outline icon is used. Default value + is None. + :paramtype outline_icon_base64: str + :return: Microsoft365PublishResult. The Microsoft365PublishResult is compatible with + MutableMapping + :rtype: ~azure.ai.projects.models.Microsoft365PublishResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -2287,15 +2495,39 @@ async def upload_session_file( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SessionFileWriteResult] = kwargs.pop("cls", None) + cls: ClsType[_models.Microsoft365PublishResult] = kwargs.pop("cls", None) - content_type = content_type or "application/octet-stream" - _content = content + if body is _Unset: + if publish_scope is _Unset: + raise TypeError("missing required argument: publish_scope") + body = { + "accessBoundaries": access_boundaries, + "agentDisplayName": agent_display_name, + "appVersion": app_version, + "botServiceArmId": bot_service_arm_id, + "canRespondWithoutMention": can_respond_without_mention, + "colorIconBase64": color_icon_base64, + "developerName": developer_name, + "developerWebsiteUrl": developer_website_url, + "fullDescription": full_description, + "optionalPermissionScopes": optional_permission_scopes, + "outlineIconBase64": outline_icon_base64, + "privacyUrl": privacy_url, + "publishAsAutopilot": publish_as_autopilot, + "publishScope": publish_scope, + "shortDescription": short_description, + "termsOfUseUrl": terms_of_use_url, + } + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/json" + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_agents_upload_session_file_request( + _request = build_agents_publish_to_microsoft365_request( agent_name=agent_name, - session_id=session_id, - path=path, content_type=content_type, api_version=self._config.api_version, content=_content, @@ -2315,7 +2547,7 @@ async def upload_session_file( response = pipeline_response.http_response - if response.status_code not in [201]: + if response.status_code not in [200]: if _stream: try: await response.read() # Load the body in memory and close the socket @@ -2331,29 +2563,273 @@ async def upload_session_file( if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.SessionFileWriteResult, response.json()) + deserialized = _deserialize(_models.Microsoft365PublishResult, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore + @overload + async def get_microsoft365_package( + self, + agent_name: str, + *, + publish_scope: Union[str, _models.Microsoft365PublishScope], + content_type: str = "application/json", + agent_display_name: Optional[str] = None, + bot_service_arm_id: Optional[str] = None, + publish_as_autopilot: Optional[bool] = None, + access_boundaries: Optional[List[Union[str, _models.ActivityProtocolAccessBoundary]]] = None, + optional_permission_scopes: Optional[List[_models.Microsoft365PermissionScopes]] = None, + can_respond_without_mention: Optional[bool] = None, + app_version: Optional[str] = None, + short_description: Optional[str] = None, + full_description: Optional[str] = None, + developer_name: Optional[str] = None, + developer_website_url: Optional[str] = None, + privacy_url: Optional[str] = None, + terms_of_use_url: Optional[str] = None, + color_icon_base64: Optional[str] = None, + outline_icon_base64: Optional[str] = None, + **kwargs: Any + ) -> AsyncIterator[bytes]: + """Generate a Microsoft 365 app package. + + Generates the Microsoft Teams app package (zip) for a Foundry agent from the supplied publish + request, without publishing it. Returns the app package as ``application/zip``. + + :param agent_name: The name of the agent to generate the app package for. Required. + :type agent_name: str + :keyword publish_scope: Publish scope for the Teams app. Known values are: "Personal", + "Shared", and "Tenant". Required. + :paramtype publish_scope: str or ~azure.ai.projects.models.Microsoft365PublishScope + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword agent_display_name: Display name used as the published Teams app name. When omitted, + the agent name from the route is + used. Default value is None. + :paramtype agent_display_name: str + :keyword bot_service_arm_id: ARM resource id of the Azure Bot Service that fronts this agent in + Microsoft Teams. Required for + workspaces on the default bot-based Teams backend; optional for workspaces on the API-based + backend. + Must not be supplied when ``publishAsAutopilot`` is true. Default value is None. + :paramtype bot_service_arm_id: str + :keyword publish_as_autopilot: When true, the agent is published as an autopilot (digital + worker) agent: the bot id is taken from + the agent's blueprint identity and the generated Teams manifest is marked as a digital worker. + Default value is None. + :paramtype publish_as_autopilot: bool + :keyword access_boundaries: Activity-protocol access boundaries to apply to the agent when + publishing as an autopilot agent. + An empty list clears the existing boundaries. When omitted, the existing boundaries are left + unchanged. Default value is None. + :paramtype access_boundaries: list[str or + ~azure.ai.projects.models.ActivityProtocolAccessBoundary] + :keyword optional_permission_scopes: Exact selection of delegated permission scopes to grant to + the autopilot blueprint. May only be + supplied when ``publishAsAutopilot`` is true. When omitted or empty, the platform's default + permission set is used. Mandatory platform permissions are always granted and are not affected + by + this value. Default value is None. + :paramtype optional_permission_scopes: + list[~azure.ai.projects.models.Microsoft365PermissionScopes] + :keyword can_respond_without_mention: Controls how the published agent responds to Teams + messages: when true it responds to all messages + on its surfaces, when false only when it is at-mentioned. When omitted, the agent's existing + Teams + message-notification setting is left unchanged. Default value is None. + :paramtype can_respond_without_mention: bool + :keyword app_version: App version (for example ``1.2.3``) written into the Teams manifest. May + contain only digits and + periods, must not start with ``0``, and must end with a digit. When omitted, a platform + default is + used. Default value is None. + :paramtype app_version: str + :keyword short_description: Short, one-line description shown in the Teams app listing. Default + value is None. + :paramtype short_description: str + :keyword full_description: Full description shown on the Teams app details page. Default value + is None. + :paramtype full_description: str + :keyword developer_name: Display name of the developer / publisher shown in the Teams app + listing. Default value is None. + :paramtype developer_name: str + :keyword developer_website_url: Developer / publisher website URL shown in the Teams app + listing. Must be an https URL. Default value is None. + :paramtype developer_website_url: str + :keyword privacy_url: Privacy policy URL shown in the Teams app listing. Must be an http or + https URL. Default value is None. + :paramtype privacy_url: str + :keyword terms_of_use_url: Terms-of-use URL shown in the Teams app listing. Default value is + None. + :paramtype terms_of_use_url: str + :keyword color_icon_base64: Optional base64-encoded PNG used as the color (full-bleed) icon in + the Teams app package. Must be a + 192x192 PNG (perfect square, no border or rounded corners). Max 1 MB after decode. When + omitted, the + platform default color icon is used. Default value is None. + :paramtype color_icon_base64: str + :keyword outline_icon_base64: Optional base64-encoded PNG used as the outline icon in the Teams + app package. Must be a 32x32 PNG. + Max 1 MB after decode. When omitted, the platform default outline icon is used. Default value + is None. + :paramtype outline_icon_base64: str + :return: AsyncIterator[bytes] + :rtype: AsyncIterator[bytes] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def get_microsoft365_package( + self, agent_name: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncIterator[bytes]: + """Generate a Microsoft 365 app package. + + Generates the Microsoft Teams app package (zip) for a Foundry agent from the supplied publish + request, without publishing it. Returns the app package as ``application/zip``. + + :param agent_name: The name of the agent to generate the app package for. Required. + :type agent_name: str + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: AsyncIterator[bytes] + :rtype: AsyncIterator[bytes] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def get_microsoft365_package( + self, agent_name: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncIterator[bytes]: + """Generate a Microsoft 365 app package. + + Generates the Microsoft Teams app package (zip) for a Foundry agent from the supplied publish + request, without publishing it. Returns the app package as ``application/zip``. + + :param agent_name: The name of the agent to generate the app package for. Required. + :type agent_name: str + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: AsyncIterator[bytes] + :rtype: AsyncIterator[bytes] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace_async - async def download_session_file( - self, agent_name: str, session_id: str, *, path: str, **kwargs: Any + async def get_microsoft365_package( # pylint: disable=too-many-locals + self, + agent_name: str, + body: Union[JSON, IO[bytes]] = _Unset, + *, + publish_scope: Union[str, _models.Microsoft365PublishScope] = _Unset, + agent_display_name: Optional[str] = None, + bot_service_arm_id: Optional[str] = None, + publish_as_autopilot: Optional[bool] = None, + access_boundaries: Optional[List[Union[str, _models.ActivityProtocolAccessBoundary]]] = None, + optional_permission_scopes: Optional[List[_models.Microsoft365PermissionScopes]] = None, + can_respond_without_mention: Optional[bool] = None, + app_version: Optional[str] = None, + short_description: Optional[str] = None, + full_description: Optional[str] = None, + developer_name: Optional[str] = None, + developer_website_url: Optional[str] = None, + privacy_url: Optional[str] = None, + terms_of_use_url: Optional[str] = None, + color_icon_base64: Optional[str] = None, + outline_icon_base64: Optional[str] = None, + **kwargs: Any ) -> AsyncIterator[bytes]: - """Download a session file. + """Generate a Microsoft 365 app package. - Downloads the file at the specified sandbox path as a binary stream. The path is resolved - relative to the session home directory. + Generates the Microsoft Teams app package (zip) for a Foundry agent from the supplied publish + request, without publishing it. Returns the app package as ``application/zip``. - :param agent_name: The name of the agent. Required. + :param agent_name: The name of the agent to generate the app package for. Required. :type agent_name: str - :param session_id: The session ID. Required. - :type session_id: str - :keyword path: The file path to download from the sandbox, relative to the session home - directory. Required. - :paramtype path: str + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :keyword publish_scope: Publish scope for the Teams app. Known values are: "Personal", + "Shared", and "Tenant". Required. + :paramtype publish_scope: str or ~azure.ai.projects.models.Microsoft365PublishScope + :keyword agent_display_name: Display name used as the published Teams app name. When omitted, + the agent name from the route is + used. Default value is None. + :paramtype agent_display_name: str + :keyword bot_service_arm_id: ARM resource id of the Azure Bot Service that fronts this agent in + Microsoft Teams. Required for + workspaces on the default bot-based Teams backend; optional for workspaces on the API-based + backend. + Must not be supplied when ``publishAsAutopilot`` is true. Default value is None. + :paramtype bot_service_arm_id: str + :keyword publish_as_autopilot: When true, the agent is published as an autopilot (digital + worker) agent: the bot id is taken from + the agent's blueprint identity and the generated Teams manifest is marked as a digital worker. + Default value is None. + :paramtype publish_as_autopilot: bool + :keyword access_boundaries: Activity-protocol access boundaries to apply to the agent when + publishing as an autopilot agent. + An empty list clears the existing boundaries. When omitted, the existing boundaries are left + unchanged. Default value is None. + :paramtype access_boundaries: list[str or + ~azure.ai.projects.models.ActivityProtocolAccessBoundary] + :keyword optional_permission_scopes: Exact selection of delegated permission scopes to grant to + the autopilot blueprint. May only be + supplied when ``publishAsAutopilot`` is true. When omitted or empty, the platform's default + permission set is used. Mandatory platform permissions are always granted and are not affected + by + this value. Default value is None. + :paramtype optional_permission_scopes: + list[~azure.ai.projects.models.Microsoft365PermissionScopes] + :keyword can_respond_without_mention: Controls how the published agent responds to Teams + messages: when true it responds to all messages + on its surfaces, when false only when it is at-mentioned. When omitted, the agent's existing + Teams + message-notification setting is left unchanged. Default value is None. + :paramtype can_respond_without_mention: bool + :keyword app_version: App version (for example ``1.2.3``) written into the Teams manifest. May + contain only digits and + periods, must not start with ``0``, and must end with a digit. When omitted, a platform + default is + used. Default value is None. + :paramtype app_version: str + :keyword short_description: Short, one-line description shown in the Teams app listing. Default + value is None. + :paramtype short_description: str + :keyword full_description: Full description shown on the Teams app details page. Default value + is None. + :paramtype full_description: str + :keyword developer_name: Display name of the developer / publisher shown in the Teams app + listing. Default value is None. + :paramtype developer_name: str + :keyword developer_website_url: Developer / publisher website URL shown in the Teams app + listing. Must be an https URL. Default value is None. + :paramtype developer_website_url: str + :keyword privacy_url: Privacy policy URL shown in the Teams app listing. Must be an http or + https URL. Default value is None. + :paramtype privacy_url: str + :keyword terms_of_use_url: Terms-of-use URL shown in the Teams app listing. Default value is + None. + :paramtype terms_of_use_url: str + :keyword color_icon_base64: Optional base64-encoded PNG used as the color (full-bleed) icon in + the Teams app package. Must be a + 192x192 PNG (perfect square, no border or rounded corners). Max 1 MB after decode. When + omitted, the + platform default color icon is used. Default value is None. + :paramtype color_icon_base64: str + :keyword outline_icon_base64: Optional base64-encoded PNG used as the outline icon in the Teams + app package. Must be a 32x32 PNG. + Max 1 MB after decode. When omitted, the platform default outline icon is used. Default value + is None. + :paramtype outline_icon_base64: str :return: AsyncIterator[bytes] :rtype: AsyncIterator[bytes] :raises ~azure.core.exceptions.HttpResponseError: @@ -2366,16 +2842,46 @@ async def download_session_file( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_agents_download_session_file_request( + if body is _Unset: + if publish_scope is _Unset: + raise TypeError("missing required argument: publish_scope") + body = { + "accessBoundaries": access_boundaries, + "agentDisplayName": agent_display_name, + "appVersion": app_version, + "botServiceArmId": bot_service_arm_id, + "canRespondWithoutMention": can_respond_without_mention, + "colorIconBase64": color_icon_base64, + "developerName": developer_name, + "developerWebsiteUrl": developer_website_url, + "fullDescription": full_description, + "optionalPermissionScopes": optional_permission_scopes, + "outlineIconBase64": outline_icon_base64, + "privacyUrl": privacy_url, + "publishAsAutopilot": publish_as_autopilot, + "publishScope": publish_scope, + "shortDescription": short_description, + "termsOfUseUrl": terms_of_use_url, + } + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/json" + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_agents_get_microsoft365_package_request( agent_name=agent_name, - session_id=session_id, - path=path, + content_type=content_type, api_version=self._config.api_version, + content=_content, headers=_headers, params=_params, ) @@ -2405,142 +2911,33 @@ async def download_session_file( ) raise HttpResponseError(response=response, model=error) + response_headers = {} + response_headers["Content-Type"] = self._deserialize("str", response.headers.get("Content-Type")) + deserialized = response.iter_bytes() if _decompress else response.iter_raw() if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore - @distributed_trace - def list_session_files( - self, - agent_name: str, - session_id: str, - *, - path: Optional[str] = None, - limit: Optional[int] = None, - order: Optional[Union[str, _models.PageOrder]] = None, - before: Optional[str] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.SessionDirectoryEntry"]: - """List session files. + @distributed_trace_async + async def get_microsoft365_publish_defaults( + self, agent_name: str, *, publish_as_digital_worker: Optional[bool] = None, **kwargs: Any + ) -> _models.Microsoft365PublishDefaults: + """Get Microsoft 365 publish defaults. - Returns files and directories at the specified path in the session sandbox. The response - includes only the immediate children of the target directory and defaults to the session home - directory when no path is supplied. + Returns default and previously-published values used to pre-populate a Microsoft 365 publish + request for a Foundry agent. - :param agent_name: The name of the agent. Required. + :param agent_name: The name of the agent to get publish defaults for. Required. :type agent_name: str - :param session_id: The session ID. Required. - :type session_id: str - :keyword path: The directory path to list, relative to the session home directory. Defaults to - the home directory if not provided. Default value is None. - :paramtype path: str - :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and - 100, and the - default is 20. Default value is None. - :paramtype limit: int - :keyword order: Sort order by the ``created_at`` timestamp of the objects. ``asc`` for - ascending order and``desc`` - for descending order. Known values are: "asc" and "desc". Default value is None. - :paramtype order: str or ~azure.ai.projects.models.PageOrder - :keyword before: A cursor for use in pagination. ``before`` is an object ID that defines your - place in the list. - For instance, if you make a list request and receive 100 objects, ending with obj_foo, your - subsequent call can include before=obj_foo in order to fetch the previous page of the list. - Default value is None. - :paramtype before: str - :return: An iterator like instance of SessionDirectoryEntry - :rtype: - ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.models.SessionDirectoryEntry] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.SessionDirectoryEntry]] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(_continuation_token=None): - - _request = build_agents_list_session_files_request( - agent_name=agent_name, - session_id=session_id, - path=path, - limit=limit, - order=order, - after=_continuation_token, - before=before, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - return _request - - async def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize( - List[_models.SessionDirectoryEntry], - deserialized.get("entries", []), - ) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("last_id") or None, AsyncList(list_of_elem) - - async def get_next(_continuation_token=None): - _request = prepare_request(_continuation_token) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ApiErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def delete_session_file( - self, agent_name: str, session_id: str, *, path: str, recursive: Optional[bool] = None, **kwargs: Any - ) -> None: - """Delete a session file. - - Deletes the specified file or directory from the session sandbox. When ``recursive`` is false, - deleting a non-empty directory returns 409 Conflict. - - :param agent_name: The name of the agent. Required. - :type agent_name: str - :param session_id: The session ID. Required. - :type session_id: str - :keyword path: The file or directory path to delete, relative to the session home directory. - Required. - :paramtype path: str - :keyword recursive: Whether to recursively delete directory contents. The service defaults to - ``false`` if a value is not specified by the caller. Default value is None. - :paramtype recursive: bool - :return: None - :rtype: None + :keyword publish_as_digital_worker: When true, returns defaults for publishing the agent as an + autopilot (digital worker) agent. Default value is None. + :paramtype publish_as_digital_worker: bool + :return: Microsoft365PublishDefaults. The Microsoft365PublishDefaults is compatible with + MutableMapping + :rtype: ~azure.ai.projects.models.Microsoft365PublishDefaults :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -2554,13 +2951,11 @@ async def delete_session_file( _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[_models.Microsoft365PublishDefaults] = kwargs.pop("cls", None) - _request = build_agents_delete_session_file_request( + _request = build_agents_get_microsoft365_publish_defaults_request( agent_name=agent_name, - session_id=session_id, - path=path, - recursive=recursive, + publish_as_digital_worker=publish_as_digital_worker, api_version=self._config.api_version, headers=_headers, params=_params, @@ -2570,14 +2965,20 @@ async def delete_session_file( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [204]: + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = _failsafe_deserialize( _models.ApiErrorResponse, @@ -2585,37 +2986,102 @@ async def delete_session_file( ) raise HttpResponseError(response=response, model=error) + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Microsoft365PublishDefaults, response.json()) + if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized # type: ignore -class EvaluationRulesOperations: # pylint: disable=docstring-missing-param - """ - .. warning:: - **DO NOT** instantiate this class directly. + @overload + async def upload_session_file( + self, + agent_name: str, + session_id: str, + content: bytes, + *, + path: str, + content_type: str = "application/octet-stream", + **kwargs: Any + ) -> _models.SessionFileWriteResult: + """Upload a session file. - Instead, you should access the following operations through - :class:`~azure.ai.projects.aio.AIProjectClient`'s - :attr:`evaluation_rules` attribute. - """ + Uploads binary file content to the specified path in the session sandbox. The service stores + the file relative to the session home directory and rejects payloads larger than 50 MB. - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + :param agent_name: The name of the agent. Required. + :type agent_name: str + :param session_id: The session ID. Required. + :type session_id: str + :param content: Required. + :type content: bytes + :keyword path: The destination file path within the sandbox, relative to the session home + directory. Required. + :paramtype path: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/octet-stream". + :paramtype content_type: str + :return: SessionFileWriteResult. The SessionFileWriteResult is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.SessionFileWriteResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def upload_session_file( + self, + agent_name: str, + session_id: str, + content: IO[bytes], + *, + path: str, + content_type: str = "application/octet-stream", + **kwargs: Any + ) -> _models.SessionFileWriteResult: + """Upload a session file. + + Uploads binary file content to the specified path in the session sandbox. The service stores + the file relative to the session home directory and rejects payloads larger than 50 MB. + + :param agent_name: The name of the agent. Required. + :type agent_name: str + :param session_id: The session ID. Required. + :type session_id: str + :param content: Required. + :type content: IO[bytes] + :keyword path: The destination file path within the sandbox, relative to the session home + directory. Required. + :paramtype path: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/octet-stream". + :paramtype content_type: str + :return: SessionFileWriteResult. The SessionFileWriteResult is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.SessionFileWriteResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace_async - async def get(self, id: str, **kwargs: Any) -> _models.EvaluationRule: - """Get an evaluation rule. + async def upload_session_file( + self, agent_name: str, session_id: str, content: Union[bytes, IO[bytes]], *, path: str, **kwargs: Any + ) -> _models.SessionFileWriteResult: + """Upload a session file. - Retrieves the specified evaluation rule and its configuration. + Uploads binary file content to the specified path in the session sandbox. The service stores + the file relative to the session home directory and rejects payloads larger than 50 MB. - :param id: Unique identifier for the evaluation rule. Required. - :type id: str - :return: EvaluationRule. The EvaluationRule is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.EvaluationRule + :param agent_name: The name of the agent. Required. + :type agent_name: str + :param session_id: The session ID. Required. + :type session_id: str + :param content: Is either a bytes type or a IO[bytes] type. Required. + :type content: bytes or IO[bytes] + :keyword path: The destination file path within the sandbox, relative to the session home + directory. Required. + :paramtype path: str + :return: SessionFileWriteResult. The SessionFileWriteResult is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.SessionFileWriteResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -2626,14 +3092,22 @@ async def get(self, id: str, **kwargs: Any) -> _models.EvaluationRule: } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.EvaluationRule] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SessionFileWriteResult] = kwargs.pop("cls", None) - _request = build_evaluation_rules_get_request( - id=id, + content_type = content_type or "application/octet-stream" + _content = content + + _request = build_agents_upload_session_file_request( + agent_name=agent_name, + session_id=session_id, + path=path, + content_type=content_type, api_version=self._config.api_version, + content=_content, headers=_headers, params=_params, ) @@ -2650,19 +3124,23 @@ async def get(self, id: str, **kwargs: Any) -> _models.EvaluationRule: response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [201]: if _stream: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.EvaluationRule, response.json()) + deserialized = _deserialize(_models.SessionFileWriteResult, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -2670,15 +3148,23 @@ async def get(self, id: str, **kwargs: Any) -> _models.EvaluationRule: return deserialized # type: ignore @distributed_trace_async - async def delete(self, id: str, **kwargs: Any) -> None: - """Delete an evaluation rule. + async def download_session_file( + self, agent_name: str, session_id: str, *, path: str, **kwargs: Any + ) -> AsyncIterator[bytes]: + """Download a session file. - Removes the specified evaluation rule from the project. + Downloads the file at the specified sandbox path as a binary stream. The path is resolved + relative to the session home directory. - :param id: Unique identifier for the evaluation rule. Required. - :type id: str - :return: None - :rtype: None + :param agent_name: The name of the agent. Required. + :type agent_name: str + :param session_id: The session ID. Required. + :type session_id: str + :keyword path: The file path to download from the sandbox, relative to the session home + directory. Required. + :paramtype path: str + :return: AsyncIterator[bytes] + :rtype: AsyncIterator[bytes] :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -2692,10 +3178,12 @@ async def delete(self, id: str, **kwargs: Any) -> None: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) - _request = build_evaluation_rules_delete_request( - id=id, + _request = build_agents_download_session_file_request( + agent_name=agent_name, + session_id=session_id, + path=path, api_version=self._config.api_version, headers=_headers, params=_params, @@ -2705,95 +3193,163 @@ async def delete(self, id: str, **kwargs: Any) -> None: } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", True) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [204]: + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore - @overload - async def create_or_update( - self, id: str, evaluation_rule: _models.EvaluationRule, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.EvaluationRule: - """Create or update an evaluation rule. + return deserialized # type: ignore - Creates a new evaluation rule, or replaces the existing rule when the identifier matches. + @distributed_trace + def list_session_files( + self, + agent_name: str, + session_id: str, + *, + path: Optional[str] = None, + limit: Optional[int] = None, + order: Optional[Union[str, _models.PageOrder]] = None, + before: Optional[str] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.SessionDirectoryEntry"]: + """List session files. - :param id: Unique identifier for the evaluation rule. Required. - :type id: str - :param evaluation_rule: Evaluation rule resource. Required. - :type evaluation_rule: ~azure.ai.projects.models.EvaluationRule - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: EvaluationRule. The EvaluationRule is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.EvaluationRule + Returns files and directories at the specified path in the session sandbox. The response + includes only the immediate children of the target directory and defaults to the session home + directory when no path is supplied. + + :param agent_name: The name of the agent. Required. + :type agent_name: str + :param session_id: The session ID. Required. + :type session_id: str + :keyword path: The directory path to list, relative to the session home directory. Defaults to + the home directory if not provided. Default value is None. + :paramtype path: str + :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and + 100, and the + default is 20. Default value is None. + :paramtype limit: int + :keyword order: Sort order by the ``created_at`` timestamp of the objects. ``asc`` for + ascending order and``desc`` + for descending order. Known values are: "asc" and "desc". Default value is None. + :paramtype order: str or ~azure.ai.projects.models.PageOrder + :keyword before: A cursor for use in pagination. ``before`` is an object ID that defines your + place in the list. + For instance, if you make a list request and receive 100 objects, ending with obj_foo, your + subsequent call can include before=obj_foo in order to fetch the previous page of the list. + Default value is None. + :paramtype before: str + :return: An iterator like instance of SessionDirectoryEntry + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.models.SessionDirectoryEntry] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - @overload - async def create_or_update( - self, id: str, evaluation_rule: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.EvaluationRule: - """Create or update an evaluation rule. + cls: ClsType[List[_models.SessionDirectoryEntry]] = kwargs.pop("cls", None) - Creates a new evaluation rule, or replaces the existing rule when the identifier matches. + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - :param id: Unique identifier for the evaluation rule. Required. - :type id: str - :param evaluation_rule: Evaluation rule resource. Required. - :type evaluation_rule: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: EvaluationRule. The EvaluationRule is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.EvaluationRule - :raises ~azure.core.exceptions.HttpResponseError: - """ + def prepare_request(_continuation_token=None): - @overload - async def create_or_update( - self, id: str, evaluation_rule: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.EvaluationRule: - """Create or update an evaluation rule. + _request = build_agents_list_session_files_request( + agent_name=agent_name, + session_id=session_id, + path=path, + limit=limit, + order=order, + after=_continuation_token, + before=before, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + return _request - Creates a new evaluation rule, or replaces the existing rule when the identifier matches. + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SessionDirectoryEntry], + deserialized.get("entries", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("last_id") or None, AsyncList(list_of_elem) - :param id: Unique identifier for the evaluation rule. Required. - :type id: str - :param evaluation_rule: Evaluation rule resource. Required. - :type evaluation_rule: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: EvaluationRule. The EvaluationRule is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.EvaluationRule - :raises ~azure.core.exceptions.HttpResponseError: - """ + async def get_next(_continuation_token=None): + _request = prepare_request(_continuation_token) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) @distributed_trace_async - async def create_or_update( - self, id: str, evaluation_rule: Union[_models.EvaluationRule, JSON, IO[bytes]], **kwargs: Any - ) -> _models.EvaluationRule: - """Create or update an evaluation rule. + async def delete_session_file( + self, agent_name: str, session_id: str, *, path: str, recursive: Optional[bool] = None, **kwargs: Any + ) -> None: + """Delete a session file. - Creates a new evaluation rule, or replaces the existing rule when the identifier matches. + Deletes the specified file or directory from the session sandbox. When ``recursive`` is false, + deleting a non-empty directory returns 409 Conflict. - :param id: Unique identifier for the evaluation rule. Required. - :type id: str - :param evaluation_rule: Evaluation rule resource. Is one of the following types: - EvaluationRule, JSON, IO[bytes] Required. - :type evaluation_rule: ~azure.ai.projects.models.EvaluationRule or JSON or IO[bytes] - :return: EvaluationRule. The EvaluationRule is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.EvaluationRule + :param agent_name: The name of the agent. Required. + :type agent_name: str + :param session_id: The session ID. Required. + :type session_id: str + :keyword path: The file or directory path to delete, relative to the session home directory. + Required. + :paramtype path: str + :keyword recursive: Whether to recursively delete directory contents. The service defaults to + ``false`` if a value is not specified by the caller. Default value is None. + :paramtype recursive: bool + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -2804,24 +3360,17 @@ async def create_or_update( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.EvaluationRule] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _content = None - if isinstance(evaluation_rule, (IOBase, bytes)): - _content = evaluation_rule - else: - _content = json.dumps(evaluation_rule, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_evaluation_rules_create_or_update_request( - id=id, - content_type=content_type, + _request = build_agents_delete_session_file_request( + agent_name=agent_name, + session_id=session_id, + path=path, + recursive=recursive, api_version=self._config.api_version, - content=_content, headers=_headers, params=_params, ) @@ -2830,150 +3379,33 @@ async def create_or_update( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 201]: - if _stream: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - deserialized = _deserialize(_models.EvaluationRule, response.json()) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def list( - self, - *, - action_type: Optional[Union[str, _models.EvaluationRuleActionType]] = None, - agent_name: Optional[str] = None, - enabled: Optional[bool] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.EvaluationRule"]: - """List evaluation rules. - - Returns the evaluation rules configured for the project, optionally filtered by action type, - agent name, or enabled state. - - :keyword action_type: Filter by the type of evaluation rule. Known values are: - "continuousEvaluation" and "humanEvaluationPreview". Default value is None. - :paramtype action_type: str or ~azure.ai.projects.models.EvaluationRuleActionType - :keyword agent_name: Filter by the agent name. Default value is None. - :paramtype agent_name: str - :keyword enabled: Filter by the enabled status. Default value is None. - :paramtype enabled: bool - :return: An iterator like instance of EvaluationRule - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.models.EvaluationRule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.EvaluationRule]] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_evaluation_rules_list_request( - action_type=action_type, - agent_name=agent_name, - enabled=enabled, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - return _request - - async def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize( - List[_models.EvaluationRule], - deserialized.get("value", []), - ) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) + return cls(pipeline_response, None, {}) # type: ignore -class ConnectionsOperations: # pylint: disable=docstring-missing-param +class EvaluationRulesOperations: # pylint: disable=docstring-missing-param """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.ai.projects.aio.AIProjectClient`'s - :attr:`connections` attribute. + :attr:`evaluation_rules` attribute. """ def __init__(self, *args, **kwargs) -> None: @@ -2984,16 +3416,15 @@ def __init__(self, *args, **kwargs) -> None: self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace_async - async def _get(self, name: str, **kwargs: Any) -> _models.Connection: - """Get a connection. + async def get(self, id: str, **kwargs: Any) -> _models.EvaluationRule: + """Get an evaluation rule. - Retrieves the specified connection and its configuration details without including credential - values. + Retrieves the specified evaluation rule and its configuration. - :param name: The friendly name of the connection, provided by the user. Required. - :type name: str - :return: Connection. The Connection is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.Connection + :param id: Unique identifier for the evaluation rule. Required. + :type id: str + :return: EvaluationRule. The EvaluationRule is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.EvaluationRule :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -3007,10 +3438,10 @@ async def _get(self, name: str, **kwargs: Any) -> _models.Connection: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.Connection] = kwargs.pop("cls", None) + cls: ClsType[_models.EvaluationRule] = kwargs.pop("cls", None) - _request = build_connections_get_request( - name=name, + _request = build_evaluation_rules_get_request( + id=id, api_version=self._config.api_version, headers=_headers, params=_params, @@ -3037,31 +3468,26 @@ async def _get(self, name: str, **kwargs: Any) -> _models.Connection: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) - response_headers = {} - response_headers["x-ms-client-request-id"] = self._deserialize( - "str", response.headers.get("x-ms-client-request-id") - ) - if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.Connection, response.json()) + deserialized = _deserialize(_models.EvaluationRule, response.json()) if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore @distributed_trace_async - async def _get_with_credentials(self, name: str, **kwargs: Any) -> _models.Connection: - """Get a connection with credentials. + async def delete(self, id: str, **kwargs: Any) -> None: + """Delete an evaluation rule. - Retrieves the specified connection together with its credential values. + Removes the specified evaluation rule from the project. - :param name: The friendly name of the connection, provided by the user. Required. - :type name: str - :return: Connection. The Connection is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.Connection + :param id: Unique identifier for the evaluation rule. Required. + :type id: str + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -3075,10 +3501,10 @@ async def _get_with_credentials(self, name: str, **kwargs: Any) -> _models.Conne _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.Connection] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_connections_get_with_credentials_request( - name=name, + _request = build_evaluation_rules_delete_request( + id=id, api_version=self._config.api_version, headers=_headers, params=_params, @@ -3088,178 +3514,187 @@ async def _get_with_credentials(self, name: str, **kwargs: Any) -> _models.Conne } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200]: - if _stream: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) - response_headers = {} - response_headers["x-ms-client-request-id"] = self._deserialize( - "str", response.headers.get("x-ms-client-request-id") - ) + if cls: + return cls(pipeline_response, None, {}) # type: ignore - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - deserialized = _deserialize(_models.Connection, response.json()) + @overload + async def create_or_update( + self, id: str, evaluation_rule: _models.EvaluationRule, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.EvaluationRule: + """Create or update an evaluation rule. - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore + Creates a new evaluation rule, or replaces the existing rule when the identifier matches. - return deserialized # type: ignore + :param id: Unique identifier for the evaluation rule. Required. + :type id: str + :param evaluation_rule: Evaluation rule resource. Required. + :type evaluation_rule: ~azure.ai.projects.models.EvaluationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: EvaluationRule. The EvaluationRule is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.EvaluationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ - @distributed_trace - def list( - self, - *, - connection_type: Optional[Union[str, _models.ConnectionType]] = None, - default_connection: Optional[bool] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.Connection"]: - """List connections. + @overload + async def create_or_update( + self, id: str, evaluation_rule: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.EvaluationRule: + """Create or update an evaluation rule. - Returns the connections available in the current project, optionally filtered by type or - default status. + Creates a new evaluation rule, or replaces the existing rule when the identifier matches. - :keyword connection_type: Lists connections of this specific type. Known values are: - "AzureOpenAI", "AzureBlob", "AzureStorageAccount", "CognitiveSearch", "CosmosDB", "ApiKey", - "AppConfig", "AppInsights", "CustomKeys", and "RemoteTool_Preview". Default value is None. - :paramtype connection_type: str or ~azure.ai.projects.models.ConnectionType - :keyword default_connection: Lists connections that are default connections. Default value is - None. - :paramtype default_connection: bool - :return: An iterator like instance of Connection - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.models.Connection] + :param id: Unique identifier for the evaluation rule. Required. + :type id: str + :param evaluation_rule: Evaluation rule resource. Required. + :type evaluation_rule: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: EvaluationRule. The EvaluationRule is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.EvaluationRule :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.Connection]] = kwargs.pop("cls", None) + @overload + async def create_or_update( + self, id: str, evaluation_rule: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.EvaluationRule: + """Create or update an evaluation rule. - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) + Creates a new evaluation rule, or replaces the existing rule when the identifier matches. - def prepare_request(next_link=None): - if not next_link: + :param id: Unique identifier for the evaluation rule. Required. + :type id: str + :param evaluation_rule: Evaluation rule resource. Required. + :type evaluation_rule: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: EvaluationRule. The EvaluationRule is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.EvaluationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ - _request = build_connections_list_request( - connection_type=connection_type, - default_connection=default_connection, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + @distributed_trace_async + async def create_or_update( + self, id: str, evaluation_rule: Union[_models.EvaluationRule, JSON, IO[bytes]], **kwargs: Any + ) -> _models.EvaluationRule: + """Create or update an evaluation rule. - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + Creates a new evaluation rule, or replaces the existing rule when the identifier matches. - return _request + :param id: Unique identifier for the evaluation rule. Required. + :type id: str + :param evaluation_rule: Evaluation rule resource. Is one of the following types: + EvaluationRule, JSON, IO[bytes] Required. + :type evaluation_rule: ~azure.ai.projects.models.EvaluationRule or JSON or IO[bytes] + :return: EvaluationRule. The EvaluationRule is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.EvaluationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - async def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize( - List[_models.Connection], - deserialized.get("value", []), - ) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - async def get_next(next_link=None): - _request = prepare_request(next_link) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.EvaluationRule] = kwargs.pop("cls", None) - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response + content_type = content_type or "application/json" + _content = None + if isinstance(evaluation_rule, (IOBase, bytes)): + _content = evaluation_rule + else: + _content = json.dumps(evaluation_rule, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + _request = build_evaluation_rules_create_or_update_request( + id=id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - return pipeline_response + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - return AsyncItemPaged(get_next, extract_data) + response = pipeline_response.http_response + if response.status_code not in [200, 201]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) -class DatasetsOperations: # pylint: disable=docstring-missing-param - """ - .. warning:: - **DO NOT** instantiate this class directly. + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.EvaluationRule, response.json()) - Instead, you should access the following operations through - :class:`~azure.ai.projects.aio.AIProjectClient`'s - :attr:`datasets` attribute. - """ + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + return deserialized # type: ignore @distributed_trace - def list_versions(self, name: str, **kwargs: Any) -> AsyncItemPaged["_models.DatasetVersion"]: - """List versions. + def list( + self, + *, + action_type: Optional[Union[str, _models.EvaluationRuleActionType]] = None, + agent_name: Optional[str] = None, + enabled: Optional[bool] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.EvaluationRule"]: + """List evaluation rules. - List all versions of the given DatasetVersion. + Returns the evaluation rules configured for the project, optionally filtered by action type, + agent name, or enabled state. - :param name: The name of the resource. Required. - :type name: str - :return: An iterator like instance of DatasetVersion - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.models.DatasetVersion] + :keyword action_type: Filter by the type of evaluation rule. Known values are: + "continuousEvaluation" and "humanEvaluationPreview". Default value is None. + :paramtype action_type: str or ~azure.ai.projects.models.EvaluationRuleActionType + :keyword agent_name: Filter by the agent name. Default value is None. + :paramtype agent_name: str + :keyword enabled: Filter by the enabled status. Default value is None. + :paramtype enabled: bool + :return: An iterator like instance of EvaluationRule + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.models.EvaluationRule] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.DatasetVersion]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.EvaluationRule]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -3272,8 +3707,10 @@ def list_versions(self, name: str, **kwargs: Any) -> AsyncItemPaged["_models.Dat def prepare_request(next_link=None): if not next_link: - _request = build_datasets_list_versions_request( - name=name, + _request = build_evaluation_rules_list_request( + action_type=action_type, + agent_name=agent_name, + enabled=enabled, api_version=self._config.api_version, headers=_headers, params=_params, @@ -3313,7 +3750,7 @@ def prepare_request(next_link=None): async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() list_of_elem = _deserialize( - List[_models.DatasetVersion], + List[_models.EvaluationRule], deserialized.get("value", []), ) if cls: @@ -3337,21 +3774,37 @@ async def get_next(next_link=None): return AsyncItemPaged(get_next, extract_data) - @distributed_trace - def list(self, **kwargs: Any) -> AsyncItemPaged["_models.DatasetVersion"]: - """List latest versions. - List the latest version of each DatasetVersion. +class ConnectionsOperations: # pylint: disable=docstring-missing-param + """ + .. warning:: + **DO NOT** instantiate this class directly. - :return: An iterator like instance of DatasetVersion - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.models.DatasetVersion] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} + Instead, you should access the following operations through + :class:`~azure.ai.projects.aio.AIProjectClient`'s + :attr:`connections` attribute. + """ - cls: ClsType[List[_models.DatasetVersion]] = kwargs.pop("cls", None) + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace_async + async def _get(self, name: str, **kwargs: Any) -> _models.Connection: + """Get a connection. + + Retrieves the specified connection and its configuration details without including credential + values. + + :param name: The friendly name of the connection, provided by the user. Required. + :type name: str + :return: Connection. The Connection is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.Connection + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -3360,104 +3813,13 @@ def list(self, **kwargs: Any) -> AsyncItemPaged["_models.DatasetVersion"]: } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - _request = build_datasets_list_request( - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + cls: ClsType[_models.Connection] = kwargs.pop("cls", None) - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - return _request - - async def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize( - List[_models.DatasetVersion], - deserialized.get("value", []), - ) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, AsyncList(list_of_elem) - - async def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace_async - async def get(self, name: str, version: str, **kwargs: Any) -> _models.DatasetVersion: - """Get a version. - - Get the specific version of the DatasetVersion. The service returns 404 Not Found error if the - DatasetVersion does not exist. - - :param name: The name of the resource. Required. - :type name: str - :param version: The specific version id of the DatasetVersion to retrieve. Required. - :type version: str - :return: DatasetVersion. The DatasetVersion is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.DatasetVersion - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.DatasetVersion] = kwargs.pop("cls", None) - - _request = build_datasets_get_request( + _request = build_connections_get_request( name=name, - version=version, api_version=self._config.api_version, headers=_headers, params=_params, @@ -3484,29 +3846,31 @@ async def get(self, name: str, version: str, **kwargs: Any) -> _models.DatasetVe map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) + response_headers = {} + response_headers["x-ms-client-request-id"] = self._deserialize( + "str", response.headers.get("x-ms-client-request-id") + ) + if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.DatasetVersion, response.json()) + deserialized = _deserialize(_models.Connection, response.json()) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @distributed_trace_async - async def delete(self, name: str, version: str, **kwargs: Any) -> None: - """Delete a version. + async def _get_with_credentials(self, name: str, **kwargs: Any) -> _models.Connection: + """Get a connection with credentials. - Delete the specific version of the DatasetVersion. The service returns 204 No Content if the - DatasetVersion was deleted successfully or if the DatasetVersion does not exist. + Retrieves the specified connection together with its credential values. - :param name: The name of the resource. Required. + :param name: The friendly name of the connection, provided by the user. Required. :type name: str - :param version: The version of the DatasetVersion to delete. Required. - :type version: str - :return: None - :rtype: None + :return: Connection. The Connection is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.Connection :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -3520,11 +3884,10 @@ async def delete(self, name: str, version: str, **kwargs: Any) -> None: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[_models.Connection] = kwargs.pop("cls", None) - _request = build_datasets_delete_request( + _request = build_connections_get_with_credentials_request( name=name, - version=version, api_version=self._config.api_version, headers=_headers, params=_params, @@ -3534,123 +3897,67 @@ async def delete(self, name: str, version: str, **kwargs: Any) -> None: } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [204]: + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @overload - async def create_or_update( - self, - name: str, - version: str, - dataset_version: _models.DatasetVersion, - *, - content_type: str = "application/merge-patch+json", - **kwargs: Any - ) -> _models.DatasetVersion: - """Create or update a version. - - Create a new or update an existing DatasetVersion with the given version id. - - :param name: The name of the resource. Required. - :type name: str - :param version: The specific version id of the DatasetVersion to create or update. Required. - :type version: str - :param dataset_version: The DatasetVersion to create or update. Required. - :type dataset_version: ~azure.ai.projects.models.DatasetVersion - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/merge-patch+json". - :paramtype content_type: str - :return: DatasetVersion. The DatasetVersion is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.DatasetVersion - :raises ~azure.core.exceptions.HttpResponseError: - """ + response_headers = {} + response_headers["x-ms-client-request-id"] = self._deserialize( + "str", response.headers.get("x-ms-client-request-id") + ) - @overload - async def create_or_update( - self, - name: str, - version: str, - dataset_version: JSON, - *, - content_type: str = "application/merge-patch+json", - **kwargs: Any - ) -> _models.DatasetVersion: - """Create or update a version. + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Connection, response.json()) - Create a new or update an existing DatasetVersion with the given version id. + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - :param name: The name of the resource. Required. - :type name: str - :param version: The specific version id of the DatasetVersion to create or update. Required. - :type version: str - :param dataset_version: The DatasetVersion to create or update. Required. - :type dataset_version: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/merge-patch+json". - :paramtype content_type: str - :return: DatasetVersion. The DatasetVersion is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.DatasetVersion - :raises ~azure.core.exceptions.HttpResponseError: - """ + return deserialized # type: ignore - @overload - async def create_or_update( + @distributed_trace + def list( self, - name: str, - version: str, - dataset_version: IO[bytes], *, - content_type: str = "application/merge-patch+json", + connection_type: Optional[Union[str, _models.ConnectionType]] = None, + default_connection: Optional[bool] = None, **kwargs: Any - ) -> _models.DatasetVersion: - """Create or update a version. + ) -> AsyncItemPaged["_models.Connection"]: + """List connections. - Create a new or update an existing DatasetVersion with the given version id. + Returns the connections available in the current project, optionally filtered by type or + default status. - :param name: The name of the resource. Required. - :type name: str - :param version: The specific version id of the DatasetVersion to create or update. Required. - :type version: str - :param dataset_version: The DatasetVersion to create or update. Required. - :type dataset_version: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/merge-patch+json". - :paramtype content_type: str - :return: DatasetVersion. The DatasetVersion is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.DatasetVersion + :keyword connection_type: Lists connections of this specific type. Known values are: + "AzureOpenAI", "AzureBlob", "AzureStorageAccount", "CognitiveSearch", "CosmosDB", "ApiKey", + "AppConfig", "AppInsights", "CustomKeys", and "RemoteTool_Preview". Default value is None. + :paramtype connection_type: str or ~azure.ai.projects.models.ConnectionType + :keyword default_connection: Lists connections that are default connections. Default value is + None. + :paramtype default_connection: bool + :return: An iterator like instance of Connection + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.models.Connection] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - @distributed_trace_async - async def create_or_update( - self, name: str, version: str, dataset_version: Union[_models.DatasetVersion, JSON, IO[bytes]], **kwargs: Any - ) -> _models.DatasetVersion: - """Create or update a version. - - Create a new or update an existing DatasetVersion with the given version id. + cls: ClsType[List[_models.Connection]] = kwargs.pop("cls", None) - :param name: The name of the resource. Required. - :type name: str - :param version: The specific version id of the DatasetVersion to create or update. Required. - :type version: str - :param dataset_version: The DatasetVersion to create or update. Is one of the following types: - DatasetVersion, JSON, IO[bytes] Required. - :type dataset_version: ~azure.ai.projects.models.DatasetVersion or JSON or IO[bytes] - :return: DatasetVersion. The DatasetVersion is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.DatasetVersion - :raises ~azure.core.exceptions.HttpResponseError: - """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -3659,25 +3966,1976 @@ async def create_or_update( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) - _params = kwargs.pop("params", {}) or {} + def prepare_request(next_link=None): + if not next_link: - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DatasetVersion] = kwargs.pop("cls", None) + _request = build_connections_list_request( + connection_type=connection_type, + default_connection=default_connection, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - content_type = content_type or "application/merge-patch+json" - _content = None + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Connection], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class DatasetsOperations: # pylint: disable=docstring-missing-param + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.ai.projects.aio.AIProjectClient`'s + :attr:`datasets` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_versions(self, name: str, **kwargs: Any) -> AsyncItemPaged["_models.DatasetVersion"]: + """List versions. + + List all versions of the given DatasetVersion. + + :param name: The name of the resource. Required. + :type name: str + :return: An iterator like instance of DatasetVersion + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.models.DatasetVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DatasetVersion]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_datasets_list_versions_request( + name=name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.DatasetVersion], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncItemPaged["_models.DatasetVersion"]: + """List latest versions. + + List the latest version of each DatasetVersion. + + :return: An iterator like instance of DatasetVersion + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.models.DatasetVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DatasetVersion]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_datasets_list_request( + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.DatasetVersion], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get(self, name: str, version: str, **kwargs: Any) -> _models.DatasetVersion: + """Get a version. + + Get the specific version of the DatasetVersion. The service returns 404 Not Found error if the + DatasetVersion does not exist. + + :param name: The name of the resource. Required. + :type name: str + :param version: The specific version id of the DatasetVersion to retrieve. Required. + :type version: str + :return: DatasetVersion. The DatasetVersion is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.DatasetVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.DatasetVersion] = kwargs.pop("cls", None) + + _request = build_datasets_get_request( + name=name, + version=version, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DatasetVersion, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete(self, name: str, version: str, **kwargs: Any) -> None: + """Delete a version. + + Delete the specific version of the DatasetVersion. The service returns 204 No Content if the + DatasetVersion was deleted successfully or if the DatasetVersion does not exist. + + :param name: The name of the resource. Required. + :type name: str + :param version: The version of the DatasetVersion to delete. Required. + :type version: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_datasets_delete_request( + name=name, + version=version, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @overload + async def create_or_update( + self, + name: str, + version: str, + dataset_version: _models.DatasetVersion, + *, + content_type: str = "application/merge-patch+json", + **kwargs: Any + ) -> _models.DatasetVersion: + """Create or update a version. + + Create a new or update an existing DatasetVersion with the given version id. + + :param name: The name of the resource. Required. + :type name: str + :param version: The specific version id of the DatasetVersion to create or update. Required. + :type version: str + :param dataset_version: The DatasetVersion to create or update. Required. + :type dataset_version: ~azure.ai.projects.models.DatasetVersion + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/merge-patch+json". + :paramtype content_type: str + :return: DatasetVersion. The DatasetVersion is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.DatasetVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + name: str, + version: str, + dataset_version: JSON, + *, + content_type: str = "application/merge-patch+json", + **kwargs: Any + ) -> _models.DatasetVersion: + """Create or update a version. + + Create a new or update an existing DatasetVersion with the given version id. + + :param name: The name of the resource. Required. + :type name: str + :param version: The specific version id of the DatasetVersion to create or update. Required. + :type version: str + :param dataset_version: The DatasetVersion to create or update. Required. + :type dataset_version: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/merge-patch+json". + :paramtype content_type: str + :return: DatasetVersion. The DatasetVersion is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.DatasetVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + name: str, + version: str, + dataset_version: IO[bytes], + *, + content_type: str = "application/merge-patch+json", + **kwargs: Any + ) -> _models.DatasetVersion: + """Create or update a version. + + Create a new or update an existing DatasetVersion with the given version id. + + :param name: The name of the resource. Required. + :type name: str + :param version: The specific version id of the DatasetVersion to create or update. Required. + :type version: str + :param dataset_version: The DatasetVersion to create or update. Required. + :type dataset_version: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/merge-patch+json". + :paramtype content_type: str + :return: DatasetVersion. The DatasetVersion is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.DatasetVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, name: str, version: str, dataset_version: Union[_models.DatasetVersion, JSON, IO[bytes]], **kwargs: Any + ) -> _models.DatasetVersion: + """Create or update a version. + + Create a new or update an existing DatasetVersion with the given version id. + + :param name: The name of the resource. Required. + :type name: str + :param version: The specific version id of the DatasetVersion to create or update. Required. + :type version: str + :param dataset_version: The DatasetVersion to create or update. Is one of the following types: + DatasetVersion, JSON, IO[bytes] Required. + :type dataset_version: ~azure.ai.projects.models.DatasetVersion or JSON or IO[bytes] + :return: DatasetVersion. The DatasetVersion is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.DatasetVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DatasetVersion] = kwargs.pop("cls", None) + + content_type = content_type or "application/merge-patch+json" + _content = None if isinstance(dataset_version, (IOBase, bytes)): _content = dataset_version else: - _content = json.dumps(dataset_version, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = json.dumps(dataset_version, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_datasets_create_or_update_request( + name=name, + version=version, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DatasetVersion, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + async def pending_upload( + self, + name: str, + version: str, + pending_upload_request: _models.PendingUploadRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PendingUploadResponse: + """Start a pending upload. + + Initiates a new pending upload or retrieves an existing one for the specified dataset version. + + :param name: The name of the resource. Required. + :type name: str + :param version: The specific version id of the DatasetVersion to operate on. Required. + :type version: str + :param pending_upload_request: The pending upload request parameters. Required. + :type pending_upload_request: ~azure.ai.projects.models.PendingUploadRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: PendingUploadResponse. The PendingUploadResponse is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.PendingUploadResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def pending_upload( + self, + name: str, + version: str, + pending_upload_request: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PendingUploadResponse: + """Start a pending upload. + + Initiates a new pending upload or retrieves an existing one for the specified dataset version. + + :param name: The name of the resource. Required. + :type name: str + :param version: The specific version id of the DatasetVersion to operate on. Required. + :type version: str + :param pending_upload_request: The pending upload request parameters. Required. + :type pending_upload_request: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: PendingUploadResponse. The PendingUploadResponse is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.PendingUploadResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def pending_upload( + self, + name: str, + version: str, + pending_upload_request: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PendingUploadResponse: + """Start a pending upload. + + Initiates a new pending upload or retrieves an existing one for the specified dataset version. + + :param name: The name of the resource. Required. + :type name: str + :param version: The specific version id of the DatasetVersion to operate on. Required. + :type version: str + :param pending_upload_request: The pending upload request parameters. Required. + :type pending_upload_request: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: PendingUploadResponse. The PendingUploadResponse is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.PendingUploadResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def pending_upload( + self, + name: str, + version: str, + pending_upload_request: Union[_models.PendingUploadRequest, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.PendingUploadResponse: + """Start a pending upload. + + Initiates a new pending upload or retrieves an existing one for the specified dataset version. + + :param name: The name of the resource. Required. + :type name: str + :param version: The specific version id of the DatasetVersion to operate on. Required. + :type version: str + :param pending_upload_request: The pending upload request parameters. Is one of the following + types: PendingUploadRequest, JSON, IO[bytes] Required. + :type pending_upload_request: ~azure.ai.projects.models.PendingUploadRequest or JSON or + IO[bytes] + :return: PendingUploadResponse. The PendingUploadResponse is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.PendingUploadResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PendingUploadResponse] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(pending_upload_request, (IOBase, bytes)): + _content = pending_upload_request + else: + _content = json.dumps(pending_upload_request, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_datasets_pending_upload_request( + name=name, + version=version, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PendingUploadResponse, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get_credentials(self, name: str, version: str, **kwargs: Any) -> _models.DatasetCredential: + """Get dataset credentials. + + Retrieves the SAS credential to access the storage account associated with a dataset version. + + :param name: The name of the resource. Required. + :type name: str + :param version: The specific version id of the DatasetVersion to operate on. Required. + :type version: str + :return: DatasetCredential. The DatasetCredential is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.DatasetCredential + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.DatasetCredential] = kwargs.pop("cls", None) + + _request = build_datasets_get_credentials_request( + name=name, + version=version, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DatasetCredential, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class DeploymentsOperations: # pylint: disable=docstring-missing-param + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.ai.projects.aio.AIProjectClient`'s + :attr:`deployments` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async + async def get(self, name: str, **kwargs: Any) -> _models.Deployment: + """Get a deployment. + + Retrieves a deployed model. + + :param name: Name of the deployment. Required. + :type name: str + :return: Deployment. The Deployment is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.Deployment + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Deployment] = kwargs.pop("cls", None) + + _request = build_deployments_get_request( + name=name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + response_headers = {} + response_headers["x-ms-client-request-id"] = self._deserialize( + "str", response.headers.get("x-ms-client-request-id") + ) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Deployment, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list( + self, + *, + model_publisher: Optional[str] = None, + model_name: Optional[str] = None, + deployment_type: Optional[Union[str, _models.DeploymentType]] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.Deployment"]: + """List deployments. + + Returns the deployed models available in the current project, optionally filtered by publisher, + model name, or deployment type. + + :keyword model_publisher: Model publisher to filter models by. Default value is None. + :paramtype model_publisher: str + :keyword model_name: Model name (the publisher specific name) to filter models by. Default + value is None. + :paramtype model_name: str + :keyword deployment_type: Type of deployment to filter list by. "ModelDeployment" Default value + is None. + :paramtype deployment_type: str or ~azure.ai.projects.models.DeploymentType + :return: An iterator like instance of Deployment + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.models.Deployment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Deployment]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_deployments_list_request( + model_publisher=model_publisher, + model_name=model_name, + deployment_type=deployment_type, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Deployment], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + +class IndexesOperations: # pylint: disable=docstring-missing-param + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.ai.projects.aio.AIProjectClient`'s + :attr:`indexes` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_versions(self, name: str, **kwargs: Any) -> AsyncItemPaged["_models.Index"]: + """List versions. + + List all versions of the given Index. + + :param name: The name of the resource. Required. + :type name: str + :return: An iterator like instance of Index + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.models.Index] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Index]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_indexes_list_versions_request( + name=name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Index], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list(self, **kwargs: Any) -> AsyncItemPaged["_models.Index"]: + """List latest versions. + + List the latest version of each Index. + + :return: An iterator like instance of Index + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.models.Index] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Index]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_indexes_list_request( + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Index], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + + async def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get(self, name: str, version: str, **kwargs: Any) -> _models.Index: + """Get a version. + + Get the specific version of the Index. The service returns 404 Not Found error if the Index + does not exist. + + :param name: The name of the resource. Required. + :type name: str + :param version: The specific version id of the Index to retrieve. Required. + :type version: str + :return: Index. The Index is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.Index + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Index] = kwargs.pop("cls", None) + + _request = build_indexes_get_request( + name=name, + version=version, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Index, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def delete(self, name: str, version: str, **kwargs: Any) -> None: + """Delete a version. + + Delete the specific version of the Index. The service returns 204 No Content if the Index was + deleted successfully or if the Index does not exist. + + :param name: The name of the resource. Required. + :type name: str + :param version: The version of the Index to delete. Required. + :type version: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_indexes_delete_request( + name=name, + version=version, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @overload + async def create_or_update( + self, + name: str, + version: str, + index: _models.Index, + *, + content_type: str = "application/merge-patch+json", + **kwargs: Any + ) -> _models.Index: + """Create or update a version. + + Create a new or update an existing Index with the given version id. + + :param name: The name of the resource. Required. + :type name: str + :param version: The specific version id of the Index to create or update. Required. + :type version: str + :param index: The Index to create or update. Required. + :type index: ~azure.ai.projects.models.Index + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/merge-patch+json". + :paramtype content_type: str + :return: Index. The Index is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.Index + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, name: str, version: str, index: JSON, *, content_type: str = "application/merge-patch+json", **kwargs: Any + ) -> _models.Index: + """Create or update a version. + + Create a new or update an existing Index with the given version id. + + :param name: The name of the resource. Required. + :type name: str + :param version: The specific version id of the Index to create or update. Required. + :type version: str + :param index: The Index to create or update. Required. + :type index: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/merge-patch+json". + :paramtype content_type: str + :return: Index. The Index is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.Index + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_or_update( + self, + name: str, + version: str, + index: IO[bytes], + *, + content_type: str = "application/merge-patch+json", + **kwargs: Any + ) -> _models.Index: + """Create or update a version. + + Create a new or update an existing Index with the given version id. + + :param name: The name of the resource. Required. + :type name: str + :param version: The specific version id of the Index to create or update. Required. + :type version: str + :param index: The Index to create or update. Required. + :type index: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/merge-patch+json". + :paramtype content_type: str + :return: Index. The Index is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.Index + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_or_update( + self, name: str, version: str, index: Union[_models.Index, JSON, IO[bytes]], **kwargs: Any + ) -> _models.Index: + """Create or update a version. + + Create a new or update an existing Index with the given version id. + + :param name: The name of the resource. Required. + :type name: str + :param version: The specific version id of the Index to create or update. Required. + :type version: str + :param index: The Index to create or update. Is one of the following types: Index, JSON, + IO[bytes] Required. + :type index: ~azure.ai.projects.models.Index or JSON or IO[bytes] + :return: Index. The Index is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.Index + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Index] = kwargs.pop("cls", None) + + content_type = content_type or "application/merge-patch+json" + _content = None + if isinstance(index, (IOBase, bytes)): + _content = index + else: + _content = json.dumps(index, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_indexes_create_or_update_request( + name=name, + version=version, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Index, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class ToolboxesOperations: # pylint: disable=docstring-missing-param + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.ai.projects.aio.AIProjectClient`'s + :attr:`toolboxes` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @overload + async def create_version( + self, + name: str, + *, + tools: List[_models.ToolboxTool], + content_type: str = "application/json", + description: Optional[str] = None, + metadata: Optional[dict[str, str]] = None, + skills: Optional[List[_models.ToolboxSkill]] = None, + policies: Optional[_models.ToolboxPolicies] = None, + **kwargs: Any + ) -> _models.ToolboxVersionObject: + """Create a new version of a toolbox. + + Creates a new toolbox version, provisioning the toolbox itself if it does not already exist. + + :param name: The name of the toolbox. If the toolbox does not exist, it will be created. + Required. + :type name: str + :keyword tools: The list of tools to include in this version. Required. + :paramtype tools: list[~azure.ai.projects.models.ToolboxTool] + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword description: A human-readable description of the toolbox. Default value is None. + :paramtype description: str + :keyword metadata: Arbitrary key-value metadata to associate with the toolbox. Default value is + None. + :paramtype metadata: dict[str, str] + :keyword skills: The list of skill sources to include in this version. A skill reference + specifies a skill name and optionally a version. If version is omitted, the skill's default + version is used. Default value is None. + :paramtype skills: list[~azure.ai.projects.models.ToolboxSkill] + :keyword policies: Policy configuration for this toolbox version. Default value is None. + :paramtype policies: ~azure.ai.projects.models.ToolboxPolicies + :return: ToolboxVersionObject. The ToolboxVersionObject is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.ToolboxVersionObject + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_version( + self, name: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ToolboxVersionObject: + """Create a new version of a toolbox. + + Creates a new toolbox version, provisioning the toolbox itself if it does not already exist. + + :param name: The name of the toolbox. If the toolbox does not exist, it will be created. + Required. + :type name: str + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ToolboxVersionObject. The ToolboxVersionObject is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.ToolboxVersionObject + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def create_version( + self, name: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ToolboxVersionObject: + """Create a new version of a toolbox. + + Creates a new toolbox version, provisioning the toolbox itself if it does not already exist. + + :param name: The name of the toolbox. If the toolbox does not exist, it will be created. + Required. + :type name: str + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ToolboxVersionObject. The ToolboxVersionObject is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.ToolboxVersionObject + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create_version( + self, + name: str, + body: Union[JSON, IO[bytes]] = _Unset, + *, + tools: List[_models.ToolboxTool] = _Unset, + description: Optional[str] = None, + metadata: Optional[dict[str, str]] = None, + skills: Optional[List[_models.ToolboxSkill]] = None, + policies: Optional[_models.ToolboxPolicies] = None, + **kwargs: Any + ) -> _models.ToolboxVersionObject: + """Create a new version of a toolbox. + + Creates a new toolbox version, provisioning the toolbox itself if it does not already exist. + + :param name: The name of the toolbox. If the toolbox does not exist, it will be created. + Required. + :type name: str + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :keyword tools: The list of tools to include in this version. Required. + :paramtype tools: list[~azure.ai.projects.models.ToolboxTool] + :keyword description: A human-readable description of the toolbox. Default value is None. + :paramtype description: str + :keyword metadata: Arbitrary key-value metadata to associate with the toolbox. Default value is + None. + :paramtype metadata: dict[str, str] + :keyword skills: The list of skill sources to include in this version. A skill reference + specifies a skill name and optionally a version. If version is omitted, the skill's default + version is used. Default value is None. + :paramtype skills: list[~azure.ai.projects.models.ToolboxSkill] + :keyword policies: Policy configuration for this toolbox version. Default value is None. + :paramtype policies: ~azure.ai.projects.models.ToolboxPolicies + :return: ToolboxVersionObject. The ToolboxVersionObject is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.ToolboxVersionObject + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ToolboxVersionObject] = kwargs.pop("cls", None) + + if body is _Unset: + if tools is _Unset: + raise TypeError("missing required argument: tools") + body = { + "description": description, + "metadata": metadata, + "policies": policies, + "skills": skills, + "tools": tools, + } + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/json" + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_toolboxes_create_version_request( + name=name, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ToolboxVersionObject, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace_async + async def get(self, name: str, **kwargs: Any) -> _models.ToolboxObject: + """Retrieve a toolbox. + + Retrieves the specified toolbox and its current configuration. + + :param name: The name of the toolbox to retrieve. Required. + :type name: str + :return: ToolboxObject. The ToolboxObject is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.ToolboxObject + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ToolboxObject] = kwargs.pop("cls", None) + + _request = build_toolboxes_get_request( + name=name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ToolboxObject, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list( + self, + *, + limit: Optional[int] = None, + order: Optional[Union[str, _models.PageOrder]] = None, + before: Optional[str] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.ToolboxObject"]: + """List toolboxes. + + Returns the toolboxes available in the current project. + + :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and + 100, and the + default is 20. Default value is None. + :paramtype limit: int + :keyword order: Sort order by the ``created_at`` timestamp of the objects. ``asc`` for + ascending order and``desc`` + for descending order. Known values are: "asc" and "desc". Default value is None. + :paramtype order: str or ~azure.ai.projects.models.PageOrder + :keyword before: A cursor for use in pagination. ``before`` is an object ID that defines your + place in the list. + For instance, if you make a list request and receive 100 objects, ending with obj_foo, your + subsequent call can include before=obj_foo in order to fetch the previous page of the list. + Default value is None. + :paramtype before: str + :return: An iterator like instance of ToolboxObject + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.models.ToolboxObject] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ToolboxObject]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(_continuation_token=None): + + _request = build_toolboxes_list_request( + limit=limit, + order=order, + after=_continuation_token, + before=before, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ToolboxObject], + deserialized.get("data", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("last_id") or None, AsyncList(list_of_elem) + + async def get_next(_continuation_token=None): + _request = prepare_request(_continuation_token) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace + def list_versions( + self, + name: str, + *, + limit: Optional[int] = None, + order: Optional[Union[str, _models.PageOrder]] = None, + before: Optional[str] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.ToolboxVersionObject"]: + """List toolbox versions. + + Returns the available versions for the specified toolbox. + + :param name: The name of the toolbox to list versions for. Required. + :type name: str + :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and + 100, and the + default is 20. Default value is None. + :paramtype limit: int + :keyword order: Sort order by the ``created_at`` timestamp of the objects. ``asc`` for + ascending order and``desc`` + for descending order. Known values are: "asc" and "desc". Default value is None. + :paramtype order: str or ~azure.ai.projects.models.PageOrder + :keyword before: A cursor for use in pagination. ``before`` is an object ID that defines your + place in the list. + For instance, if you make a list request and receive 100 objects, ending with obj_foo, your + subsequent call can include before=obj_foo in order to fetch the previous page of the list. + Default value is None. + :paramtype before: str + :return: An iterator like instance of ToolboxVersionObject + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.models.ToolboxVersionObject] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ToolboxVersionObject]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(_continuation_token=None): + + _request = build_toolboxes_list_versions_request( + name=name, + limit=limit, + order=order, + after=_continuation_token, + before=before, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + return _request + + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ToolboxVersionObject], + deserialized.get("data", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("last_id") or None, AsyncList(list_of_elem) + + async def get_next(_continuation_token=None): + _request = prepare_request(_continuation_token) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + return pipeline_response + + return AsyncItemPaged(get_next, extract_data) + + @distributed_trace_async + async def get_version(self, name: str, version: str, **kwargs: Any) -> _models.ToolboxVersionObject: + """Retrieve a specific version of a toolbox. + + Retrieves the specified version of a toolbox by name and version identifier. + + :param name: The name of the toolbox. Required. + :type name: str + :param version: The version identifier to retrieve. Required. + :type version: str + :return: ToolboxVersionObject. The ToolboxVersionObject is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.ToolboxVersionObject + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - _request = build_datasets_create_or_update_request( + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ToolboxVersionObject] = kwargs.pop("cls", None) + + _request = build_toolboxes_get_version_request( name=name, version=version, - content_type=content_type, api_version=self._config.api_version, - content=_content, headers=_headers, params=_params, ) @@ -3694,19 +5952,23 @@ async def create_or_update( response = pipeline_response.http_response - if response.status_code not in [200, 201]: + if response.status_code not in [200]: if _stream: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.DatasetVersion, response.json()) + deserialized = _deserialize(_models.ToolboxVersionObject, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -3714,111 +5976,83 @@ async def create_or_update( return deserialized # type: ignore @overload - async def pending_upload( - self, - name: str, - version: str, - pending_upload_request: _models.PendingUploadRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.PendingUploadResponse: - """Start a pending upload. + async def update( + self, name: str, *, default_version: str, content_type: str = "application/json", **kwargs: Any + ) -> _models.ToolboxObject: + """Update a toolbox to point to a specific version. - Initiates a new pending upload or retrieves an existing one for the specified dataset version. + Updates the toolbox's default version pointer to the specified version. - :param name: The name of the resource. Required. + :param name: The name of the toolbox to update. Required. :type name: str - :param version: The specific version id of the DatasetVersion to operate on. Required. - :type version: str - :param pending_upload_request: The pending upload request parameters. Required. - :type pending_upload_request: ~azure.ai.projects.models.PendingUploadRequest + :keyword default_version: The version identifier that the toolbox should point to. When set, + the toolbox's default version will resolve to this version instead of the latest. Required. + :paramtype default_version: str :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: PendingUploadResponse. The PendingUploadResponse is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.PendingUploadResponse + :return: ToolboxObject. The ToolboxObject is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.ToolboxObject :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def pending_upload( - self, - name: str, - version: str, - pending_upload_request: JSON, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.PendingUploadResponse: - """Start a pending upload. + async def update( + self, name: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ToolboxObject: + """Update a toolbox to point to a specific version. - Initiates a new pending upload or retrieves an existing one for the specified dataset version. + Updates the toolbox's default version pointer to the specified version. - :param name: The name of the resource. Required. + :param name: The name of the toolbox to update. Required. :type name: str - :param version: The specific version id of the DatasetVersion to operate on. Required. - :type version: str - :param pending_upload_request: The pending upload request parameters. Required. - :type pending_upload_request: JSON + :param body: Required. + :type body: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: PendingUploadResponse. The PendingUploadResponse is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.PendingUploadResponse + :return: ToolboxObject. The ToolboxObject is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.ToolboxObject :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def pending_upload( - self, - name: str, - version: str, - pending_upload_request: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.PendingUploadResponse: - """Start a pending upload. + async def update( + self, name: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ToolboxObject: + """Update a toolbox to point to a specific version. - Initiates a new pending upload or retrieves an existing one for the specified dataset version. + Updates the toolbox's default version pointer to the specified version. - :param name: The name of the resource. Required. + :param name: The name of the toolbox to update. Required. :type name: str - :param version: The specific version id of the DatasetVersion to operate on. Required. - :type version: str - :param pending_upload_request: The pending upload request parameters. Required. - :type pending_upload_request: IO[bytes] + :param body: Required. + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: PendingUploadResponse. The PendingUploadResponse is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.PendingUploadResponse + :return: ToolboxObject. The ToolboxObject is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.ToolboxObject :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def pending_upload( - self, - name: str, - version: str, - pending_upload_request: Union[_models.PendingUploadRequest, JSON, IO[bytes]], - **kwargs: Any - ) -> _models.PendingUploadResponse: - """Start a pending upload. + async def update( + self, name: str, body: Union[JSON, IO[bytes]] = _Unset, *, default_version: str = _Unset, **kwargs: Any + ) -> _models.ToolboxObject: + """Update a toolbox to point to a specific version. - Initiates a new pending upload or retrieves an existing one for the specified dataset version. + Updates the toolbox's default version pointer to the specified version. - :param name: The name of the resource. Required. + :param name: The name of the toolbox to update. Required. :type name: str - :param version: The specific version id of the DatasetVersion to operate on. Required. - :type version: str - :param pending_upload_request: The pending upload request parameters. Is one of the following - types: PendingUploadRequest, JSON, IO[bytes] Required. - :type pending_upload_request: ~azure.ai.projects.models.PendingUploadRequest or JSON or - IO[bytes] - :return: PendingUploadResponse. The PendingUploadResponse is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.PendingUploadResponse + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :keyword default_version: The version identifier that the toolbox should point to. When set, + the toolbox's default version will resolve to this version instead of the latest. Required. + :paramtype default_version: str + :return: ToolboxObject. The ToolboxObject is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.ToolboxObject :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -3833,18 +6067,22 @@ async def pending_upload( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PendingUploadResponse] = kwargs.pop("cls", None) + cls: ClsType[_models.ToolboxObject] = kwargs.pop("cls", None) + if body is _Unset: + if default_version is _Unset: + raise TypeError("missing required argument: default_version") + body = {"default_version": default_version} + body = {k: v for k, v in body.items() if v is not None} content_type = content_type or "application/json" _content = None - if isinstance(pending_upload_request, (IOBase, bytes)): - _content = pending_upload_request + if isinstance(body, (IOBase, bytes)): + _content = body else: - _content = json.dumps(pending_upload_request, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_datasets_pending_upload_request( + _request = build_toolboxes_update_request( name=name, - version=version, content_type=content_type, api_version=self._config.api_version, content=_content, @@ -3871,112 +6109,32 @@ async def pending_upload( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - deserialized = _deserialize(_models.PendingUploadResponse, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace_async - async def get_credentials(self, name: str, version: str, **kwargs: Any) -> _models.DatasetCredential: - """Get dataset credentials. - - Retrieves the SAS credential to access the storage account associated with a dataset version. - - :param name: The name of the resource. Required. - :type name: str - :param version: The specific version id of the DatasetVersion to operate on. Required. - :type version: str - :return: DatasetCredential. The DatasetCredential is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.DatasetCredential - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.DatasetCredential] = kwargs.pop("cls", None) - - _request = build_datasets_get_credentials_request( - name=name, - version=version, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.DatasetCredential, response.json()) + deserialized = _deserialize(_models.ToolboxObject, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - -class DeploymentsOperations: # pylint: disable=docstring-missing-param - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.ai.projects.aio.AIProjectClient`'s - :attr:`deployments` attribute. - """ - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace_async - async def get(self, name: str, **kwargs: Any) -> _models.Deployment: - """Get a deployment. + async def delete(self, name: str, **kwargs: Any) -> None: + """Delete a toolbox. - Retrieves a deployed model. + Removes the specified toolbox along with all of its versions. - :param name: Name of the deployment. Required. + :param name: The name of the toolbox to delete. Required. :type name: str - :return: Deployment. The Deployment is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.Deployment + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -3990,9 +6148,9 @@ async def get(self, name: str, **kwargs: Any) -> _models.Deployment: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.Deployment] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_deployments_get_request( + _request = build_toolboxes_delete_request( name=name, api_version=self._config.api_version, headers=_headers, @@ -4003,69 +6161,38 @@ async def get(self, name: str, **kwargs: Any) -> _models.Deployment: } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) + _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200]: - if _stream: - try: - await response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - response_headers = {} - response_headers["x-ms-client-request-id"] = self._deserialize( - "str", response.headers.get("x-ms-client-request-id") - ) - - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - deserialized = _deserialize(_models.Deployment, response.json()) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore + return cls(pipeline_response, None, {}) # type: ignore - @distributed_trace - def list( - self, - *, - model_publisher: Optional[str] = None, - model_name: Optional[str] = None, - deployment_type: Optional[Union[str, _models.DeploymentType]] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.Deployment"]: - """List deployments. + @distributed_trace_async + async def delete_version(self, name: str, version: str, **kwargs: Any) -> None: + """Delete a specific version of a toolbox. - Returns the deployed models available in the current project, optionally filtered by publisher, - model name, or deployment type. + Removes the specified version of a toolbox. - :keyword model_publisher: Model publisher to filter models by. Default value is None. - :paramtype model_publisher: str - :keyword model_name: Model name (the publisher specific name) to filter models by. Default - value is None. - :paramtype model_name: str - :keyword deployment_type: Type of deployment to filter list by. "ModelDeployment" Default value - is None. - :paramtype deployment_type: str or ~azure.ai.projects.models.DeploymentType - :return: An iterator like instance of Deployment - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.models.Deployment] + :param name: The name of the toolbox. Required. + :type name: str + :param version: The version identifier to delete. Required. + :type version: str + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.Deployment]] = kwargs.pop("cls", None) - error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -4074,85 +6201,50 @@ def list( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - _request = build_deployments_list_request( - model_publisher=model_publisher, - model_name=model_name, - deployment_type=deployment_type, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + cls: ClsType[None] = kwargs.pop("cls", None) - return _request + _request = build_toolboxes_delete_version_request( + name=name, + version=version, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - async def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize( - List[_models.Deployment], - deserialized.get("value", []), - ) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - async def get_next(next_link=None): - _request = prepare_request(next_link) + response = pipeline_response.http_response - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - return pipeline_response + raise HttpResponseError(response=response, model=error) - return AsyncItemPaged(get_next, extract_data) + if cls: + return cls(pipeline_response, None, {}) # type: ignore -class IndexesOperations: # pylint: disable=docstring-missing-param +class BetaAgentInsightMonitorsOperations: # pylint: disable=docstring-missing-param """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.ai.projects.aio.AIProjectClient`'s - :attr:`indexes` attribute. + :attr:`agent_insight_monitors` attribute. """ def __init__(self, *args, **kwargs) -> None: @@ -4163,21 +6255,36 @@ def __init__(self, *args, **kwargs) -> None: self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list_versions(self, name: str, **kwargs: Any) -> AsyncItemPaged["_models.Index"]: - """List versions. - - List all versions of the given Index. + def list( + self, + *, + before: Optional[str] = None, + limit: Optional[int] = None, + order: Optional[Union[str, _models.PageOrder]] = None, + agent_name: Optional[str] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.AgentInsightMonitorListItem"]: + """List Agent Insights monitors, optionally filtered by agent name. - :param name: The name of the resource. Required. - :type name: str - :return: An iterator like instance of Index - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.models.Index] + :keyword before: A cursor that identifies the first item in the next page. Default value is + None. + :paramtype before: str + :keyword limit: The maximum number of items to return. Defaults to 20. Default value is None. + :paramtype limit: int + :keyword order: Sort order by creation time. Defaults to descending. Known values are: "asc" + and "desc". Default value is None. + :paramtype order: str or ~azure.ai.projects.models.PageOrder + :keyword agent_name: Filter monitors by agent name. Default value is None. + :paramtype agent_name: str + :return: An iterator like instance of AgentInsightMonitorListItem + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.models.AgentInsightMonitorListItem] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.Index]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.AgentInsightMonitorListItem]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -4187,59 +6294,36 @@ def list_versions(self, name: str, **kwargs: Any) -> AsyncItemPaged["_models.Ind } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - _request = build_indexes_list_versions_request( - name=name, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + def prepare_request(_continuation_token=None): + _request = build_beta_agent_insight_monitors_list_request( + after=_continuation_token, + before=before, + limit=limit, + order=order, + agent_name=agent_name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) return _request async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() list_of_elem = _deserialize( - List[_models.Index], - deserialized.get("value", []), + List[_models.AgentInsightMonitorListItem], + deserialized.get("data", []), ) if cls: list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + return deserialized.get("last_id") or None, AsyncList(list_of_elem) - async def get_next(next_link=None): - _request = prepare_request(next_link) + async def get_next(_continuation_token=None): + _request = prepare_request(_continuation_token) _stream = False pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access @@ -4249,27 +6333,77 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) return pipeline_response return AsyncItemPaged(get_next, extract_data) - @distributed_trace - def list(self, **kwargs: Any) -> AsyncItemPaged["_models.Index"]: - """List latest versions. + @overload + async def create( + self, monitor: _models.AgentInsightMonitorCreate, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.AgentInsightMonitor: + """Create an Agent Insights monitor for an agent. - List the latest version of each Index. + :param monitor: The monitor to create. Required. + :type monitor: ~azure.ai.projects.models.AgentInsightMonitorCreate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: AgentInsightMonitor. The AgentInsightMonitor is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.AgentInsightMonitor + :raises ~azure.core.exceptions.HttpResponseError: + """ - :return: An iterator like instance of Index - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.models.Index] + @overload + async def create( + self, monitor: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.AgentInsightMonitor: + """Create an Agent Insights monitor for an agent. + + :param monitor: The monitor to create. Required. + :type monitor: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: AgentInsightMonitor. The AgentInsightMonitor is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.AgentInsightMonitor :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.Index]] = kwargs.pop("cls", None) + @overload + async def create( + self, monitor: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.AgentInsightMonitor: + """Create an Agent Insights monitor for an agent. + :param monitor: The monitor to create. Required. + :type monitor: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: AgentInsightMonitor. The AgentInsightMonitor is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.AgentInsightMonitor + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def create( + self, monitor: Union[_models.AgentInsightMonitorCreate, JSON, IO[bytes]], **kwargs: Any + ) -> _models.AgentInsightMonitor: + """Create an Agent Insights monitor for an agent. + + :param monitor: The monitor to create. Is one of the following types: + AgentInsightMonitorCreate, JSON, IO[bytes] Required. + :type monitor: ~azure.ai.projects.models.AgentInsightMonitorCreate or JSON or IO[bytes] + :return: AgentInsightMonitor. The AgentInsightMonitor is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.AgentInsightMonitor + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -4278,86 +6412,73 @@ def list(self, **kwargs: Any) -> AsyncItemPaged["_models.Index"]: } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - _request = build_indexes_list_request( - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AgentInsightMonitor] = kwargs.pop("cls", None) - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + content_type = content_type or "application/json" + _content = None + if isinstance(monitor, (IOBase, bytes)): + _content = monitor + else: + _content = json.dumps(monitor, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - return _request + _request = build_beta_agent_insight_monitors_create_request( + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - async def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize( - List[_models.Index], - deserialized.get("value", []), - ) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, AsyncList(list_of_elem) + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - async def get_next(next_link=None): - _request = prepare_request(next_link) + response = pipeline_response.http_response - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + if response.status_code not in [201]: + if _stream: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, ) - response = pipeline_response.http_response + raise HttpResponseError(response=response, model=error) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - return pipeline_response + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.AgentInsightMonitor, response.json()) - return AsyncItemPaged(get_next, extract_data) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - @distributed_trace_async - async def get(self, name: str, version: str, **kwargs: Any) -> _models.Index: - """Get a version. + return deserialized # type: ignore - Get the specific version of the Index. The service returns 404 Not Found error if the Index - does not exist. + @distributed_trace_async + async def get(self, monitor_id: str, **kwargs: Any) -> _models.AgentInsightMonitor: + """Get an Agent Insights monitor. - :param name: The name of the resource. Required. - :type name: str - :param version: The specific version id of the Index to retrieve. Required. - :type version: str - :return: Index. The Index is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.Index + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :return: AgentInsightMonitor. The AgentInsightMonitor is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.AgentInsightMonitor :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -4371,11 +6492,10 @@ async def get(self, name: str, version: str, **kwargs: Any) -> _models.Index: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.Index] = kwargs.pop("cls", None) + cls: ClsType[_models.AgentInsightMonitor] = kwargs.pop("cls", None) - _request = build_indexes_get_request( - name=name, - version=version, + _request = build_beta_agent_insight_monitors_get_request( + monitor_id=monitor_id, api_version=self._config.api_version, headers=_headers, params=_params, @@ -4400,12 +6520,16 @@ async def get(self, name: str, version: str, **kwargs: Any) -> _models.Index: except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.Index, response.json()) + deserialized = _deserialize(_models.AgentInsightMonitor, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -4413,16 +6537,11 @@ async def get(self, name: str, version: str, **kwargs: Any) -> _models.Index: return deserialized # type: ignore @distributed_trace_async - async def delete(self, name: str, version: str, **kwargs: Any) -> None: - """Delete a version. + async def delete(self, monitor_id: str, **kwargs: Any) -> None: + """Delete an Agent Insights monitor and all of its runs, insights, and state. - Delete the specific version of the Index. The service returns 204 No Content if the Index was - deleted successfully or if the Index does not exist. - - :param name: The name of the resource. Required. - :type name: str - :param version: The version of the Index to delete. Required. - :type version: str + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str :return: None :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -4440,9 +6559,8 @@ async def delete(self, name: str, version: str, **kwargs: Any) -> None: cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_indexes_delete_request( - name=name, - version=version, + _request = build_beta_agent_insight_monitors_delete_request( + monitor_id=monitor_id, api_version=self._config.api_version, headers=_headers, params=_params, @@ -4461,106 +6579,87 @@ async def delete(self, name: str, version: str, **kwargs: Any) -> None: if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) if cls: return cls(pipeline_response, None, {}) # type: ignore @overload - async def create_or_update( + async def update( self, - name: str, - version: str, - index: _models.Index, + monitor_id: str, + monitor: _models.AgentInsightMonitorUpdate, *, content_type: str = "application/merge-patch+json", **kwargs: Any - ) -> _models.Index: - """Create or update a version. - - Create a new or update an existing Index with the given version id. + ) -> _models.AgentInsightMonitor: + """Update an Agent Insights monitor. - :param name: The name of the resource. Required. - :type name: str - :param version: The specific version id of the Index to create or update. Required. - :type version: str - :param index: The Index to create or update. Required. - :type index: ~azure.ai.projects.models.Index + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :param monitor: The monitor fields to update. Required. + :type monitor: ~azure.ai.projects.models.AgentInsightMonitorUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/merge-patch+json". :paramtype content_type: str - :return: Index. The Index is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.Index + :return: AgentInsightMonitor. The AgentInsightMonitor is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.AgentInsightMonitor :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def create_or_update( - self, name: str, version: str, index: JSON, *, content_type: str = "application/merge-patch+json", **kwargs: Any - ) -> _models.Index: - """Create or update a version. - - Create a new or update an existing Index with the given version id. - - :param name: The name of the resource. Required. - :type name: str - :param version: The specific version id of the Index to create or update. Required. - :type version: str - :param index: The Index to create or update. Required. - :type index: JSON + async def update( + self, monitor_id: str, monitor: JSON, *, content_type: str = "application/merge-patch+json", **kwargs: Any + ) -> _models.AgentInsightMonitor: + """Update an Agent Insights monitor. + + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :param monitor: The monitor fields to update. Required. + :type monitor: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/merge-patch+json". :paramtype content_type: str - :return: Index. The Index is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.Index + :return: AgentInsightMonitor. The AgentInsightMonitor is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.AgentInsightMonitor :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def create_or_update( - self, - name: str, - version: str, - index: IO[bytes], - *, - content_type: str = "application/merge-patch+json", - **kwargs: Any - ) -> _models.Index: - """Create or update a version. - - Create a new or update an existing Index with the given version id. - - :param name: The name of the resource. Required. - :type name: str - :param version: The specific version id of the Index to create or update. Required. - :type version: str - :param index: The Index to create or update. Required. - :type index: IO[bytes] + async def update( + self, monitor_id: str, monitor: IO[bytes], *, content_type: str = "application/merge-patch+json", **kwargs: Any + ) -> _models.AgentInsightMonitor: + """Update an Agent Insights monitor. + + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :param monitor: The monitor fields to update. Required. + :type monitor: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/merge-patch+json". - :paramtype content_type: str - :return: Index. The Index is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.Index - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace_async - async def create_or_update( - self, name: str, version: str, index: Union[_models.Index, JSON, IO[bytes]], **kwargs: Any - ) -> _models.Index: - """Create or update a version. - - Create a new or update an existing Index with the given version id. - - :param name: The name of the resource. Required. - :type name: str - :param version: The specific version id of the Index to create or update. Required. - :type version: str - :param index: The Index to create or update. Is one of the following types: Index, JSON, - IO[bytes] Required. - :type index: ~azure.ai.projects.models.Index or JSON or IO[bytes] - :return: Index. The Index is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.Index + :paramtype content_type: str + :return: AgentInsightMonitor. The AgentInsightMonitor is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.AgentInsightMonitor + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def update( + self, monitor_id: str, monitor: Union[_models.AgentInsightMonitorUpdate, JSON, IO[bytes]], **kwargs: Any + ) -> _models.AgentInsightMonitor: + """Update an Agent Insights monitor. + + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :param monitor: The monitor fields to update. Is one of the following types: + AgentInsightMonitorUpdate, JSON, IO[bytes] Required. + :type monitor: ~azure.ai.projects.models.AgentInsightMonitorUpdate or JSON or IO[bytes] + :return: AgentInsightMonitor. The AgentInsightMonitor is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.AgentInsightMonitor :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -4575,18 +6674,17 @@ async def create_or_update( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Index] = kwargs.pop("cls", None) + cls: ClsType[_models.AgentInsightMonitor] = kwargs.pop("cls", None) content_type = content_type or "application/merge-patch+json" _content = None - if isinstance(index, (IOBase, bytes)): - _content = index + if isinstance(monitor, (IOBase, bytes)): + _content = monitor else: - _content = json.dumps(index, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = json.dumps(monitor, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_indexes_create_or_update_request( - name=name, - version=version, + _request = build_beta_agent_insight_monitors_update_request( + monitor_id=monitor_id, content_type=content_type, api_version=self._config.api_version, content=_content, @@ -4606,163 +6704,396 @@ async def create_or_update( response = pipeline_response.http_response - if response.status_code not in [200, 201]: + if response.status_code not in [200]: if _stream: try: await response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.Index, response.json()) + deserialized = _deserialize(_models.AgentInsightMonitor, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore + @distributed_trace_async + async def reset(self, monitor_id: str, **kwargs: Any) -> None: + """Reset an Agent Insights monitor's overview, checkpoint, and active insight state. -class ToolboxesOperations: # pylint: disable=docstring-missing-param - """ - .. warning:: - **DO NOT** instantiate this class directly. + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - Instead, you should access the following operations through - :class:`~azure.ai.projects.aio.AIProjectClient`'s - :attr:`toolboxes` attribute. - """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_beta_agent_insight_monitors_reset_request( + monitor_id=monitor_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + async def _create_run_initial( + self, monitor_id: str, run: Union[_models.AgentInsightRunCreate, JSON, IO[bytes]], **kwargs: Any + ) -> AsyncIterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[AsyncIterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(run, (IOBase, bytes)): + _content = run + else: + _content = json.dumps(run, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_beta_agent_insight_monitors_create_run_request( + monitor_id=monitor_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [201]: + try: + await response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["Operation-Location"] = self._deserialize("str", response.headers.get("Operation-Location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @overload - async def create_version( + async def begin_create_run( self, - name: str, + monitor_id: str, + run: _models.AgentInsightRunCreate, *, - tools: List[_models.ToolboxTool], content_type: str = "application/json", - description: Optional[str] = None, - metadata: Optional[dict[str, str]] = None, - skills: Optional[List[_models.ToolboxSkill]] = None, - policies: Optional[_models.ToolboxPolicies] = None, **kwargs: Any - ) -> _models.ToolboxVersionObject: - """Create a new version of a toolbox. + ) -> AsyncLROPoller[_models.AgentInsightRunResult]: + """Start an Agent Insights run for a monitor. - Creates a new toolbox version, provisioning the toolbox itself if it does not already exist. + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :param run: Run inputs. Send an empty object to use the default 168-hour lookback window. + Required. + :type run: ~azure.ai.projects.models.AgentInsightRunCreate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns AgentInsightRunResult. The + AgentInsightRunResult is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.ai.projects.models.AgentInsightRunResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ - :param name: The name of the toolbox. If the toolbox does not exist, it will be created. + @overload + async def begin_create_run( + self, monitor_id: str, run: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.AgentInsightRunResult]: + """Start an Agent Insights run for a monitor. + + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :param run: Run inputs. Send an empty object to use the default 168-hour lookback window. Required. - :type name: str - :keyword tools: The list of tools to include in this version. Required. - :paramtype tools: list[~azure.ai.projects.models.ToolboxTool] + :type run: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword description: A human-readable description of the toolbox. Default value is None. - :paramtype description: str - :keyword metadata: Arbitrary key-value metadata to associate with the toolbox. Default value is + :return: An instance of AsyncLROPoller that returns AgentInsightRunResult. The + AgentInsightRunResult is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.ai.projects.models.AgentInsightRunResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + async def begin_create_run( + self, monitor_id: str, run: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> AsyncLROPoller[_models.AgentInsightRunResult]: + """Start an Agent Insights run for a monitor. + + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :param run: Run inputs. Send an empty object to use the default 168-hour lookback window. + Required. + :type run: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of AsyncLROPoller that returns AgentInsightRunResult. The + AgentInsightRunResult is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.ai.projects.models.AgentInsightRunResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace_async + async def begin_create_run( + self, monitor_id: str, run: Union[_models.AgentInsightRunCreate, JSON, IO[bytes]], **kwargs: Any + ) -> AsyncLROPoller[_models.AgentInsightRunResult]: + """Start an Agent Insights run for a monitor. + + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :param run: Run inputs. Send an empty object to use the default 168-hour lookback window. Is + one of the following types: AgentInsightRunCreate, JSON, IO[bytes] Required. + :type run: ~azure.ai.projects.models.AgentInsightRunCreate or JSON or IO[bytes] + :return: An instance of AsyncLROPoller that returns AgentInsightRunResult. The + AgentInsightRunResult is compatible with MutableMapping + :rtype: ~azure.core.polling.AsyncLROPoller[~azure.ai.projects.models.AgentInsightRunResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AgentInsightRunResult] = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = await self._create_run_initial( + monitor_id=monitor_id, + run=run, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Operation-Location"] = self._deserialize( + "str", response.headers.get("Operation-Location") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = _deserialize(_models.AgentInsightRunResult, response.json().get("result", {})) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncLROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if cont_token: + return AsyncLROPoller[_models.AgentInsightRunResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return AsyncLROPoller[_models.AgentInsightRunResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list_runs( + self, + monitor_id: str, + *, + before: Optional[str] = None, + limit: Optional[int] = None, + order: Optional[Union[str, _models.PageOrder]] = None, + status: Optional[Union[str, _models.JobStatus]] = None, + trigger: Optional[Union[str, _models.AgentInsightRunTrigger]] = None, + **kwargs: Any + ) -> AsyncItemPaged["_models.AgentInsightRun"]: + """List Agent Insights runs for a monitor. + + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :keyword before: A cursor that identifies the first item in the next page. Default value is None. - :paramtype metadata: dict[str, str] - :keyword skills: The list of skill sources to include in this version. A skill reference - specifies a skill name and optionally a version. If version is omitted, the skill's default - version is used. Default value is None. - :paramtype skills: list[~azure.ai.projects.models.ToolboxSkill] - :keyword policies: Policy configuration for this toolbox version. Default value is None. - :paramtype policies: ~azure.ai.projects.models.ToolboxPolicies - :return: ToolboxVersionObject. The ToolboxVersionObject is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.ToolboxVersionObject + :paramtype before: str + :keyword limit: The maximum number of items to return. Defaults to 20. Default value is None. + :paramtype limit: int + :keyword order: Sort order by creation time. Defaults to descending. Known values are: "asc" + and "desc". Default value is None. + :paramtype order: str or ~azure.ai.projects.models.PageOrder + :keyword status: Filter runs by status. Known values are: "queued", "in_progress", "succeeded", + "failed", and "cancelled". Default value is None. + :paramtype status: str or ~azure.ai.projects.models.JobStatus + :keyword trigger: Filter runs by trigger. Known values are: "on_demand" and "scheduled". + Default value is None. + :paramtype trigger: str or ~azure.ai.projects.models.AgentInsightRunTrigger + :return: An iterator like instance of AgentInsightRun + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.models.AgentInsightRun] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.AgentInsightRun]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - @overload - async def create_version( - self, name: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.ToolboxVersionObject: - """Create a new version of a toolbox. + def prepare_request(_continuation_token=None): - Creates a new toolbox version, provisioning the toolbox itself if it does not already exist. + _request = build_beta_agent_insight_monitors_list_runs_request( + monitor_id=monitor_id, + after=_continuation_token, + before=before, + limit=limit, + order=order, + status=status, + trigger=trigger, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + return _request - :param name: The name of the toolbox. If the toolbox does not exist, it will be created. - Required. - :type name: str - :param body: Required. - :type body: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: ToolboxVersionObject. The ToolboxVersionObject is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.ToolboxVersionObject - :raises ~azure.core.exceptions.HttpResponseError: - """ + async def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.AgentInsightRun], + deserialized.get("data", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("last_id") or None, AsyncList(list_of_elem) - @overload - async def create_version( - self, name: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.ToolboxVersionObject: - """Create a new version of a toolbox. + async def get_next(_continuation_token=None): + _request = prepare_request(_continuation_token) - Creates a new toolbox version, provisioning the toolbox itself if it does not already exist. + _stream = False + pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - :param name: The name of the toolbox. If the toolbox does not exist, it will be created. - Required. - :type name: str - :param body: Required. - :type body: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: ToolboxVersionObject. The ToolboxVersionObject is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.ToolboxVersionObject - :raises ~azure.core.exceptions.HttpResponseError: - """ + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) - @distributed_trace_async - async def create_version( - self, - name: str, - body: Union[JSON, IO[bytes]] = _Unset, - *, - tools: List[_models.ToolboxTool] = _Unset, - description: Optional[str] = None, - metadata: Optional[dict[str, str]] = None, - skills: Optional[List[_models.ToolboxSkill]] = None, - policies: Optional[_models.ToolboxPolicies] = None, - **kwargs: Any - ) -> _models.ToolboxVersionObject: - """Create a new version of a toolbox. + return pipeline_response - Creates a new toolbox version, provisioning the toolbox itself if it does not already exist. + return AsyncItemPaged(get_next, extract_data) - :param name: The name of the toolbox. If the toolbox does not exist, it will be created. - Required. - :type name: str - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] - :keyword tools: The list of tools to include in this version. Required. - :paramtype tools: list[~azure.ai.projects.models.ToolboxTool] - :keyword description: A human-readable description of the toolbox. Default value is None. - :paramtype description: str - :keyword metadata: Arbitrary key-value metadata to associate with the toolbox. Default value is - None. - :paramtype metadata: dict[str, str] - :keyword skills: The list of skill sources to include in this version. A skill reference - specifies a skill name and optionally a version. If version is omitted, the skill's default - version is used. Default value is None. - :paramtype skills: list[~azure.ai.projects.models.ToolboxSkill] - :keyword policies: Policy configuration for this toolbox version. Default value is None. - :paramtype policies: ~azure.ai.projects.models.ToolboxPolicies - :return: ToolboxVersionObject. The ToolboxVersionObject is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.ToolboxVersionObject + @distributed_trace_async + async def get_run(self, monitor_id: str, run_id: str, **kwargs: Any) -> _models.AgentInsightRun: + """Get an Agent Insights run. + + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :param run_id: The identifier of the run. Required. + :type run_id: str + :return: AgentInsightRun. The AgentInsightRun is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.AgentInsightRun :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -4773,35 +7104,15 @@ async def create_version( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ToolboxVersionObject] = kwargs.pop("cls", None) - - if body is _Unset: - if tools is _Unset: - raise TypeError("missing required argument: tools") - body = { - "description": description, - "metadata": metadata, - "policies": policies, - "skills": skills, - "tools": tools, - } - body = {k: v for k, v in body.items() if v is not None} - content_type = content_type or "application/json" - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + cls: ClsType[_models.AgentInsightRun] = kwargs.pop("cls", None) - _request = build_toolboxes_create_version_request( - name=name, - content_type=content_type, + _request = build_beta_agent_insight_monitors_get_run_request( + monitor_id=monitor_id, + run_id=run_id, api_version=self._config.api_version, - content=_content, headers=_headers, params=_params, ) @@ -4834,7 +7145,7 @@ async def create_version( if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.ToolboxVersionObject, response.json()) + deserialized = _deserialize(_models.AgentInsightRun, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -4842,15 +7153,15 @@ async def create_version( return deserialized # type: ignore @distributed_trace_async - async def get(self, name: str, **kwargs: Any) -> _models.ToolboxObject: - """Retrieve a toolbox. - - Retrieves the specified toolbox and its current configuration. + async def cancel_run(self, monitor_id: str, run_id: str, **kwargs: Any) -> _models.AgentInsightRun: + """Cancel an Agent Insights run. - :param name: The name of the toolbox to retrieve. Required. - :type name: str - :return: ToolboxObject. The ToolboxObject is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.ToolboxObject + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :param run_id: The identifier of the run. Required. + :type run_id: str + :return: AgentInsightRun. The AgentInsightRun is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.AgentInsightRun :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -4864,10 +7175,11 @@ async def get(self, name: str, **kwargs: Any) -> _models.ToolboxObject: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.ToolboxObject] = kwargs.pop("cls", None) + cls: ClsType[_models.AgentInsightRun] = kwargs.pop("cls", None) - _request = build_toolboxes_get_request( - name=name, + _request = build_beta_agent_insight_monitors_cancel_run_request( + monitor_id=monitor_id, + run_id=run_id, api_version=self._config.api_version, headers=_headers, params=_params, @@ -4901,7 +7213,7 @@ async def get(self, name: str, **kwargs: Any) -> _models.ToolboxObject: if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.ToolboxObject, response.json()) + deserialized = _deserialize(_models.AgentInsightRun, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -4909,135 +7221,50 @@ async def get(self, name: str, **kwargs: Any) -> _models.ToolboxObject: return deserialized # type: ignore @distributed_trace - def list( - self, - *, - limit: Optional[int] = None, - order: Optional[Union[str, _models.PageOrder]] = None, - before: Optional[str] = None, - **kwargs: Any - ) -> AsyncItemPaged["_models.ToolboxObject"]: - """List toolboxes. - - Returns the toolboxes available in the current project. - - :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and - 100, and the - default is 20. Default value is None. - :paramtype limit: int - :keyword order: Sort order by the ``created_at`` timestamp of the objects. ``asc`` for - ascending order and``desc`` - for descending order. Known values are: "asc" and "desc". Default value is None. - :paramtype order: str or ~azure.ai.projects.models.PageOrder - :keyword before: A cursor for use in pagination. ``before`` is an object ID that defines your - place in the list. - For instance, if you make a list request and receive 100 objects, ending with obj_foo, your - subsequent call can include before=obj_foo in order to fetch the previous page of the list. - Default value is None. - :paramtype before: str - :return: An iterator like instance of ToolboxObject - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.models.ToolboxObject] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.ToolboxObject]] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(_continuation_token=None): - - _request = build_toolboxes_list_request( - limit=limit, - order=order, - after=_continuation_token, - before=before, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - return _request - - async def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize( - List[_models.ToolboxObject], - deserialized.get("data", []), - ) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("last_id") or None, AsyncList(list_of_elem) - - async def get_next(_continuation_token=None): - _request = prepare_request(_continuation_token) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ApiErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error) - - return pipeline_response - - return AsyncItemPaged(get_next, extract_data) - - @distributed_trace - def list_versions( + def list_insights( self, - name: str, + monitor_id: str, *, + before: Optional[str] = None, limit: Optional[int] = None, order: Optional[Union[str, _models.PageOrder]] = None, - before: Optional[str] = None, + category: Optional[str] = None, + severity: Optional[Union[str, _models.AgentInsightSeverity]] = None, + status: Optional[Union[str, _models.AgentInsightStatus]] = None, + include_details: Optional[bool] = None, **kwargs: Any - ) -> AsyncItemPaged["_models.ToolboxVersionObject"]: - """List toolbox versions. + ) -> AsyncItemPaged["_models.AgentInsight"]: + """List current insights for an Agent Insights monitor. - Returns the available versions for the specified toolbox. - - :param name: The name of the toolbox to list versions for. Required. - :type name: str - :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and - 100, and the - default is 20. Default value is None. + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :keyword before: A cursor that identifies the first item in the next page. Default value is + None. + :paramtype before: str + :keyword limit: The maximum number of items to return. Defaults to 20. Default value is None. :paramtype limit: int - :keyword order: Sort order by the ``created_at`` timestamp of the objects. ``asc`` for - ascending order and``desc`` - for descending order. Known values are: "asc" and "desc". Default value is None. + :keyword order: Sort order by creation time. Defaults to descending. Known values are: "asc" + and "desc". Default value is None. :paramtype order: str or ~azure.ai.projects.models.PageOrder - :keyword before: A cursor for use in pagination. ``before`` is an object ID that defines your - place in the list. - For instance, if you make a list request and receive 100 objects, ending with obj_foo, your - subsequent call can include before=obj_foo in order to fetch the previous page of the list. + :keyword category: Filter insights by category. Default value is None. + :paramtype category: str + :keyword severity: Filter insights by severity. Known values are: "high", "medium", and "low". Default value is None. - :paramtype before: str - :return: An iterator like instance of ToolboxVersionObject - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.models.ToolboxVersionObject] + :paramtype severity: str or ~azure.ai.projects.models.AgentInsightSeverity + :keyword status: Filter insights by lifecycle status. Known values are: "active", "resolved", + and "ignored". Default value is None. + :paramtype status: str or ~azure.ai.projects.models.AgentInsightStatus + :keyword include_details: Whether to include expanded insight details such as evidence and run + links in the response. Defaults to false. Default value is None. + :paramtype include_details: bool + :return: An iterator like instance of AgentInsight + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.ai.projects.models.AgentInsight] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.ToolboxVersionObject]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.AgentInsight]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -5049,12 +7276,16 @@ def list_versions( def prepare_request(_continuation_token=None): - _request = build_toolboxes_list_versions_request( - name=name, - limit=limit, - order=order, + _request = build_beta_agent_insight_monitors_list_insights_request( + monitor_id=monitor_id, after=_continuation_token, before=before, + limit=limit, + order=order, + category=category, + severity=severity, + status=status, + include_details=include_details, api_version=self._config.api_version, headers=_headers, params=_params, @@ -5068,7 +7299,7 @@ def prepare_request(_continuation_token=None): async def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() list_of_elem = _deserialize( - List[_models.ToolboxVersionObject], + List[_models.AgentInsight], deserialized.get("data", []), ) if cls: @@ -5097,17 +7328,20 @@ async def get_next(_continuation_token=None): return AsyncItemPaged(get_next, extract_data) @distributed_trace_async - async def get_version(self, name: str, version: str, **kwargs: Any) -> _models.ToolboxVersionObject: - """Retrieve a specific version of a toolbox. - - Retrieves the specified version of a toolbox by name and version identifier. - - :param name: The name of the toolbox. Required. - :type name: str - :param version: The version identifier to retrieve. Required. - :type version: str - :return: ToolboxVersionObject. The ToolboxVersionObject is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.ToolboxVersionObject + async def get_insight( + self, monitor_id: str, insight_id: str, *, include_details: Optional[bool] = None, **kwargs: Any + ) -> _models.AgentInsight: + """Get a full insight for an Agent Insights monitor. + + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :param insight_id: The identifier of the insight. Required. + :type insight_id: str + :keyword include_details: Whether to include expanded insight details such as evidence and run + links in the response. Defaults to false. Default value is None. + :paramtype include_details: bool + :return: AgentInsight. The AgentInsight is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.AgentInsight :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -5121,11 +7355,12 @@ async def get_version(self, name: str, version: str, **kwargs: Any) -> _models.T _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.ToolboxVersionObject] = kwargs.pop("cls", None) + cls: ClsType[_models.AgentInsight] = kwargs.pop("cls", None) - _request = build_toolboxes_get_version_request( - name=name, - version=version, + _request = build_beta_agent_insight_monitors_get_insight_request( + monitor_id=monitor_id, + insight_id=insight_id, + include_details=include_details, api_version=self._config.api_version, headers=_headers, params=_params, @@ -5159,7 +7394,7 @@ async def get_version(self, name: str, version: str, **kwargs: Any) -> _models.T if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.ToolboxVersionObject, response.json()) + deserialized = _deserialize(_models.AgentInsight, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -5167,83 +7402,102 @@ async def get_version(self, name: str, version: str, **kwargs: Any) -> _models.T return deserialized # type: ignore @overload - async def update( - self, name: str, *, default_version: str, content_type: str = "application/json", **kwargs: Any - ) -> _models.ToolboxObject: - """Update a toolbox to point to a specific version. - - Updates the toolbox's default version pointer to the specified version. + async def update_insight( + self, + monitor_id: str, + insight_id: str, + update: _models.AgentInsightUpdate, + *, + content_type: str = "application/merge-patch+json", + **kwargs: Any + ) -> _models.AgentInsight: + """Update the lifecycle status of an insight. - :param name: The name of the toolbox to update. Required. - :type name: str - :keyword default_version: The version identifier that the toolbox should point to. When set, - the toolbox's default version will resolve to this version instead of the latest. Required. - :paramtype default_version: str + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :param insight_id: The identifier of the insight. Required. + :type insight_id: str + :param update: The insight fields to update. Required. + :type update: ~azure.ai.projects.models.AgentInsightUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". + Default value is "application/merge-patch+json". :paramtype content_type: str - :return: ToolboxObject. The ToolboxObject is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.ToolboxObject + :return: AgentInsight. The AgentInsight is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.AgentInsight :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def update( - self, name: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.ToolboxObject: - """Update a toolbox to point to a specific version. - - Updates the toolbox's default version pointer to the specified version. + async def update_insight( + self, + monitor_id: str, + insight_id: str, + update: JSON, + *, + content_type: str = "application/merge-patch+json", + **kwargs: Any + ) -> _models.AgentInsight: + """Update the lifecycle status of an insight. - :param name: The name of the toolbox to update. Required. - :type name: str - :param body: Required. - :type body: JSON + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :param insight_id: The identifier of the insight. Required. + :type insight_id: str + :param update: The insight fields to update. Required. + :type update: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". + Default value is "application/merge-patch+json". :paramtype content_type: str - :return: ToolboxObject. The ToolboxObject is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.ToolboxObject + :return: AgentInsight. The AgentInsight is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.AgentInsight :raises ~azure.core.exceptions.HttpResponseError: """ @overload - async def update( - self, name: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.ToolboxObject: - """Update a toolbox to point to a specific version. - - Updates the toolbox's default version pointer to the specified version. + async def update_insight( + self, + monitor_id: str, + insight_id: str, + update: IO[bytes], + *, + content_type: str = "application/merge-patch+json", + **kwargs: Any + ) -> _models.AgentInsight: + """Update the lifecycle status of an insight. - :param name: The name of the toolbox to update. Required. - :type name: str - :param body: Required. - :type body: IO[bytes] + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :param insight_id: The identifier of the insight. Required. + :type insight_id: str + :param update: The insight fields to update. Required. + :type update: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". + Default value is "application/merge-patch+json". :paramtype content_type: str - :return: ToolboxObject. The ToolboxObject is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.ToolboxObject + :return: AgentInsight. The AgentInsight is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.AgentInsight :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace_async - async def update( - self, name: str, body: Union[JSON, IO[bytes]] = _Unset, *, default_version: str = _Unset, **kwargs: Any - ) -> _models.ToolboxObject: - """Update a toolbox to point to a specific version. - - Updates the toolbox's default version pointer to the specified version. + async def update_insight( + self, + monitor_id: str, + insight_id: str, + update: Union[_models.AgentInsightUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.AgentInsight: + """Update the lifecycle status of an insight. - :param name: The name of the toolbox to update. Required. - :type name: str - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] - :keyword default_version: The version identifier that the toolbox should point to. When set, - the toolbox's default version will resolve to this version instead of the latest. Required. - :paramtype default_version: str - :return: ToolboxObject. The ToolboxObject is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.ToolboxObject + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :param insight_id: The identifier of the insight. Required. + :type insight_id: str + :param update: The insight fields to update. Is one of the following types: AgentInsightUpdate, + JSON, IO[bytes] Required. + :type update: ~azure.ai.projects.models.AgentInsightUpdate or JSON or IO[bytes] + :return: AgentInsight. The AgentInsight is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.AgentInsight :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -5258,22 +7512,18 @@ async def update( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ToolboxObject] = kwargs.pop("cls", None) + cls: ClsType[_models.AgentInsight] = kwargs.pop("cls", None) - if body is _Unset: - if default_version is _Unset: - raise TypeError("missing required argument: default_version") - body = {"default_version": default_version} - body = {k: v for k, v in body.items() if v is not None} - content_type = content_type or "application/json" + content_type = content_type or "application/merge-patch+json" _content = None - if isinstance(body, (IOBase, bytes)): - _content = body + if isinstance(update, (IOBase, bytes)): + _content = update else: - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = json.dumps(update, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_toolboxes_update_request( - name=name, + _request = build_beta_agent_insight_monitors_update_insight_request( + monitor_id=monitor_id, + insight_id=insight_id, content_type=content_type, api_version=self._config.api_version, content=_content, @@ -5309,124 +7559,13 @@ async def update( if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.ToolboxObject, response.json()) + deserialized = _deserialize(_models.AgentInsight, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace_async - async def delete(self, name: str, **kwargs: Any) -> None: - """Delete a toolbox. - - Removes the specified toolbox along with all of its versions. - - :param name: The name of the toolbox to delete. Required. - :type name: str - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_toolboxes_delete_request( - name=name, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ApiErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace_async - async def delete_version(self, name: str, version: str, **kwargs: Any) -> None: - """Delete a specific version of a toolbox. - - Removes the specified version of a toolbox. - - :param name: The name of the toolbox. Required. - :type name: str - :param version: The version identifier to delete. Required. - :type version: str - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_toolboxes_delete_version_request( - name=name, - version=version, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = False - pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ApiErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - class BetaEvaluationTaxonomiesOperations: # pylint: disable=docstring-missing-param """ @@ -10942,6 +13081,7 @@ async def create_or_update( enabled: Optional[bool] = None, triggers: Optional[dict[str, _models.RoutineTrigger]] = None, action: Optional[_models.RoutineAction] = None, + authorization: Optional[_models.RoutineAuthorization] = None, **kwargs: Any ) -> _models.Routine: """Create or update a routine. @@ -10962,6 +13102,9 @@ async def create_or_update( :paramtype triggers: dict[str, ~azure.ai.projects.models.RoutineTrigger] :keyword action: The action executed when the routine fires. Default value is None. :paramtype action: ~azure.ai.projects.models.RoutineAction + :keyword authorization: Optional authorization configuration for dispatching a newly created + routine. Ignored when updating an existing routine. Default value is None. + :paramtype authorization: ~azure.ai.projects.models.RoutineAuthorization :return: Routine. The Routine is compatible with MutableMapping :rtype: ~azure.ai.projects.models.Routine :raises ~azure.core.exceptions.HttpResponseError: @@ -11017,6 +13160,7 @@ async def create_or_update( enabled: Optional[bool] = None, triggers: Optional[dict[str, _models.RoutineTrigger]] = None, action: Optional[_models.RoutineAction] = None, + authorization: Optional[_models.RoutineAuthorization] = None, **kwargs: Any ) -> _models.Routine: """Create or update a routine. @@ -11036,6 +13180,9 @@ async def create_or_update( :paramtype triggers: dict[str, ~azure.ai.projects.models.RoutineTrigger] :keyword action: The action executed when the routine fires. Default value is None. :paramtype action: ~azure.ai.projects.models.RoutineAction + :keyword authorization: Optional authorization configuration for dispatching a newly created + routine. Ignored when updating an existing routine. Default value is None. + :paramtype authorization: ~azure.ai.projects.models.RoutineAuthorization :return: Routine. The Routine is compatible with MutableMapping :rtype: ~azure.ai.projects.models.Routine :raises ~azure.core.exceptions.HttpResponseError: @@ -11055,7 +13202,13 @@ async def create_or_update( cls: ClsType[_models.Routine] = kwargs.pop("cls", None) if body is _Unset: - body = {"action": action, "description": description, "enabled": enabled, "triggers": triggers} + body = { + "action": action, + "authorization": authorization, + "description": description, + "enabled": enabled, + "triggers": triggers, + } body = {k: v for k, v in body.items() if v is not None} content_type = content_type or "application/json" _content = None diff --git a/sdk/ai/azure-ai-projects/azure/ai/projects/aio/operations/_patch.py b/sdk/ai/azure-ai-projects/azure/ai/projects/aio/operations/_patch.py index 5bb74cf4fe6d..6462512ea065 100644 --- a/sdk/ai/azure-ai-projects/azure/ai/projects/aio/operations/_patch.py +++ b/sdk/ai/azure-ai-projects/azure/ai/projects/aio/operations/_patch.py @@ -10,6 +10,7 @@ from typing import Any, List from ._patch_agents_async import AgentsOperations, BetaAgentsOperations +from ._patch_agent_insights_async import BetaAgentInsightMonitorsOperations from ._patch_datasets_async import BetaDatasetsOperations, DatasetsOperations from ._patch_evaluators_async import BetaEvaluatorsOperations from ._patch_evaluation_rules_async import EvaluationRulesOperations @@ -41,6 +42,8 @@ class BetaOperations(GeneratedBetaOperations): agents: BetaAgentsOperations """:class:`~azure.ai.projects.aio.operations.BetaAgentsOperations` operations""" + agent_insight_monitors: BetaAgentInsightMonitorsOperations + """:class:`~azure.ai.projects.aio.operations.BetaAgentInsightMonitorsOperations` operations""" evaluation_taxonomies: BetaEvaluationTaxonomiesOperations """:class:`~azure.ai.projects.aio.operations.BetaEvaluationTaxonomiesOperations` operations""" evaluators: BetaEvaluatorsOperations @@ -74,6 +77,10 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: self.models = BetaModelsOperations(self._client, self._config, self._serialize, self._deserialize) # Replace with patched class that returns AsyncDatasetGenerationLROPoller self.datasets = BetaDatasetsOperations(self._client, self._config, self._serialize, self._deserialize) + # Replace with patched class that returns AsyncAgentInsightRunLROPoller + self.agent_insight_monitors = BetaAgentInsightMonitorsOperations( + self._client, self._config, self._serialize, self._deserialize + ) for property_name, foundry_features_value in _BETA_OPERATION_FEATURE_HEADERS.items(): setattr( @@ -85,6 +92,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: __all__: List[str] = [ "AgentsOperations", + "BetaAgentInsightMonitorsOperations", "BetaAgentsOperations", "BetaDatasetsOperations", "BetaEvaluationTaxonomiesOperations", diff --git a/sdk/ai/azure-ai-projects/azure/ai/projects/aio/operations/_patch_agent_insights_async.py b/sdk/ai/azure-ai-projects/azure/ai/projects/aio/operations/_patch_agent_insights_async.py new file mode 100644 index 000000000000..72eff617498e --- /dev/null +++ b/sdk/ai/azure-ai-projects/azure/ai/projects/aio/operations/_patch_agent_insights_async.py @@ -0,0 +1,138 @@ +# pylint: disable=line-too-long,useless-suppression +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" + +from typing import Any, IO, Optional, Union, cast, overload +from collections.abc import MutableMapping + +from azure.core.polling import AsyncNoPolling, AsyncPollingMethod +from azure.core.polling.async_base_polling import AsyncLROBasePolling +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.core.utils import case_insensitive_dict + +from ._operations import ( + BetaAgentInsightMonitorsOperations as BetaAgentInsightMonitorsOperationsGenerated, +) +from ... import models as _models +from ..._utils.model_base import _deserialize +from ...models import AsyncAgentInsightRunLROPoller + +JSON = MutableMapping[str, Any] + + +class BetaAgentInsightMonitorsOperations(BetaAgentInsightMonitorsOperationsGenerated): + """Custom async operations for beta Agent Insights monitors.""" + + @overload + async def begin_create_run( + self, + monitor_id: str, + run: _models.AgentInsightRunCreate, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> AsyncAgentInsightRunLROPoller: ... + + @overload + async def begin_create_run( + self, + monitor_id: str, + run: JSON, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> AsyncAgentInsightRunLROPoller: ... + + @overload + async def begin_create_run( + self, + monitor_id: str, + run: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> AsyncAgentInsightRunLROPoller: ... + + @distributed_trace_async + async def begin_create_run( + self, + monitor_id: str, + run: Union[_models.AgentInsightRunCreate, JSON, IO[bytes]], + **kwargs: Any, + ) -> AsyncAgentInsightRunLROPoller: + """Start an Agent Insights run for a monitor. + + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :param run: Run inputs. Send an empty object to use the default 168-hour lookback window. Is + one of the following types: AgentInsightRunCreate, JSON, IO[bytes] Required. + :type run: ~azure.ai.projects.models.AgentInsightRunCreate or JSON or IO[bytes] + :return: A poller that returns AgentInsightRunResult and exposes the run ID in ``details``. + :rtype: ~azure.ai.projects.models.AsyncAgentInsightRunLROPoller + :raises ~azure.core.exceptions.HttpResponseError: + """ + headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", headers.pop("Content-Type", None)) + cls = kwargs.pop("cls", None) + polling: Union[bool, AsyncPollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + continuation_token: Optional[str] = kwargs.pop("continuation_token", None) + raw_result = None + if continuation_token is None: + raw_result = await self._create_run_initial( + monitor_id=monitor_id, + run=run, + content_type=content_type, + cls=lambda x, y, z: x, + headers=headers, + params=params, + **kwargs, + ) + await raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Operation-Location"] = self._deserialize( + "str", response.headers.get("Operation-Location") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = _deserialize(_models.AgentInsightRunResult, response.json().get("result", {})) + if cls: + return cls(pipeline_response, deserialized, response_headers) + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + + if polling is True: + polling_method: AsyncPollingMethod = cast( + AsyncPollingMethod, + AsyncLROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs), + ) + elif polling is False: + polling_method = cast(AsyncPollingMethod, AsyncNoPolling()) + else: + polling_method = polling + if continuation_token: + return AsyncAgentInsightRunLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=continuation_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + assert raw_result is not None + return AsyncAgentInsightRunLROPoller( # type: ignore + self._client, raw_result, get_long_running_output, polling_method + ) diff --git a/sdk/ai/azure-ai-projects/azure/ai/projects/models/__init__.py b/sdk/ai/azure-ai-projects/azure/ai/projects/models/__init__.py index 1261682860e9..2a0def115184 100644 --- a/sdk/ai/azure-ai-projects/azure/ai/projects/models/__init__.py +++ b/sdk/ai/azure-ai-projects/azure/ai/projects/models/__init__.py @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -33,6 +34,26 @@ AgentEndpointConfig, AgentEvaluatorGenerationJobSource, AgentIdentity, + AgentInsight, + AgentInsightDetails, + AgentInsightEstimatedCost, + AgentInsightHighlightedTrace, + AgentInsightLinkedTrace, + AgentInsightMonitor, + AgentInsightMonitorCreate, + AgentInsightMonitorListItem, + AgentInsightMonitorUpdate, + AgentInsightProposedFix, + AgentInsightProposedFixChange, + AgentInsightRecommendedAction, + AgentInsightRun, + AgentInsightRunCreate, + AgentInsightRunResult, + AgentInsightSuspension, + AgentInsightTokenUsage, + AgentInsightUpdate, + AgentInsightsOverview, + AgentInsightsOverviewOverride, AgentObjectVersions, AgentOptimizationCandidate, AgentOptimizationDatasetCriterion, @@ -241,6 +262,9 @@ MemoryStoreSearchResult, MemoryStoreUpdateCompletedResult, MemoryStoreUpdateResult, + Microsoft365PermissionScopes, + Microsoft365PublishDefaults, + Microsoft365PublishResult, MicrosoftFabricPreviewTool, ModelCredentialRequest, ModelDeployment, @@ -291,6 +315,7 @@ ResponsesProtocolConfiguration, Routine, RoutineAction, + RoutineAuthorization, RoutineDispatchPayload, RoutineRun, RoutineTrigger, @@ -301,11 +326,13 @@ ScheduleRoutineTrigger, ScheduleRun, ScheduleTask, + SessionConfiguration, SessionDirectoryEntry, SessionFileWriteResult, SessionLogEvent, SharepointGroundingToolParameters, SharepointPreviewTool, + ShellToolboxTool, SimpleQnADataGenerationJobOptions, SimulationSeedDataGenerationJobOptions, SkillDetails, @@ -350,6 +377,11 @@ ToolboxObject, ToolboxPolicies, ToolboxSearchPreviewToolboxTool, + ToolboxShellContainerAutoEnvironment, + ToolboxShellContainerReferenceEnvironment, + ToolboxShellEnvironment, + ToolboxShellNetworkPolicy, + ToolboxShellNetworkPolicyDisabled, ToolboxSkill, ToolboxSkillReference, ToolboxTool, @@ -365,6 +397,8 @@ VersionRefIndicator, VersionSelectionRule, VersionSelector, + WebIQPreviewTool, + WebIQPreviewToolboxTool, WebSearchApproximateLocation, WebSearchConfiguration, WebSearchPreviewTool, @@ -379,10 +413,17 @@ from ._enums import ( # type: ignore A2AProtocolVersion, + ActivityProtocolAccessBoundary, AgentBlueprintReferenceType, AgentEndpointAuthorizationSchemeType, AgentEndpointProtocol, AgentIdentityStatus, + AgentInsightOverviewSource, + AgentInsightPromptSurface, + AgentInsightProposedFixKind, + AgentInsightRunTrigger, + AgentInsightSeverity, + AgentInsightStatus, AgentKind, AgentObjectType, AgentOptimizationDatasetInputType, @@ -408,6 +449,7 @@ DatasetType, DayOfWeek, DeploymentType, + DigitalWorkerType, EvaluationLevel, EvaluationRuleActionType, EvaluationRuleEventType, @@ -437,10 +479,12 @@ MemoryStoreKind, MemoryStoreObjectType, MemoryStoreUpdateStatus, + Microsoft365PublishScope, OpenApiAuthType, OperationState, PageOrder, PendingUploadType, + PublishApprovalStatus, RankerVersionType, ReasoningEffort, ReasoningModeEnum, @@ -448,6 +492,7 @@ RiskCategory, RoutineActionType, RoutineAttemptSource, + RoutineDispatchIdentity, RoutineDispatchPayloadType, RoutineRunPhase, RoutineTriggerType, @@ -499,6 +544,26 @@ "AgentEndpointConfig", "AgentEvaluatorGenerationJobSource", "AgentIdentity", + "AgentInsight", + "AgentInsightDetails", + "AgentInsightEstimatedCost", + "AgentInsightHighlightedTrace", + "AgentInsightLinkedTrace", + "AgentInsightMonitor", + "AgentInsightMonitorCreate", + "AgentInsightMonitorListItem", + "AgentInsightMonitorUpdate", + "AgentInsightProposedFix", + "AgentInsightProposedFixChange", + "AgentInsightRecommendedAction", + "AgentInsightRun", + "AgentInsightRunCreate", + "AgentInsightRunResult", + "AgentInsightSuspension", + "AgentInsightTokenUsage", + "AgentInsightUpdate", + "AgentInsightsOverview", + "AgentInsightsOverviewOverride", "AgentObjectVersions", "AgentOptimizationCandidate", "AgentOptimizationDatasetCriterion", @@ -707,6 +772,9 @@ "MemoryStoreSearchResult", "MemoryStoreUpdateCompletedResult", "MemoryStoreUpdateResult", + "Microsoft365PermissionScopes", + "Microsoft365PublishDefaults", + "Microsoft365PublishResult", "MicrosoftFabricPreviewTool", "ModelCredentialRequest", "ModelDeployment", @@ -757,6 +825,7 @@ "ResponsesProtocolConfiguration", "Routine", "RoutineAction", + "RoutineAuthorization", "RoutineDispatchPayload", "RoutineRun", "RoutineTrigger", @@ -767,11 +836,13 @@ "ScheduleRoutineTrigger", "ScheduleRun", "ScheduleTask", + "SessionConfiguration", "SessionDirectoryEntry", "SessionFileWriteResult", "SessionLogEvent", "SharepointGroundingToolParameters", "SharepointPreviewTool", + "ShellToolboxTool", "SimpleQnADataGenerationJobOptions", "SimulationSeedDataGenerationJobOptions", "SkillDetails", @@ -816,6 +887,11 @@ "ToolboxObject", "ToolboxPolicies", "ToolboxSearchPreviewToolboxTool", + "ToolboxShellContainerAutoEnvironment", + "ToolboxShellContainerReferenceEnvironment", + "ToolboxShellEnvironment", + "ToolboxShellNetworkPolicy", + "ToolboxShellNetworkPolicyDisabled", "ToolboxSkill", "ToolboxSkillReference", "ToolboxTool", @@ -831,6 +907,8 @@ "VersionRefIndicator", "VersionSelectionRule", "VersionSelector", + "WebIQPreviewTool", + "WebIQPreviewToolboxTool", "WebSearchApproximateLocation", "WebSearchConfiguration", "WebSearchPreviewTool", @@ -842,10 +920,17 @@ "WorkIQPreviewToolboxTool", "WorkflowAgentDefinition", "A2AProtocolVersion", + "ActivityProtocolAccessBoundary", "AgentBlueprintReferenceType", "AgentEndpointAuthorizationSchemeType", "AgentEndpointProtocol", "AgentIdentityStatus", + "AgentInsightOverviewSource", + "AgentInsightPromptSurface", + "AgentInsightProposedFixKind", + "AgentInsightRunTrigger", + "AgentInsightSeverity", + "AgentInsightStatus", "AgentKind", "AgentObjectType", "AgentOptimizationDatasetInputType", @@ -871,6 +956,7 @@ "DatasetType", "DayOfWeek", "DeploymentType", + "DigitalWorkerType", "EvaluationLevel", "EvaluationRuleActionType", "EvaluationRuleEventType", @@ -900,10 +986,12 @@ "MemoryStoreKind", "MemoryStoreObjectType", "MemoryStoreUpdateStatus", + "Microsoft365PublishScope", "OpenApiAuthType", "OperationState", "PageOrder", "PendingUploadType", + "PublishApprovalStatus", "RankerVersionType", "ReasoningEffort", "ReasoningModeEnum", @@ -911,6 +999,7 @@ "RiskCategory", "RoutineActionType", "RoutineAttemptSource", + "RoutineDispatchIdentity", "RoutineDispatchPayloadType", "RoutineRunPhase", "RoutineTriggerType", diff --git a/sdk/ai/azure-ai-projects/azure/ai/projects/models/_enums.py b/sdk/ai/azure-ai-projects/azure/ai/projects/models/_enums.py index 8b3f138d31bb..d2e0105f2403 100644 --- a/sdk/ai/azure-ai-projects/azure/ai/projects/models/_enums.py +++ b/sdk/ai/azure-ai-projects/azure/ai/projects/models/_enums.py @@ -22,6 +22,8 @@ class _AgentDefinitionOptInKeys(str, Enum, metaclass=CaseInsensitiveEnumMeta): """DRAFT_AGENTS_V1_PREVIEW.""" VOICE_AGENTS_V1_PREVIEW = "VoiceAgents=V1Preview" """VOICE_AGENTS_V1_PREVIEW.""" + DIGITAL_WORKER_V1_PREVIEW = "DigitalWorker=V1Preview" + """DIGITAL_WORKER_V1_PREVIEW.""" class _FoundryFeaturesOptInKeys(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -35,6 +37,8 @@ class _FoundryFeaturesOptInKeys(str, Enum, metaclass=CaseInsensitiveEnumMeta): """RED_TEAMS_V1_PREVIEW.""" INSIGHTS_V1_PREVIEW = "Insights=V1Preview" """INSIGHTS_V1_PREVIEW.""" + AGENT_INSIGHTS_V1_PREVIEW = "AgentInsights=V1Preview" + """AGENT_INSIGHTS_V1_PREVIEW.""" MEMORY_STORES_V1_PREVIEW = "MemoryStores=V1Preview" """MEMORY_STORES_V1_PREVIEW.""" ROUTINES_V2_PREVIEW = "Routines=V2Preview" @@ -47,6 +51,8 @@ class _FoundryFeaturesOptInKeys(str, Enum, metaclass=CaseInsensitiveEnumMeta): """MODELS_V1_PREVIEW.""" AGENTS_OPTIMIZATION_V2_PREVIEW = "AgentsOptimization=V2Preview" """AGENTS_OPTIMIZATION_V2_PREVIEW.""" + MODEL_ROUTER_CONTROLS_V1_PREVIEW = "ModelRouterControls=V1Preview" + """MODEL_ROUTER_CONTROLS_V1_PREVIEW.""" class A2AProtocolVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -56,6 +62,47 @@ class A2AProtocolVersion(str, Enum, metaclass=CaseInsensitiveEnumMeta): """A2A protocol version 1.0.""" +class ActivityProtocolAccessBoundary(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """An access boundary for the activity protocol.""" + + READ1_ON1_DEVELOPERS = "read.1on1.developers" + """Allows read access to one-on-one developer conversations.""" + READ1_ON1_MANAGER = "read.1on1.manager" + """Allows read access to one-on-one manager conversations.""" + READ1_ON1_ALLOWLISTED = "read.1on1.allowlisted" + """Allows read access to allowlisted one-on-one conversations.""" + READ1_ON1_TENANT = "read.1on1.tenant" + """Allows read access to tenant-wide one-on-one conversations.""" + WRITE1_ON1_DEVELOPERS = "write.1on1.developers" + """Allows write access to one-on-one developer conversations.""" + WRITE1_ON1_MANAGER = "write.1on1.manager" + """Allows write access to one-on-one manager conversations.""" + WRITE1_ON1_ALLOWLISTED = "write.1on1.allowlisted" + """Allows write access to allowlisted one-on-one conversations.""" + WRITE1_ON1_TENANT = "write.1on1.tenant" + """Allows write access to tenant-wide one-on-one conversations.""" + READ_GROUP_DEVELOPERS = "read.group.developers" + """Allows read access to developer group conversations.""" + READ_GROUP_ALLOWLISTED = "read.group.allowlisted" + """Allows read access to allowlisted group conversations.""" + READ_GROUP_MANAGER_INVITED = "read.group.manager-invited" + """Allows read access to group conversations where a manager is invited.""" + READ_GROUP_MANAGER_PRESENT = "read.group.manager-present" + """Allows read access to group conversations where a manager is present.""" + READ_GROUP_TENANT = "read.group.tenant" + """Allows read access to tenant-wide group conversations.""" + WRITE_GROUP_DEVELOPERS = "write.group.developers" + """Allows write access to developer group conversations.""" + WRITE_GROUP_ALLOWLISTED = "write.group.allowlisted" + """Allows write access to allowlisted group conversations.""" + WRITE_GROUP_MANAGER_INVITED = "write.group.manager-invited" + """Allows write access to group conversations where a manager is invited.""" + WRITE_GROUP_MANAGER_PRESENT = "write.group.manager-present" + """Allows write access to group conversations where a manager is present.""" + WRITE_GROUP_TENANT = "write.group.tenant" + """Allows write access to tenant-wide group conversations.""" + + class AgentBlueprintReferenceType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Type of AgentBlueprintReferenceType.""" @@ -104,6 +151,66 @@ class AgentIdentityStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The agent identity is disabled and cannot be used to access resources.""" +class AgentInsightOverviewSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """Identifies where an Agent Insights overview came from.""" + + GENERATED = "generated" + """The overview was generated by Agent Insights.""" + USER_OVERRIDE = "user_override" + """The overview was provided by the user.""" + + +class AgentInsightPromptSurface(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The Prompt surface changed by a proposed fix.""" + + INSTRUCTIONS = "instructions" + """The Prompt instructions.""" + TOOL = "tool" + """A function tool definition.""" + + +class AgentInsightProposedFixKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The customer-renderable kind of an agent insight's proposed fix.""" + + PROSE = "prose" + """Text-only remediation guidance.""" + CODE_CHANGE = "code_change" + """A validated source-code change.""" + PROMPT_CHANGE = "prompt_change" + """A validated Prompt change.""" + + +class AgentInsightRunTrigger(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The trigger that started an agent insight run.""" + + ON_DEMAND = "on_demand" + """The run was started on demand by a user or client.""" + SCHEDULED = "scheduled" + """The run was started by scheduled insight generation.""" + + +class AgentInsightSeverity(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The severity of an agent insight.""" + + HIGH = "high" + """The insight has high severity.""" + MEDIUM = "medium" + """The insight has medium severity.""" + LOW = "low" + """The insight has low severity.""" + + +class AgentInsightStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The lifecycle status of an agent insight.""" + + ACTIVE = "active" + """The insight is active and should be reviewed.""" + RESOLVED = "resolved" + """The insight was resolved by the user.""" + IGNORED = "ignored" + """The insight was ignored by the user.""" + + class AgentKind(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Type of AgentKind.""" @@ -480,6 +587,13 @@ class DeploymentType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Model deployment.""" +class DigitalWorkerType(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The type of digital worker.""" + + M365 = "m365" + """A Microsoft 365 digital worker.""" + + class EvaluationLevel(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The level at which evaluation is performed.""" @@ -806,6 +920,17 @@ class MemoryStoreUpdateStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): """SUPERSEDED.""" +class Microsoft365PublishScope(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The publish scope for the generated Microsoft Teams app.""" + + PERSONAL = "Personal" + """Publish the app for the acting user only.""" + SHARED = "Shared" + """Publish the app to a shared scope within the organization.""" + TENANT = "Tenant" + """Publish the app tenant-wide.""" + + class OpenApiAuthType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Authentication type for OpenApi endpoint. Allowed types are: @@ -858,6 +983,24 @@ class PendingUploadType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Temporary blob reference.""" +class PublishApprovalStatus(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The Microsoft Agent Certification review status of the Microsoft 365 store title published for + an agent. + """ + + NOT_PUBLISHED = "not_published" + """The agent has never been published to the Microsoft 365 store, so there is nothing to review.""" + PENDING = "pending" + """The published title is awaiting a review decision.""" + APPROVED = "approved" + """The title passed review, as of this read.""" + REJECTED = "rejected" + """The title was rejected in review, as of this read.""" + NO_APPROVAL_NEEDED = "no_approval_needed" + """The agent is published at a scope that does not go through Microsoft Agent Certification. Only + tenant-scoped titles are reviewed.""" + + class RankerVersionType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Type of RankerVersionType.""" @@ -962,6 +1105,15 @@ class RoutineAttemptSource(str, Enum, metaclass=CaseInsensitiveEnumMeta): """A dispatch fired from a timer delivery.""" +class RoutineDispatchIdentity(str, Enum, metaclass=CaseInsensitiveEnumMeta): + """The supported identities for routine dispatch authorization.""" + + AGENT = "agent" + """Dispatches with the target agent identity and a foundation token.""" + CREATOR = "creator" + """An explicit customer opt-in to dispatch as the principal that created the routine.""" + + class RoutineDispatchPayloadType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The discriminator values supported for manual routine dispatch payloads.""" @@ -1181,8 +1333,6 @@ class ToolboxToolType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """AZURE_AI_SEARCH.""" OPENAPI = "openapi" """OPENAPI.""" - A2_A = "a2a" - """A2_A.""" A2A_PREVIEW = "a2a_preview" """A2A_PREVIEW.""" BROWSER_AUTOMATION_PREVIEW = "browser_automation_preview" @@ -1197,6 +1347,12 @@ class ToolboxToolType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """TOOLBOX_SEARCH.""" TOOLBOX_SEARCH_PREVIEW = "toolbox_search_preview" """TOOLBOX_SEARCH_PREVIEW.""" + A2_A = "a2a" + """A2_A.""" + SHELL = "shell" + """SHELL.""" + WEB_IQ_PREVIEW = "web_iq_preview" + """WEB_IQ_PREVIEW.""" class ToolChoiceParamType(str, Enum, metaclass=CaseInsensitiveEnumMeta): @@ -1296,6 +1452,8 @@ class ToolType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """FABRIC_IQ_PREVIEW.""" TOOLBOX_SEARCH_PREVIEW = "toolbox_search_preview" """TOOLBOX_SEARCH_PREVIEW.""" + WEB_IQ_PREVIEW = "web_iq_preview" + """WEB_IQ_PREVIEW.""" A2_A = "a2a" """A2_A.""" AZURE_AI_SEARCH = "azure_ai_search" diff --git a/sdk/ai/azure-ai-projects/azure/ai/projects/models/_models.py b/sdk/ai/azure-ai-projects/azure/ai/projects/models/_models.py index 1fbcd59d0c91..bd4176afd983 100644 --- a/sdk/ai/azure-ai-projects/azure/ai/projects/models/_models.py +++ b/sdk/ai/azure-ai-projects/azure/ai/projects/models/_models.py @@ -162,7 +162,7 @@ class Tool(_Model): # pylint: disable=docstring-keyword-should-match-keyword-on CustomToolParam, MicrosoftFabricPreviewTool, FabricIQPreviewTool, FileSearchTool, FunctionTool, ImageGenTool, LocalShellToolParam, MCPTool, MemorySearchPreviewTool, NamespaceToolParam, OpenApiTool, ProgrammaticToolCallingParam, SharepointPreviewTool, FunctionShellToolParam, - ToolSearchToolParam, WebSearchTool, WebSearchPreviewTool, WorkIQPreviewTool + ToolSearchToolParam, WebIQPreviewTool, WebSearchTool, WebSearchPreviewTool, WorkIQPreviewTool :ivar type: Required. Known values are: "function", "file_search", "computer", "computer_use_preview", "web_search", "mcp", "code_interpreter", "programmatic_tool_calling", @@ -170,8 +170,8 @@ class Tool(_Model): # pylint: disable=docstring-keyword-should-match-keyword-on "web_search_preview", "apply_patch", "a2a_preview", "bing_custom_search_preview", "browser_automation_preview", "fabric_dataagent_preview", "sharepoint_grounding_preview", "memory_search_preview", "work_iq_preview", "fabric_iq_preview", "toolbox_search_preview", - "a2a", "azure_ai_search", "azure_function", "bing_grounding", "capture_structured_outputs", and - "openapi". + "web_iq_preview", "a2a", "azure_ai_search", "azure_function", "bing_grounding", + "capture_structured_outputs", and "openapi". :vartype type: str or ~azure.ai.projects.models.ToolType """ @@ -183,8 +183,9 @@ class Tool(_Model): # pylint: disable=docstring-keyword-should-match-keyword-on \"namespace\", \"tool_search\", \"web_search_preview\", \"apply_patch\", \"a2a_preview\", \"bing_custom_search_preview\", \"browser_automation_preview\", \"fabric_dataagent_preview\", \"sharepoint_grounding_preview\", \"memory_search_preview\", \"work_iq_preview\", - \"fabric_iq_preview\", \"toolbox_search_preview\", \"a2a\", \"azure_ai_search\", - \"azure_function\", \"bing_grounding\", \"capture_structured_outputs\", and \"openapi\".""" + \"fabric_iq_preview\", \"toolbox_search_preview\", \"web_iq_preview\", \"a2a\", + \"azure_ai_search\", \"azure_function\", \"bing_grounding\", \"capture_structured_outputs\", + and \"openapi\".""" @overload def __init__( @@ -269,13 +270,13 @@ class ToolboxTool(_Model): # pylint: disable=docstring-keyword-should-match-key A2AToolboxTool, A2APreviewToolboxTool, AzureAISearchToolboxTool, BrowserAutomationPreviewToolboxTool, CodeInterpreterToolboxTool, FabricIQPreviewToolboxTool, FileSearchToolboxTool, MCPToolboxTool, OpenApiToolboxTool, ReminderPreviewToolboxTool, - ToolSearchToolboxTool, ToolboxSearchPreviewToolboxTool, WebSearchToolboxTool, - WorkIQPreviewToolboxTool + ShellToolboxTool, ToolSearchToolboxTool, ToolboxSearchPreviewToolboxTool, + WebIQPreviewToolboxTool, WebSearchToolboxTool, WorkIQPreviewToolboxTool :ivar type: The type of tool. Required. Known values are: "code_interpreter", "file_search", - "web_search", "mcp", "azure_ai_search", "openapi", "a2a", "a2a_preview", - "browser_automation_preview", "reminder_preview", "work_iq_preview", "fabric_iq_preview", - "toolbox_search", and "toolbox_search_preview". + "web_search", "mcp", "azure_ai_search", "openapi", "a2a_preview", "browser_automation_preview", + "reminder_preview", "work_iq_preview", "fabric_iq_preview", "toolbox_search", + "toolbox_search_preview", "a2a", "shell", and "web_iq_preview". :vartype type: str or ~azure.ai.projects.models.ToolboxToolType :ivar name: Optional user-defined name for this tool or configuration. :vartype name: str @@ -290,9 +291,10 @@ class ToolboxTool(_Model): # pylint: disable=docstring-keyword-should-match-key __mapping__: dict[str, _Model] = {} type: str = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) """The type of tool. Required. Known values are: \"code_interpreter\", \"file_search\", - \"web_search\", \"mcp\", \"azure_ai_search\", \"openapi\", \"a2a\", \"a2a_preview\", + \"web_search\", \"mcp\", \"azure_ai_search\", \"openapi\", \"a2a_preview\", \"browser_automation_preview\", \"reminder_preview\", \"work_iq_preview\", - \"fabric_iq_preview\", \"toolbox_search\", and \"toolbox_search_preview\".""" + \"fabric_iq_preview\", \"toolbox_search\", \"toolbox_search_preview\", \"a2a\", \"shell\", and + \"web_iq_preview\".""" name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Optional user-defined name for this tool or configuration.""" description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) @@ -547,10 +549,17 @@ class ActivityProtocolConfiguration(_Model): # pylint: disable=docstring-keywor :ivar enable_m365_public_endpoint: Whether to enable the M365 public endpoint for the activity protocol. :vartype enable_m365_public_endpoint: bool + :ivar access_boundaries: The access boundaries for the activity protocol. + :vartype access_boundaries: list[str or + ~azure.ai.projects.models.ActivityProtocolAccessBoundary] """ enable_m365_public_endpoint: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) """Whether to enable the M365 public endpoint for the activity protocol.""" + access_boundaries: Optional[list[Union[str, "_models.ActivityProtocolAccessBoundary"]]] = rest_field( + visibility=["read"] + ) + """The access boundaries for the activity protocol.""" @overload def __init__( @@ -983,6 +992,9 @@ class AgentDetails(_Model): # pylint: disable=docstring-keyword-should-match-ke :vartype versions: ~azure.ai.projects.models.AgentObjectVersions :ivar agent_endpoint: The endpoint configuration for the agent. :vartype agent_endpoint: ~azure.ai.projects.models.AgentEndpointConfig + :ivar digital_worker_type: (Preview) The type of digital worker (previously known as + ``autopilot``). If omitted, it is not a digital worker. "m365" + :vartype digital_worker_type: str or ~azure.ai.projects.models.DigitalWorkerType :ivar instance_identity: The instance identity of the agent. :vartype instance_identity: ~azure.ai.projects.models.AgentIdentity :ivar blueprint: The blueprint for the agent. @@ -1012,6 +1024,11 @@ class AgentDetails(_Model): # pylint: disable=docstring-keyword-should-match-ke visibility=["read", "create", "update", "delete", "query"] ) """The endpoint configuration for the agent.""" + digital_worker_type: Optional[Union[str, "_models.DigitalWorkerType"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """(Preview) The type of digital worker (previously known as ``autopilot``). If omitted, it is not + a digital worker. \"m365\"""" instance_identity: Optional["_models.AgentIdentity"] = rest_field(visibility=["read"]) """The instance identity of the agent.""" blueprint: Optional["_models.AgentIdentity"] = rest_field(visibility=["read"]) @@ -1029,6 +1046,7 @@ def __init__( name: str, versions: "_models.AgentObjectVersions", agent_endpoint: Optional["_models.AgentEndpointConfig"] = None, + digital_worker_type: Optional[Union[str, "_models.DigitalWorkerType"]] = None, agent_card: Optional["_models.AgentCard"] = None, ) -> None: ... @@ -1089,6 +1107,13 @@ class AgentEndpointConfig(_Model): # pylint: disable=docstring-keyword-should-m :ivar authorization_schemes: The authorization schemes supported by the agent endpoint. :vartype authorization_schemes: list[~azure.ai.projects.models.AgentEndpointAuthorizationScheme] + :ivar publish_approval_status: The Microsoft Agent Certification review status of the Microsoft + 365 store title published for this agent. Server-populated and best-effort: it is absent when + the status could not be determined, and an absent value must not be interpreted as the agent + not being published. No value is terminal, because publishing a new version of an agent reuses + the same store title and sends it back through review. Known values are: "not_published", + "pending", "approved", "rejected", and "no_approval_needed". + :vartype publish_approval_status: str or ~azure.ai.projects.models.PublishApprovalStatus """ version_selector: Optional["_models.VersionSelector"] = rest_field( @@ -1104,6 +1129,13 @@ class AgentEndpointConfig(_Model): # pylint: disable=docstring-keyword-should-m visibility=["read", "create", "update", "delete", "query"] ) """The authorization schemes supported by the agent endpoint.""" + publish_approval_status: Optional[Union[str, "_models.PublishApprovalStatus"]] = rest_field(visibility=["read"]) + """The Microsoft Agent Certification review status of the Microsoft 365 store title published for + this agent. Server-populated and best-effort: it is absent when the status could not be + determined, and an absent value must not be interpreted as the agent not being published. No + value is terminal, because publishing a new version of an agent reuses the same store title and + sends it back through review. Known values are: \"not_published\", \"pending\", \"approved\", + \"rejected\", and \"no_approval_needed\".""" @overload def __init__( @@ -1137,16 +1169,947 @@ class EvaluatorGenerationJobSource(_Model): # pylint: disable=docstring-keyword :vartype type: str or ~azure.ai.projects.models.EvaluatorGenerationJobSourceType """ - __mapping__: dict[str, _Model] = {} - type: str = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) - """The type of source. Required. Known values are: \"prompt\", \"agent\", \"traces\", and - \"dataset\".""" + __mapping__: dict[str, _Model] = {} + type: str = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) + """The type of source. Required. Known values are: \"prompt\", \"agent\", \"traces\", and + \"dataset\".""" + + @overload + def __init__( + self, + *, + type: str, + ) -> 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 AgentEvaluatorGenerationJobSource( + EvaluatorGenerationJobSource, discriminator="agent" +): # pylint: disable=docstring-keyword-should-match-keyword-only + """Agent source for evaluator generation jobs — references an agent to fetch instructions and + metadata from. + + :ivar description: Optional description of what this source represents — helps the pipeline + interpret its content (e.g., 'Company refund policy document' or 'Describes the agent's core + capabilities'). + :vartype description: str + :ivar type: The source type for this source, which is Agent. Required. Agent source — + references an agent to fetch instructions and metadata from. + :vartype type: str or ~azure.ai.projects.models.AGENT + :ivar agent_name: The agent name to fetch instructions from. Required. + :vartype agent_name: str + :ivar agent_version: The agent version. If not specified, the latest version is used. + :vartype agent_version: str + """ + + description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Optional description of what this source represents — helps the pipeline interpret its content + (e.g., 'Company refund policy document' or 'Describes the agent's core capabilities').""" + type: Literal[EvaluatorGenerationJobSourceType.AGENT] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """The source type for this source, which is Agent. Required. Agent source — references an agent + to fetch instructions and metadata from.""" + agent_name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The agent name to fetch instructions from. Required.""" + agent_version: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The agent version. If not specified, the latest version is used.""" + + @overload + def __init__( + self, + *, + agent_name: str, + description: Optional[str] = None, + agent_version: Optional[str] = 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) + self.type = EvaluatorGenerationJobSourceType.AGENT # type: ignore + + +class BaseCredentials(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """A base class for connection credentials. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + EntraIDCredentials, AgenticIdentityPreviewCredentials, ApiKeyCredentials, CustomCredential, + NoAuthenticationCredentials, SASCredentials + + :ivar type: The type of credential used by the connection. Required. Known values are: + "ApiKey", "AAD", "SAS", "CustomKeys", "None", and "AgenticIdentityToken_Preview". + :vartype type: str or ~azure.ai.projects.models.CredentialType + """ + + __mapping__: dict[str, _Model] = {} + type: str = rest_discriminator(name="type", visibility=["read"]) + """The type of credential used by the connection. Required. Known values are: \"ApiKey\", \"AAD\", + \"SAS\", \"CustomKeys\", \"None\", and \"AgenticIdentityToken_Preview\".""" + + @overload + def __init__( + self, + *, + type: str, + ) -> 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 AgenticIdentityPreviewCredentials(BaseCredentials, discriminator="AgenticIdentityToken_Preview"): + """Agentic identity credential definition. + + :ivar type: The credential type. Required. Agentic identity credential. + :vartype type: str or ~azure.ai.projects.models.AGENTIC_IDENTITY_PREVIEW + """ + + type: Literal[CredentialType.AGENTIC_IDENTITY_PREVIEW] = rest_discriminator(name="type", visibility=["read"]) # type: ignore + """The credential type. Required. Agentic identity credential.""" + + @overload + def __init__( + self, + ) -> 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) + self.type = CredentialType.AGENTIC_IDENTITY_PREVIEW # type: ignore + + +class AgentIdentity(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """AgentIdentity. + + :ivar principal_id: The principal ID of the agent instance. Required. + :vartype principal_id: str + :ivar client_id: The client ID of the agent instance. Also referred to as the instance ID. + Required. + :vartype client_id: str + :ivar status: The status of the agent identity. Present for both the agent instance identity + and the agent blueprint. Known values are: "active" and "disabled". + :vartype status: str or ~azure.ai.projects.models.AgentIdentityStatus + """ + + principal_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The principal ID of the agent instance. Required.""" + client_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The client ID of the agent instance. Also referred to as the instance ID. Required.""" + status: Optional[Union[str, "_models.AgentIdentityStatus"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The status of the agent identity. Present for both the agent instance identity and the agent + blueprint. Known values are: \"active\" and \"disabled\".""" + + @overload + def __init__( + self, + *, + principal_id: str, + client_id: str, + status: Optional[Union[str, "_models.AgentIdentityStatus"]] = 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 AgentInsight(_Model): + """A persisted issue discovered from an agent's traces. + + :ivar id: The insight identifier. Required. + :vartype id: str + :ivar monitor_id: The Agent Insights monitor this insight belongs to. Required. + :vartype monitor_id: str + :ivar agent_name: The agent this insight belongs to. Required. + :vartype agent_name: str + :ivar agent_version: The latest immutable agent version associated with this insight. Required. + :vartype agent_version: str + :ivar title: A short title for the issue. Required. + :vartype title: str + :ivar severity: The severity of the issue. Required. Known values are: "high", "medium", and + "low". + :vartype severity: str or ~azure.ai.projects.models.AgentInsightSeverity + :ivar category: An open, service-generated category label for the issue. Clients must accept + previously unseen values. Required. + :vartype category: str + :ivar status: The lifecycle status of the insight. Required. Known values are: "active", + "resolved", and "ignored". + :vartype status: str or ~azure.ai.projects.models.AgentInsightStatus + :ivar trace_count: The number of traces that provide evidence for this insight. Required. + :vartype trace_count: int + :ivar created_at: The time when this insight was created. Required. + :vartype created_at: ~datetime.datetime + :ivar updated_at: The time when this insight was last updated. Required. + :vartype updated_at: ~datetime.datetime + :ivar description: The root-cause diagnosis for the issue. Required. + :vartype description: str + :ivar details: Additional insight details. Omitted unless details are requested. + :vartype details: ~azure.ai.projects.models.AgentInsightDetails + """ + + id: str = rest_field(visibility=["read"]) + """The insight identifier. Required.""" + monitor_id: str = rest_field(visibility=["read"]) + """The Agent Insights monitor this insight belongs to. Required.""" + agent_name: str = rest_field(visibility=["read"]) + """The agent this insight belongs to. Required.""" + agent_version: str = rest_field(visibility=["read"]) + """The latest immutable agent version associated with this insight. Required.""" + title: str = rest_field(visibility=["read"]) + """A short title for the issue. Required.""" + severity: Union[str, "_models.AgentInsightSeverity"] = rest_field(visibility=["read"]) + """The severity of the issue. Required. Known values are: \"high\", \"medium\", and \"low\".""" + category: str = rest_field(visibility=["read"]) + """An open, service-generated category label for the issue. Clients must accept previously unseen + values. Required.""" + status: Union[str, "_models.AgentInsightStatus"] = rest_field(visibility=["read"]) + """The lifecycle status of the insight. Required. Known values are: \"active\", \"resolved\", and + \"ignored\".""" + trace_count: int = rest_field(visibility=["read"]) + """The number of traces that provide evidence for this insight. Required.""" + created_at: datetime.datetime = rest_field(visibility=["read"], format="unix-timestamp") + """The time when this insight was created. Required.""" + updated_at: datetime.datetime = rest_field(visibility=["read"], format="unix-timestamp") + """The time when this insight was last updated. Required.""" + description: str = rest_field(visibility=["read"]) + """The root-cause diagnosis for the issue. Required.""" + details: Optional["_models.AgentInsightDetails"] = rest_field(visibility=["read"]) + """Additional insight details. Omitted unless details are requested.""" + + +class AgentInsightDetails(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Additional insight details. Omitted unless details are requested. + + :ivar highlighted_traces: Up to 5 highlighted traces that provide evidence for this insight. + Required. + :vartype highlighted_traces: list[~azure.ai.projects.models.AgentInsightHighlightedTrace] + :ivar linked_traces: Up to 200 most recent traces linked to this insight as supporting + evidence. Required. + :vartype linked_traces: list[~azure.ai.projects.models.AgentInsightLinkedTrace] + :ivar recommended_actions: The recommended remediation for this insight. Required. + :vartype recommended_actions: ~azure.ai.projects.models.AgentInsightRecommendedAction + """ + + highlighted_traces: list["_models.AgentInsightHighlightedTrace"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Up to 5 highlighted traces that provide evidence for this insight. Required.""" + linked_traces: list["_models.AgentInsightLinkedTrace"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Up to 200 most recent traces linked to this insight as supporting evidence. Required.""" + recommended_actions: "_models.AgentInsightRecommendedAction" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The recommended remediation for this insight. Required.""" + + @overload + def __init__( + self, + *, + highlighted_traces: list["_models.AgentInsightHighlightedTrace"], + linked_traces: list["_models.AgentInsightLinkedTrace"], + recommended_actions: "_models.AgentInsightRecommendedAction", + ) -> 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 AgentInsightEstimatedCost(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Estimated Agent Insights cost. + + :ivar amount: Estimated cost amount. Required. + :vartype amount: float + :ivar currency: Currency for the estimated cost amount. Agent Insights estimates are reported + in US dollars. Required. Default value is "USD". + :vartype currency: str + """ + + amount: float = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Estimated cost amount. Required.""" + currency: Literal["USD"] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Currency for the estimated cost amount. Agent Insights estimates are reported in US dollars. + Required. Default value is \"USD\".""" + + @overload + def __init__( + self, + *, + amount: float, + ) -> 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) + self.currency: Literal["USD"] = "USD" + + +class AgentInsightHighlightedTrace(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """A highlighted trace that provides evidence for an agent insight. + + :ivar trace_id: The trace identifier. Required. + :vartype trace_id: str + :ivar summary: A short summary of the trace. Required. + :vartype summary: str + :ivar duration_ms: The end-to-end duration of the trace in milliseconds. Required. + :vartype duration_ms: ~datetime.timedelta + :ivar total_tokens: Aggregate input and output tokens reported across all model inference calls + in this trace, including calls to different models. Intended for relative usage comparison, not + cost estimation. + :vartype total_tokens: int + :ivar timestamp: The time when the trace was recorded. Required. + :vartype timestamp: ~datetime.datetime + """ + + trace_id: str = rest_field(visibility=["read"]) + """The trace identifier. Required.""" + summary: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """A short summary of the trace. Required.""" + duration_ms: datetime.timedelta = rest_field( + visibility=["read", "create", "update", "delete", "query"], format="duration-milliseconds-int" + ) + """The end-to-end duration of the trace in milliseconds. Required.""" + total_tokens: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Aggregate input and output tokens reported across all model inference calls in this trace, + including calls to different models. Intended for relative usage comparison, not cost + estimation.""" + timestamp: datetime.datetime = rest_field( + visibility=["read", "create", "update", "delete", "query"], format="unix-timestamp" + ) + """The time when the trace was recorded. Required.""" + + @overload + def __init__( + self, + *, + summary: str, + duration_ms: datetime.timedelta, + timestamp: datetime.datetime, + total_tokens: Optional[int] = 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 AgentInsightLinkedTrace(_Model): + """A lightweight trace reference linked to an agent insight as supporting evidence. + + :ivar trace_id: The trace identifier. Required. + :vartype trace_id: str + :ivar timestamp: The time when the trace was recorded. Required. + :vartype timestamp: ~datetime.datetime + """ + + trace_id: str = rest_field(visibility=["read"]) + """The trace identifier. Required.""" + timestamp: datetime.datetime = rest_field(visibility=["read"], format="unix-timestamp") + """The time when the trace was recorded. Required.""" + + +class AgentInsightMonitor(_Model): + """A per-agent Agent Insights monitor that owns configuration, runs, and discovered insights. + + :ivar id: The monitor identifier. Required. + :vartype id: str + :ivar agent_name: The agent this monitor analyzes. There can be only one monitor per agent. + Required. + :vartype agent_name: str + :ivar enabled: Whether scheduled insight generation is armed for the monitor. Required. + :vartype enabled: bool + :ivar run_interval_hours: Interval between scheduled insight runs, in hours. Required. + :vartype run_interval_hours: float + :ivar model_deployment_name: The model deployment to use for analyzing traces. Accepts either + the deployment name alone or with the connection name as + '{connectionName}/modelDeploymentName'. Required. + :vartype model_deployment_name: str + :ivar next_scheduled_run_at: The next time a scheduled agent insight run will start. Omitted + when scheduled generation is disabled. + :vartype next_scheduled_run_at: ~datetime.datetime + :ivar estimated_cost: Estimated cost accumulated by Agent Insights for this monitor. + :vartype estimated_cost: ~azure.ai.projects.models.AgentInsightEstimatedCost + :ivar suspension: Why the system suspended scheduled generation. Null when the monitor is not + suspended. Required. + :vartype suspension: ~azure.ai.projects.models.AgentInsightSuspension + :ivar overview: The effective overview, or null before an overview is available. Required. + :vartype overview: ~azure.ai.projects.models.AgentInsightsOverview + :ivar updated_at: The time when this monitor was last updated. Required. + :vartype updated_at: ~datetime.datetime + """ + + id: str = rest_field(visibility=["read"]) + """The monitor identifier. Required.""" + agent_name: str = rest_field(visibility=["read"]) + """The agent this monitor analyzes. There can be only one monitor per agent. Required.""" + enabled: bool = rest_field(visibility=["read"]) + """Whether scheduled insight generation is armed for the monitor. Required.""" + run_interval_hours: float = rest_field(visibility=["read"]) + """Interval between scheduled insight runs, in hours. Required.""" + model_deployment_name: str = rest_field(visibility=["read"]) + """The model deployment to use for analyzing traces. Accepts either the deployment name alone or + with the connection name as '{connectionName}/modelDeploymentName'. Required.""" + next_scheduled_run_at: Optional[datetime.datetime] = rest_field(visibility=["read"], format="unix-timestamp") + """The next time a scheduled agent insight run will start. Omitted when scheduled generation is + disabled.""" + estimated_cost: Optional["_models.AgentInsightEstimatedCost"] = rest_field(visibility=["read"]) + """Estimated cost accumulated by Agent Insights for this monitor.""" + suspension: "_models.AgentInsightSuspension" = rest_field(visibility=["read"]) + """Why the system suspended scheduled generation. Null when the monitor is not suspended. + Required.""" + overview: "_models.AgentInsightsOverview" = rest_field(visibility=["read"]) + """The effective overview, or null before an overview is available. Required.""" + updated_at: datetime.datetime = rest_field(visibility=["read"], format="unix-timestamp") + """The time when this monitor was last updated. Required.""" + + +class AgentInsightMonitorCreate(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Fields accepted when creating an Agent Insights monitor for an agent. + + :ivar agent_name: The agent this monitor should analyze. Required. + :vartype agent_name: str + :ivar enabled: Whether scheduled insight generation should be armed. Defaults to false. + :vartype enabled: bool + :ivar run_interval_hours: Interval between scheduled insight runs, in hours. Defaults to 6. + :vartype run_interval_hours: float + :ivar model_deployment_name: The model deployment to use for analyzing traces. Accepts either + the deployment name alone or with the connection name as + '{connectionName}/modelDeploymentName'. Required. + :vartype model_deployment_name: str + """ + + agent_name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The agent this monitor should analyze. Required.""" + enabled: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Whether scheduled insight generation should be armed. Defaults to false.""" + run_interval_hours: Optional[float] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Interval between scheduled insight runs, in hours. Defaults to 6.""" + model_deployment_name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The model deployment to use for analyzing traces. Accepts either the deployment name alone or + with the connection name as '{connectionName}/modelDeploymentName'. Required.""" + + @overload + def __init__( + self, + *, + agent_name: str, + model_deployment_name: str, + enabled: Optional[bool] = None, + run_interval_hours: Optional[float] = 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 AgentInsightMonitorListItem(_Model): + """An Agent Insights monitor summary returned by list operations. + + :ivar id: The monitor identifier. Required. + :vartype id: str + :ivar agent_name: The agent this monitor analyzes. There can be only one monitor per agent. + Required. + :vartype agent_name: str + :ivar enabled: Whether scheduled insight generation is armed for the monitor. Required. + :vartype enabled: bool + :ivar run_interval_hours: Interval between scheduled insight runs, in hours. Required. + :vartype run_interval_hours: float + :ivar model_deployment_name: The model deployment to use for analyzing traces. Accepts either + the deployment name alone or with the connection name as + '{connectionName}/modelDeploymentName'. Required. + :vartype model_deployment_name: str + :ivar next_scheduled_run_at: The next time a scheduled agent insight run will start. Omitted + when scheduled generation is disabled. + :vartype next_scheduled_run_at: ~datetime.datetime + :ivar estimated_cost: Estimated cost accumulated by Agent Insights for this monitor. + :vartype estimated_cost: ~azure.ai.projects.models.AgentInsightEstimatedCost + :ivar suspension: Why the system suspended scheduled generation. Null when the monitor is not + suspended. Required. + :vartype suspension: ~azure.ai.projects.models.AgentInsightSuspension + :ivar updated_at: The time when this monitor was last updated. Required. + :vartype updated_at: ~datetime.datetime + """ + + id: str = rest_field(visibility=["read"]) + """The monitor identifier. Required.""" + agent_name: str = rest_field(visibility=["read"]) + """The agent this monitor analyzes. There can be only one monitor per agent. Required.""" + enabled: bool = rest_field(visibility=["read"]) + """Whether scheduled insight generation is armed for the monitor. Required.""" + run_interval_hours: float = rest_field(visibility=["read"]) + """Interval between scheduled insight runs, in hours. Required.""" + model_deployment_name: str = rest_field(visibility=["read"]) + """The model deployment to use for analyzing traces. Accepts either the deployment name alone or + with the connection name as '{connectionName}/modelDeploymentName'. Required.""" + next_scheduled_run_at: Optional[datetime.datetime] = rest_field(visibility=["read"], format="unix-timestamp") + """The next time a scheduled agent insight run will start. Omitted when scheduled generation is + disabled.""" + estimated_cost: Optional["_models.AgentInsightEstimatedCost"] = rest_field(visibility=["read"]) + """Estimated cost accumulated by Agent Insights for this monitor.""" + suspension: "_models.AgentInsightSuspension" = rest_field(visibility=["read"]) + """Why the system suspended scheduled generation. Null when the monitor is not suspended. + Required.""" + updated_at: datetime.datetime = rest_field(visibility=["read"], format="unix-timestamp") + """The time when this monitor was last updated. Required.""" + + +class AgentInsightMonitorUpdate(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Fields that can be updated on an Agent Insights monitor. + + :ivar enabled: Whether scheduled insight generation is armed for the monitor. + :vartype enabled: bool + :ivar run_interval_hours: Interval between scheduled insight runs, in hours. + :vartype run_interval_hours: float + :ivar model_deployment_name: The model deployment to use for analyzing traces. Accepts either + the deployment name alone or with the connection name as + '{connectionName}/modelDeploymentName'. + :vartype model_deployment_name: str + :ivar overview_override: Sets the effective user overview, or clears it when explicitly set to + null. Omission leaves the overview unchanged. This field cannot be combined with other monitor + updates. + :vartype overview_override: ~azure.ai.projects.models.AgentInsightsOverviewOverride + """ + + enabled: Optional[bool] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Whether scheduled insight generation is armed for the monitor.""" + run_interval_hours: Optional[float] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Interval between scheduled insight runs, in hours.""" + model_deployment_name: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The model deployment to use for analyzing traces. Accepts either the deployment name alone or + with the connection name as '{connectionName}/modelDeploymentName'.""" + overview_override: Optional["_models.AgentInsightsOverviewOverride"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Sets the effective user overview, or clears it when explicitly set to null. Omission leaves the + overview unchanged. This field cannot be combined with other monitor updates.""" + + @overload + def __init__( + self, + *, + enabled: Optional[bool] = None, + run_interval_hours: Optional[float] = None, + model_deployment_name: Optional[str] = None, + overview_override: Optional["_models.AgentInsightsOverviewOverride"] = 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 AgentInsightProposedFix(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """A recommended fix for an agent insight. + + :ivar kind: The proposed-fix discriminator. Required. Known values are: "prose", "code_change", + and "prompt_change". + :vartype kind: str or ~azure.ai.projects.models.AgentInsightProposedFixKind + :ivar text: The human-readable remediation guidance. Required. + :vartype text: str + :ivar changes: The concrete changes. Omitted for a prose-only fix. + :vartype changes: list[~azure.ai.projects.models.AgentInsightProposedFixChange] + """ + + kind: Union[str, "_models.AgentInsightProposedFixKind"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The proposed-fix discriminator. Required. Known values are: \"prose\", \"code_change\", and + \"prompt_change\".""" + text: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The human-readable remediation guidance. Required.""" + changes: Optional[list["_models.AgentInsightProposedFixChange"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The concrete changes. Omitted for a prose-only fix.""" + + @overload + def __init__( + self, + *, + kind: Union[str, "_models.AgentInsightProposedFixKind"], + text: str, + changes: Optional[list["_models.AgentInsightProposedFixChange"]] = 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 AgentInsightProposedFixChange(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """A customer-renderable change in a proposed fix. + + :ivar path: The source path changed by a code change. + :vartype path: str + :ivar language: The language of the changed source path. + :vartype language: str + :ivar diff: The unified diff for the changed source path. + :vartype diff: str + :ivar surface: The Prompt surface changed by a Prompt change. Known values are: "instructions" + and "tool". + :vartype surface: str or ~azure.ai.projects.models.AgentInsightPromptSurface + :ivar target: The user-visible target within a Prompt surface, when needed. + :vartype target: str + :ivar old_value: The bounded Prompt value before the change. Present for Prompt changes, + including when null. + :vartype old_value: any + :ivar new_value: The bounded Prompt value after the change. Present for Prompt changes, + including when null. + :vartype new_value: any + """ + + path: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The source path changed by a code change.""" + language: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The language of the changed source path.""" + diff: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The unified diff for the changed source path.""" + surface: Optional[Union[str, "_models.AgentInsightPromptSurface"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The Prompt surface changed by a Prompt change. Known values are: \"instructions\" and \"tool\".""" + target: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The user-visible target within a Prompt surface, when needed.""" + old_value: Optional[Any] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The bounded Prompt value before the change. Present for Prompt changes, including when null.""" + new_value: Optional[Any] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The bounded Prompt value after the change. Present for Prompt changes, including when null.""" + + @overload + def __init__( + self, + *, + path: Optional[str] = None, + language: Optional[str] = None, + diff: Optional[str] = None, + surface: Optional[Union[str, "_models.AgentInsightPromptSurface"]] = None, + target: Optional[str] = None, + old_value: Optional[Any] = None, + new_value: Optional[Any] = 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 AgentInsightRecommendedAction(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """The recommended remediation for an agent insight. + + :ivar proposed_fix: The single recommended fix for the issue represented by the insight. + Required. + :vartype proposed_fix: ~azure.ai.projects.models.AgentInsightProposedFix + """ + + proposed_fix: "_models.AgentInsightProposedFix" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The single recommended fix for the issue represented by the insight. Required.""" + + @overload + def __init__( + self, + *, + proposed_fix: "_models.AgentInsightProposedFix", + ) -> 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 AgentInsightRun(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """A long-running run that analyzes one agent's traces and updates that agent's insights. + + :ivar id: Server-assigned unique identifier. Required. + :vartype id: str + :ivar inputs: Caller-supplied inputs. + :vartype inputs: ~azure.ai.projects.models.AgentInsightRunCreate + :ivar result: Result produced on success. + :vartype result: ~azure.ai.projects.models.AgentInsightRunResult + :ivar status: Current lifecycle status. Required. Known values are: "queued", "in_progress", + "succeeded", "failed", and "cancelled". + :vartype status: str or ~azure.ai.projects.models.JobStatus + :ivar error: Error details — populated only on failure. + :vartype error: ~azure.ai.projects.models.ApiError + :ivar monitor_id: The Agent Insights monitor this run belongs to. Required. + :vartype monitor_id: str + :ivar agent_name: The agent whose traces are analyzed by this run. Required. + :vartype agent_name: str + :ivar trigger: The trigger that started the run. Required. Known values are: "on_demand" and + "scheduled". + :vartype trigger: str or ~azure.ai.projects.models.AgentInsightRunTrigger + :ivar created_at: The time when this run was created. Required. + :vartype created_at: ~datetime.datetime + :ivar updated_at: The time when this run was last updated. Required. + :vartype updated_at: ~datetime.datetime + :ivar window_start: The start of the trace window analyzed by this run. Required. + :vartype window_start: ~datetime.datetime + :ivar window_end: The end of the trace window analyzed by this run. Required. + :vartype window_end: ~datetime.datetime + :ivar started_at: The time when this run started processing. + :vartype started_at: ~datetime.datetime + :ivar completed_at: The time when this run reached a terminal status. + :vartype completed_at: ~datetime.datetime + :ivar model_deployment_name: The model deployment used to analyze traces for this run. + Required. + :vartype model_deployment_name: str + """ + + id: str = rest_field(visibility=["read"]) + """Server-assigned unique identifier. Required.""" + inputs: Optional["_models.AgentInsightRunCreate"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Caller-supplied inputs.""" + result: Optional["_models.AgentInsightRunResult"] = rest_field(visibility=["read"]) + """Result produced on success.""" + status: Union[str, "_models.JobStatus"] = rest_field(visibility=["read"]) + """Current lifecycle status. Required. Known values are: \"queued\", \"in_progress\", + \"succeeded\", \"failed\", and \"cancelled\".""" + error: Optional["_models.ApiError"] = rest_field(visibility=["read"]) + """Error details — populated only on failure.""" + monitor_id: str = rest_field(visibility=["read"]) + """The Agent Insights monitor this run belongs to. Required.""" + agent_name: str = rest_field(visibility=["read"]) + """The agent whose traces are analyzed by this run. Required.""" + trigger: Union[str, "_models.AgentInsightRunTrigger"] = rest_field(visibility=["read"]) + """The trigger that started the run. Required. Known values are: \"on_demand\" and \"scheduled\".""" + created_at: datetime.datetime = rest_field(visibility=["read"], format="unix-timestamp") + """The time when this run was created. Required.""" + updated_at: datetime.datetime = rest_field(visibility=["read"], format="unix-timestamp") + """The time when this run was last updated. Required.""" + window_start: datetime.datetime = rest_field(visibility=["read"], format="unix-timestamp") + """The start of the trace window analyzed by this run. Required.""" + window_end: datetime.datetime = rest_field(visibility=["read"], format="unix-timestamp") + """The end of the trace window analyzed by this run. Required.""" + started_at: Optional[datetime.datetime] = rest_field(visibility=["read"], format="unix-timestamp") + """The time when this run started processing.""" + completed_at: Optional[datetime.datetime] = rest_field(visibility=["read"], format="unix-timestamp") + """The time when this run reached a terminal status.""" + model_deployment_name: str = rest_field(visibility=["read"]) + """The model deployment used to analyze traces for this run. Required.""" + + @overload + def __init__( + self, + *, + inputs: Optional["_models.AgentInsightRunCreate"] = 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 AgentInsightRunCreate(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Inputs used when creating an agent insight run. + + :ivar lookback_hours: Optional finite positive number of hours of trace history to analyze, up + to 2,160. Defaults to 168. + :vartype lookback_hours: float + """ + + lookback_hours: Optional[float] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Optional finite positive number of hours of trace history to analyze, up to 2,160. Defaults to + 168.""" + + @overload + def __init__( + self, + *, + lookback_hours: Optional[float] = 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 AgentInsightRunResult(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Result statistics produced when an agent insight run succeeds. + + :ivar traces_in_window: The number of traces in the analyzed time window. Required. + :vartype traces_in_window: int + :ivar traces_analyzed: The number of traces analyzed by the run. Required. + :vartype traces_analyzed: int + :ivar insights_created: The number of insights created by the run. Required. + :vartype insights_created: int + :ivar insights_updated: The number of insights updated by the run. Required. + :vartype insights_updated: int + :ivar insights_reopened: The number of insights reopened by the run. Required. + :vartype insights_reopened: int + :ivar token_usage: Token usage for the run's insight-generation analysis. Required. + :vartype token_usage: ~azure.ai.projects.models.AgentInsightTokenUsage + """ + + traces_in_window: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The number of traces in the analyzed time window. Required.""" + traces_analyzed: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The number of traces analyzed by the run. Required.""" + insights_created: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The number of insights created by the run. Required.""" + insights_updated: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The number of insights updated by the run. Required.""" + insights_reopened: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The number of insights reopened by the run. Required.""" + token_usage: "_models.AgentInsightTokenUsage" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Token usage for the run's insight-generation analysis. Required.""" + + @overload + def __init__( + self, + *, + traces_in_window: int, + traces_analyzed: int, + insights_created: int, + insights_updated: int, + insights_reopened: int, + token_usage: "_models.AgentInsightTokenUsage", + ) -> 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 AgentInsightsOverview(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """The effective overview for an Agent Insights monitor. + + :ivar content: The overview content. Required. + :vartype content: str + :ivar source: Where the effective overview came from. Required. Known values are: "generated" + and "user_override". + :vartype source: str or ~azure.ai.projects.models.AgentInsightOverviewSource + :ivar updated_at: The time when this overview was last updated. Required. + :vartype updated_at: ~datetime.datetime + """ + + content: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The overview content. Required.""" + source: Union[str, "_models.AgentInsightOverviewSource"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Where the effective overview came from. Required. Known values are: \"generated\" and + \"user_override\".""" + updated_at: datetime.datetime = rest_field( + visibility=["read", "create", "update", "delete", "query"], format="unix-timestamp" + ) + """The time when this overview was last updated. Required.""" @overload def __init__( self, *, - type: str, + content: str, + source: Union[str, "_models.AgentInsightOverviewSource"], + updated_at: datetime.datetime, ) -> None: ... @overload @@ -1160,43 +2123,22 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class AgentEvaluatorGenerationJobSource( - EvaluatorGenerationJobSource, discriminator="agent" -): # pylint: disable=docstring-keyword-should-match-keyword-only - """Agent source for evaluator generation jobs — references an agent to fetch instructions and - metadata from. +class AgentInsightsOverviewOverride(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """A user-provided overview that becomes effective immediately and seeds the next generation. - :ivar description: Optional description of what this source represents — helps the pipeline - interpret its content (e.g., 'Company refund policy document' or 'Describes the agent's core - capabilities'). - :vartype description: str - :ivar type: The source type for this source, which is Agent. Required. Agent source — - references an agent to fetch instructions and metadata from. - :vartype type: str or ~azure.ai.projects.models.AGENT - :ivar agent_name: The agent name to fetch instructions from. Required. - :vartype agent_name: str - :ivar agent_version: The agent version. If not specified, the latest version is used. - :vartype agent_version: str + :ivar content: The nonblank overview content, limited to 64 KiB when encoded as UTF-8. + Required. + :vartype content: str """ - description: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """Optional description of what this source represents — helps the pipeline interpret its content - (e.g., 'Company refund policy document' or 'Describes the agent's core capabilities').""" - type: Literal[EvaluatorGenerationJobSourceType.AGENT] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The source type for this source, which is Agent. Required. Agent source — references an agent - to fetch instructions and metadata from.""" - agent_name: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The agent name to fetch instructions from. Required.""" - agent_version: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The agent version. If not specified, the latest version is used.""" + content: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The nonblank overview content, limited to 64 KiB when encoded as UTF-8. Required.""" @overload def __init__( self, *, - agent_name: str, - description: Optional[str] = None, - agent_version: Optional[str] = None, + content: str, ) -> None: ... @overload @@ -1208,31 +2150,40 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) - self.type = EvaluatorGenerationJobSourceType.AGENT # type: ignore -class BaseCredentials(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only - """A base class for connection credentials. - - You probably want to use the sub-classes and not this class directly. Known sub-classes are: - EntraIDCredentials, AgenticIdentityPreviewCredentials, ApiKeyCredentials, CustomCredential, - NoAuthenticationCredentials, SASCredentials +class AgentInsightSuspension(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Structured reason why scheduled generation is suspended for a monitor. - :ivar type: The type of credential used by the connection. Required. Known values are: - "ApiKey", "AAD", "SAS", "CustomKeys", "None", and "AgenticIdentityToken_Preview". - :vartype type: str or ~azure.ai.projects.models.CredentialType + :ivar code: Stable, machine-readable suspension category. Required. + :vartype code: str + :ivar message: Human-readable description of the suspension. Required. + :vartype message: str + :ivar occurred_at: The time when the suspension occurred. Required. + :vartype occurred_at: ~datetime.datetime + :ivar details: Additional reason-specific suspension details. + :vartype details: dict[str, any] """ - __mapping__: dict[str, _Model] = {} - type: str = rest_discriminator(name="type", visibility=["read"]) - """The type of credential used by the connection. Required. Known values are: \"ApiKey\", \"AAD\", - \"SAS\", \"CustomKeys\", \"None\", and \"AgenticIdentityToken_Preview\".""" + code: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Stable, machine-readable suspension category. Required.""" + message: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Human-readable description of the suspension. Required.""" + occurred_at: datetime.datetime = rest_field( + visibility=["read", "create", "update", "delete", "query"], format="unix-timestamp" + ) + """The time when the suspension occurred. Required.""" + details: Optional[dict[str, Any]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Additional reason-specific suspension details.""" @overload def __init__( self, *, - type: str, + code: str, + message: str, + occurred_at: datetime.datetime, + details: Optional[dict[str, Any]] = None, ) -> None: ... @overload @@ -1246,19 +2197,36 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) -class AgenticIdentityPreviewCredentials(BaseCredentials, discriminator="AgenticIdentityToken_Preview"): - """Agentic identity credential definition. +class AgentInsightTokenUsage(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Token usage for an Agent Insights run. - :ivar type: The credential type. Required. Agentic identity credential. - :vartype type: str or ~azure.ai.projects.models.AGENTIC_IDENTITY_PREVIEW + :ivar input_tokens: The number of input tokens used by the run. Required. + :vartype input_tokens: int + :ivar output_tokens: The number of output tokens used by the run. Required. + :vartype output_tokens: int + :ivar cached_tokens: The number of input tokens served from cache. + :vartype cached_tokens: int + :ivar total_tokens: The total number of tokens used by the run. Required. + :vartype total_tokens: int """ - type: Literal[CredentialType.AGENTIC_IDENTITY_PREVIEW] = rest_discriminator(name="type", visibility=["read"]) # type: ignore - """The credential type. Required. Agentic identity credential.""" + input_tokens: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The number of input tokens used by the run. Required.""" + output_tokens: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The number of output tokens used by the run. Required.""" + cached_tokens: Optional[int] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The number of input tokens served from cache.""" + total_tokens: int = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The total number of tokens used by the run. Required.""" @overload def __init__( self, + *, + input_tokens: int, + output_tokens: int, + total_tokens: int, + cached_tokens: Optional[int] = None, ) -> None: ... @overload @@ -1270,39 +2238,27 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) - self.type = CredentialType.AGENTIC_IDENTITY_PREVIEW # type: ignore -class AgentIdentity(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only - """AgentIdentity. +class AgentInsightUpdate(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Fields that can be updated on an agent insight. - :ivar principal_id: The principal ID of the agent instance. Required. - :vartype principal_id: str - :ivar client_id: The client ID of the agent instance. Also referred to as the instance ID. - Required. - :vartype client_id: str - :ivar status: The status of the agent identity. Present for both the agent instance identity - and the agent blueprint. Known values are: "active" and "disabled". - :vartype status: str or ~azure.ai.projects.models.AgentIdentityStatus + :ivar status: The lifecycle status to apply to the insight. Known values are: "active", + "resolved", and "ignored". + :vartype status: str or ~azure.ai.projects.models.AgentInsightStatus """ - principal_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The principal ID of the agent instance. Required.""" - client_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) - """The client ID of the agent instance. Also referred to as the instance ID. Required.""" - status: Optional[Union[str, "_models.AgentIdentityStatus"]] = rest_field( + status: Optional[Union[str, "_models.AgentInsightStatus"]] = rest_field( visibility=["read", "create", "update", "delete", "query"] ) - """The status of the agent identity. Present for both the agent instance identity and the agent - blueprint. Known values are: \"active\" and \"disabled\".""" + """The lifecycle status to apply to the insight. Known values are: \"active\", \"resolved\", and + \"ignored\".""" @overload def __init__( self, *, - principal_id: str, - client_id: str, - status: Optional[Union[str, "_models.AgentIdentityStatus"]] = None, + status: Optional[Union[str, "_models.AgentInsightStatus"]] = None, ) -> None: ... @overload @@ -8963,6 +9919,9 @@ class HostedAgentDefinition( :ivar telemetry_config: Optional customer-supplied telemetry configuration for exporting container logs, traces, and metrics. :vartype telemetry_config: ~azure.ai.projects.models.TelemetryConfig + :ivar session_configuration: Optional session defaults (for example, the idle timeout) applied + to sessions created for this agent version. + :vartype session_configuration: ~azure.ai.projects.models.SessionConfiguration """ kind: Literal[AgentKind.HOSTED] = rest_discriminator(name="kind", visibility=["read", "create", "update", "delete", "query"]) # type: ignore @@ -8994,6 +9953,11 @@ class HostedAgentDefinition( ) """Optional customer-supplied telemetry configuration for exporting container logs, traces, and metrics.""" + session_configuration: Optional["_models.SessionConfiguration"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Optional session defaults (for example, the idle timeout) applied to sessions created for this + agent version.""" @overload def __init__( @@ -9007,6 +9971,7 @@ def __init__( protocol_versions: Optional[list["_models.ProtocolVersionRecord"]] = None, code_configuration: Optional["_models.CodeConfiguration"] = None, telemetry_config: Optional["_models.TelemetryConfig"] = None, + session_configuration: Optional["_models.SessionConfiguration"] = None, ) -> None: ... @overload @@ -11163,6 +12128,206 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) +class Microsoft365PermissionScopes(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """A set of delegated permission scopes requested from a single resource application. + + :ivar resource_app_id: Application id of the resource that exposes the requested delegated + scopes. Required. + :vartype resource_app_id: str + :ivar scopes: Delegated scope names requested from the resource application. Must not be empty. + Required. + :vartype scopes: list[str] + """ + + resource_app_id: str = rest_field(name="resourceAppId", visibility=["read", "create", "update", "delete", "query"]) + """Application id of the resource that exposes the requested delegated scopes. Required.""" + scopes: list[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """Delegated scope names requested from the resource application. Must not be empty. Required.""" + + @overload + def __init__( + self, + *, + resource_app_id: str, + scopes: list[str], + ) -> 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 Microsoft365PublishDefaults(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Default and previously-published values used to pre-populate a Microsoft 365 publish request + for a Foundry agent. + + :ivar app_publish_scope: The publish scope. Known values are: "Personal", "Shared", and + "Tenant". + :vartype app_publish_scope: str or ~azure.ai.projects.models.Microsoft365PublishScope + :ivar agent_name: The agent name. + :vartype agent_name: str + :ivar agent_display_name: The user-facing display name for the agent. Defaults to the agent + name if not previously overridden. + :vartype agent_display_name: str + :ivar app_registration_client_id: The app-registration client id associated with the agent. + :vartype app_registration_client_id: str + :ivar bot_service_arm_id: ARM resource id of the Azure Bot Service associated with the + previously-published app, if any. + :vartype bot_service_arm_id: str + :ivar app_version: The most recently published app version. + :vartype app_version: str + :ivar recommended_next_app_version: The recommended next app version (the most recent app + version, incremented). + :vartype recommended_next_app_version: str + :ivar title_id: The Microsoft 365 title id of the previously-published app, if any. + :vartype title_id: str + :ivar teams_app_id: The Microsoft Teams app id of the previously-published app, if any. + :vartype teams_app_id: str + :ivar short_description: Short, one-line description shown in the Teams app listing. + :vartype short_description: str + :ivar full_description: Full description shown on the Teams app details page. + :vartype full_description: str + :ivar developer_name: Display name of the developer / publisher. + :vartype developer_name: str + :ivar developer_website_url: Developer / publisher website URL. + :vartype developer_website_url: str + :ivar privacy_url: Privacy policy URL. + :vartype privacy_url: str + :ivar terms_of_use_url: Terms-of-use URL. + :vartype terms_of_use_url: str + """ + + app_publish_scope: Optional[Union[str, "_models.Microsoft365PublishScope"]] = rest_field( + name="appPublishScope", visibility=["read", "create", "update", "delete", "query"] + ) + """The publish scope. Known values are: \"Personal\", \"Shared\", and \"Tenant\".""" + agent_name: Optional[str] = rest_field(name="agentName", visibility=["read", "create", "update", "delete", "query"]) + """The agent name.""" + agent_display_name: Optional[str] = rest_field( + name="agentDisplayName", visibility=["read", "create", "update", "delete", "query"] + ) + """The user-facing display name for the agent. Defaults to the agent name if not previously + overridden.""" + app_registration_client_id: Optional[str] = rest_field( + name="appRegistrationClientId", visibility=["read", "create", "update", "delete", "query"] + ) + """The app-registration client id associated with the agent.""" + bot_service_arm_id: Optional[str] = rest_field( + name="botServiceArmId", visibility=["read", "create", "update", "delete", "query"] + ) + """ARM resource id of the Azure Bot Service associated with the previously-published app, if any.""" + app_version: Optional[str] = rest_field( + name="appVersion", visibility=["read", "create", "update", "delete", "query"] + ) + """The most recently published app version.""" + recommended_next_app_version: Optional[str] = rest_field( + name="recommendedNextAppVersion", visibility=["read", "create", "update", "delete", "query"] + ) + """The recommended next app version (the most recent app version, incremented).""" + title_id: Optional[str] = rest_field(name="titleId", visibility=["read", "create", "update", "delete", "query"]) + """The Microsoft 365 title id of the previously-published app, if any.""" + teams_app_id: Optional[str] = rest_field( + name="teamsAppId", visibility=["read", "create", "update", "delete", "query"] + ) + """The Microsoft Teams app id of the previously-published app, if any.""" + short_description: Optional[str] = rest_field( + name="shortDescription", visibility=["read", "create", "update", "delete", "query"] + ) + """Short, one-line description shown in the Teams app listing.""" + full_description: Optional[str] = rest_field( + name="fullDescription", visibility=["read", "create", "update", "delete", "query"] + ) + """Full description shown on the Teams app details page.""" + developer_name: Optional[str] = rest_field( + name="developerName", visibility=["read", "create", "update", "delete", "query"] + ) + """Display name of the developer / publisher.""" + developer_website_url: Optional[str] = rest_field( + name="developerWebsiteUrl", visibility=["read", "create", "update", "delete", "query"] + ) + """Developer / publisher website URL.""" + privacy_url: Optional[str] = rest_field( + name="privacyUrl", visibility=["read", "create", "update", "delete", "query"] + ) + """Privacy policy URL.""" + terms_of_use_url: Optional[str] = rest_field( + name="termsOfUseUrl", visibility=["read", "create", "update", "delete", "query"] + ) + """Terms-of-use URL.""" + + @overload + def __init__( + self, + *, + app_publish_scope: Optional[Union[str, "_models.Microsoft365PublishScope"]] = None, + agent_name: Optional[str] = None, + agent_display_name: Optional[str] = None, + app_registration_client_id: Optional[str] = None, + bot_service_arm_id: Optional[str] = None, + app_version: Optional[str] = None, + recommended_next_app_version: Optional[str] = None, + title_id: Optional[str] = None, + teams_app_id: Optional[str] = None, + short_description: Optional[str] = None, + full_description: Optional[str] = None, + developer_name: Optional[str] = None, + developer_website_url: Optional[str] = None, + privacy_url: Optional[str] = None, + terms_of_use_url: Optional[str] = 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 Microsoft365PublishResult(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Response from publishing an agent to Microsoft 365 / Microsoft Teams. + + :ivar title_id: The Microsoft 365 title id of the published app. + :vartype title_id: str + :ivar teams_app_id: The Microsoft Teams app id of the published app. + :vartype teams_app_id: str + """ + + title_id: Optional[str] = rest_field(name="titleId", visibility=["read", "create", "update", "delete", "query"]) + """The Microsoft 365 title id of the published app.""" + teams_app_id: Optional[str] = rest_field( + name="teamsAppId", visibility=["read", "create", "update", "delete", "query"] + ) + """The Microsoft Teams app id of the published app.""" + + @overload + def __init__( + self, + *, + title_id: Optional[str] = None, + teams_app_id: Optional[str] = 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 MicrosoftFabricPreviewTool( Tool, discriminator="fabric_dataagent_preview" ): # pylint: disable=docstring-keyword-should-match-keyword-only @@ -13303,6 +14468,40 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) +class RoutineAuthorization(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Optional authorization configuration for a routine dispatch. + + :ivar identity: The identity used when dispatching the routine. Defaults to agent when omitted; + set to creator only when the customer opts in to creator identity dispatch. Known values are: + "agent" and "creator". + :vartype identity: str or ~azure.ai.projects.models.RoutineDispatchIdentity + """ + + identity: Optional[Union[str, "_models.RoutineDispatchIdentity"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The identity used when dispatching the routine. Defaults to agent when omitted; set to creator + only when the customer opts in to creator identity dispatch. Known values are: \"agent\" and + \"creator\".""" + + @overload + def __init__( + self, + *, + identity: Optional[Union[str, "_models.RoutineDispatchIdentity"]] = 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 RoutineRun(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only """A single routine run returned from the run history API. @@ -13813,6 +15012,39 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) +class SessionConfiguration(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Session defaults applied to sessions created for a hosted agent version. + + :ivar idle_timeout_seconds: The idle duration, in seconds, before a session's sandbox is + suspended. Optional — when unset, the server default of 900 seconds is used. Must be between + 120 and 3600 seconds (inclusive). + :vartype idle_timeout_seconds: ~datetime.timedelta + """ + + idle_timeout_seconds: Optional[datetime.timedelta] = rest_field( + visibility=["read", "create", "update", "delete", "query"], format="duration-seconds-int" + ) + """The idle duration, in seconds, before a session's sandbox is suspended. Optional — when unset, + the server default of 900 seconds is used. Must be between 120 and 3600 seconds (inclusive).""" + + @overload + def __init__( + self, + *, + idle_timeout_seconds: Optional[datetime.timedelta] = 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 SessionDirectoryEntry(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only """A single entry in a directory listing. @@ -13985,29 +15217,86 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: class SharepointPreviewTool( Tool, discriminator="sharepoint_grounding_preview" ): # pylint: disable=docstring-keyword-should-match-keyword-only - """The input definition information for a sharepoint tool as used to configure an agent. + """The input definition information for a sharepoint tool as used to configure an agent. + + :ivar type: The object type, which is always 'sharepoint_grounding_preview'. Required. + SHAREPOINT_GROUNDING_PREVIEW. + :vartype type: str or ~azure.ai.projects.models.SHAREPOINT_GROUNDING_PREVIEW + :ivar sharepoint_grounding_preview: The sharepoint grounding tool parameters. Required. + :vartype sharepoint_grounding_preview: + ~azure.ai.projects.models.SharepointGroundingToolParameters + """ + + type: Literal[ToolType.SHAREPOINT_GROUNDING_PREVIEW] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """The object type, which is always 'sharepoint_grounding_preview'. Required. + SHAREPOINT_GROUNDING_PREVIEW.""" + sharepoint_grounding_preview: "_models.SharepointGroundingToolParameters" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The sharepoint grounding tool parameters. Required.""" + + @overload + def __init__( + self, + *, + sharepoint_grounding_preview: "_models.SharepointGroundingToolParameters", + ) -> 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) + self.type = ToolType.SHAREPOINT_GROUNDING_PREVIEW # type: ignore + + +class ShellToolboxTool( + ToolboxTool, discriminator="shell" +): # pylint: disable=docstring-keyword-should-match-keyword-only + """A shell tool stored in a toolbox. This model is additive to toolbox configuration and does not + modify the OpenAI tool contract or existing toolbox tool definitions. - :ivar type: The object type, which is always 'sharepoint_grounding_preview'. Required. - SHAREPOINT_GROUNDING_PREVIEW. - :vartype type: str or ~azure.ai.projects.models.SHAREPOINT_GROUNDING_PREVIEW - :ivar sharepoint_grounding_preview: The sharepoint grounding tool parameters. Required. - :vartype sharepoint_grounding_preview: - ~azure.ai.projects.models.SharepointGroundingToolParameters + :ivar name: Optional user-defined name for this tool or configuration. + :vartype name: str + :ivar description: Optional user-defined description for this tool or configuration. + :vartype description: str + :ivar tool_configs: Per-tool configuration map. Keys are tool names or ``*`` (catch-all + default). Resolution order: exact tool name match takes priority over ``*``. Unknown tool names + are silently ignored at runtime. + :vartype tool_configs: dict[str, ~azure.ai.projects.models.ToolConfig] + :ivar type: The type of the tool. Always ``shell``. Required. SHELL. + :vartype type: str or ~azure.ai.projects.models.SHELL + :ivar allowed_callers: + :vartype allowed_callers: list[str or ~azure.ai.projects.models.CallableToolAllowedCaller] + :ivar environment: The environment in which shell commands are executed. Specify an + automatically provisioned container or an existing container. Required. + :vartype environment: ~azure.ai.projects.models.ToolboxShellEnvironment """ - type: Literal[ToolType.SHAREPOINT_GROUNDING_PREVIEW] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore - """The object type, which is always 'sharepoint_grounding_preview'. Required. - SHAREPOINT_GROUNDING_PREVIEW.""" - sharepoint_grounding_preview: "_models.SharepointGroundingToolParameters" = rest_field( + type: Literal[ToolboxToolType.SHELL] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """The type of the tool. Always ``shell``. Required. SHELL.""" + allowed_callers: Optional[list[Union[str, "_models.CallableToolAllowedCaller"]]] = rest_field( visibility=["read", "create", "update", "delete", "query"] ) - """The sharepoint grounding tool parameters. Required.""" + environment: "_models.ToolboxShellEnvironment" = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The environment in which shell commands are executed. Specify an automatically provisioned + container or an existing container. Required.""" @overload def __init__( self, *, - sharepoint_grounding_preview: "_models.SharepointGroundingToolParameters", + environment: "_models.ToolboxShellEnvironment", + name: Optional[str] = None, + description: Optional[str] = None, + tool_configs: Optional[dict[str, "_models.ToolConfig"]] = None, + allowed_callers: Optional[list[Union[str, "_models.CallableToolAllowedCaller"]]] = None, ) -> None: ... @overload @@ -14019,7 +15308,7 @@ def __init__(self, mapping: Mapping[str, Any]) -> None: def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) - self.type = ToolType.SHAREPOINT_GROUNDING_PREVIEW # type: ignore + self.type = ToolboxToolType.SHELL # type: ignore class SimpleQnADataGenerationJobOptions( @@ -14974,6 +16263,197 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: self.type = ToolboxToolType.TOOLBOX_SEARCH_PREVIEW # type: ignore +class ToolboxShellEnvironment(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """An execution environment for a shell tool stored in a toolbox. This environment model is scoped + to toolbox configuration and does not modify the OpenAI shell environment contract. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + ToolboxShellContainerAutoEnvironment, ToolboxShellContainerReferenceEnvironment + + :ivar type: The type of the shell execution environment. Required. Default value is None. + :vartype type: str + """ + + __mapping__: dict[str, _Model] = {} + type: str = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) + """The type of the shell execution environment. Required. Default value is None.""" + + @overload + def __init__( + self, + *, + type: str, + ) -> 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 ToolboxShellContainerAutoEnvironment( + ToolboxShellEnvironment, discriminator="container_auto" +): # pylint: disable=docstring-keyword-should-match-keyword-only + """An automatically provisioned container environment for a shell tool stored in a toolbox. + + :ivar type: The type of the shell execution environment. Always ``container_auto``. Required. + Default value is "container_auto". + :vartype type: str + :ivar file_ids: An optional list of uploaded files to make available to your code. + :vartype file_ids: list[str] + :ivar memory_limit: Known values are: "1g", "4g", "16g", and "64g". + :vartype memory_limit: str or ~azure.ai.projects.models.ContainerMemoryLimit + :ivar skills: An optional list of skills referenced by id or inline data. + :vartype skills: list[~azure.ai.projects.models.ContainerSkill] + :ivar network_policy: The network access policy for the container. When omitted, the service + defaults to disabled outbound network access. + :vartype network_policy: ~azure.ai.projects.models.ToolboxShellNetworkPolicy + """ + + type: Literal["container_auto"] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """The type of the shell execution environment. Always ``container_auto``. Required. Default value + is \"container_auto\".""" + file_ids: Optional[list[str]] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """An optional list of uploaded files to make available to your code.""" + memory_limit: Optional[Union[str, "_models.ContainerMemoryLimit"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Known values are: \"1g\", \"4g\", \"16g\", and \"64g\".""" + skills: Optional[list["_models.ContainerSkill"]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """An optional list of skills referenced by id or inline data.""" + network_policy: Optional["_models.ToolboxShellNetworkPolicy"] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """The network access policy for the container. When omitted, the service defaults to disabled + outbound network access.""" + + @overload + def __init__( + self, + *, + file_ids: Optional[list[str]] = None, + memory_limit: Optional[Union[str, "_models.ContainerMemoryLimit"]] = None, + skills: Optional[list["_models.ContainerSkill"]] = None, + network_policy: Optional["_models.ToolboxShellNetworkPolicy"] = 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) + self.type = "container_auto" # type: ignore + + +class ToolboxShellContainerReferenceEnvironment( + ToolboxShellEnvironment, discriminator="container_reference" +): # pylint: disable=name-too-long,docstring-keyword-should-match-keyword-only + """An existing container environment for a shell tool stored in a toolbox. + + :ivar type: The type of the shell execution environment. Always ``container_reference``. + Required. Default value is "container_reference". + :vartype type: str + :ivar container_id: The ID of the referenced container. Required. + :vartype container_id: str + """ + + type: Literal["container_reference"] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """The type of the shell execution environment. Always ``container_reference``. Required. Default + value is \"container_reference\".""" + container_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The ID of the referenced container. Required.""" + + @overload + def __init__( + self, + *, + container_id: str, + ) -> 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) + self.type = "container_reference" # type: ignore + + +class ToolboxShellNetworkPolicy(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only + """Network access policy for an automatically provisioned toolbox shell container. + + You probably want to use the sub-classes and not this class directly. Known sub-classes are: + ToolboxShellNetworkPolicyDisabled + + :ivar type: The type of network access policy. Required. Default value is None. + :vartype type: str + """ + + __mapping__: dict[str, _Model] = {} + type: str = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) + """The type of network access policy. Required. Default value is None.""" + + @overload + def __init__( + self, + *, + type: str, + ) -> 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 ToolboxShellNetworkPolicyDisabled(ToolboxShellNetworkPolicy, discriminator="disabled"): + """A network policy that disables outbound access from a toolbox shell container. + + :ivar type: The type of network access policy. Always ``disabled``. Required. Default value is + "disabled". + :vartype type: str + """ + + type: Literal["disabled"] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """The type of network access policy. Always ``disabled``. Required. Default value is + \"disabled\".""" + + @overload + def __init__( + self, + ) -> 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) + self.type = "disabled" # type: ignore + + class ToolboxSkill(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only """A skill source included in a toolbox. @@ -16168,6 +17648,121 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: super().__init__(*args, **kwargs) +class WebIQPreviewTool( + Tool, discriminator="web_iq_preview" +): # pylint: disable=docstring-keyword-should-match-keyword-only + """A WebIQ server-side tool. + + :ivar type: The object type, which is always 'web_iq_preview'. Required. WEB_IQ_PREVIEW. + :vartype type: str or ~azure.ai.projects.models.WEB_IQ_PREVIEW + :ivar project_connection_id: The ID of the WebIQ project connection. Required. + :vartype project_connection_id: str + :ivar server_label: The label of the WebIQ MCP server to connect to. When omitted, the service + defaults to connection name extracted from project_connection_id. + :vartype server_label: str + :ivar require_approval: Whether the agent requires approval before executing actions. When + omitted, the service defaults to "always". Is either a MCPToolRequireApproval type or a str + type. + :vartype require_approval: ~azure.ai.projects.models.MCPToolRequireApproval or str + """ + + type: Literal[ToolType.WEB_IQ_PREVIEW] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """The object type, which is always 'web_iq_preview'. Required. WEB_IQ_PREVIEW.""" + project_connection_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The ID of the WebIQ project connection. Required.""" + server_label: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The label of the WebIQ MCP server to connect to. When omitted, the service defaults to + connection name extracted from project_connection_id.""" + require_approval: Optional[Union["_models.MCPToolRequireApproval", str]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Whether the agent requires approval before executing actions. When omitted, the service + defaults to \"always\". Is either a MCPToolRequireApproval type or a str type.""" + + @overload + def __init__( + self, + *, + project_connection_id: str, + server_label: Optional[str] = None, + require_approval: Optional[Union["_models.MCPToolRequireApproval", str]] = 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) + self.type = ToolType.WEB_IQ_PREVIEW # type: ignore + + +class WebIQPreviewToolboxTool( + ToolboxTool, discriminator="web_iq_preview" +): # pylint: disable=docstring-keyword-should-match-keyword-only + """A WebIQ tool stored in a toolbox. + + :ivar name: Optional user-defined name for this tool or configuration. + :vartype name: str + :ivar description: Optional user-defined description for this tool or configuration. + :vartype description: str + :ivar tool_configs: Per-tool configuration map. Keys are tool names or ``*`` (catch-all + default). Resolution order: exact tool name match takes priority over ``*``. Unknown tool names + are silently ignored at runtime. + :vartype tool_configs: dict[str, ~azure.ai.projects.models.ToolConfig] + :ivar type: Required. WEB_IQ_PREVIEW. + :vartype type: str or ~azure.ai.projects.models.WEB_IQ_PREVIEW + :ivar project_connection_id: The ID of the WebIQ project connection. Required. + :vartype project_connection_id: str + :ivar server_label: The label of the WebIQ MCP server to connect to. When omitted, the service + defaults to connection name extracted from project_connection_id. + :vartype server_label: str + :ivar require_approval: Whether the agent requires approval before executing actions. When + omitted, the service defaults to "always". Is either a MCPToolRequireApproval type or a str + type. + :vartype require_approval: ~azure.ai.projects.models.MCPToolRequireApproval or str + """ + + type: Literal[ToolboxToolType.WEB_IQ_PREVIEW] = rest_discriminator(name="type", visibility=["read", "create", "update", "delete", "query"]) # type: ignore + """Required. WEB_IQ_PREVIEW.""" + project_connection_id: str = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The ID of the WebIQ project connection. Required.""" + server_label: Optional[str] = rest_field(visibility=["read", "create", "update", "delete", "query"]) + """The label of the WebIQ MCP server to connect to. When omitted, the service defaults to + connection name extracted from project_connection_id.""" + require_approval: Optional[Union["_models.MCPToolRequireApproval", str]] = rest_field( + visibility=["read", "create", "update", "delete", "query"] + ) + """Whether the agent requires approval before executing actions. When omitted, the service + defaults to \"always\". Is either a MCPToolRequireApproval type or a str type.""" + + @overload + def __init__( + self, + *, + project_connection_id: str, + name: Optional[str] = None, + description: Optional[str] = None, + tool_configs: Optional[dict[str, "_models.ToolConfig"]] = None, + server_label: Optional[str] = None, + require_approval: Optional[Union["_models.MCPToolRequireApproval", str]] = 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) + self.type = ToolboxToolType.WEB_IQ_PREVIEW # type: ignore + + class WebSearchApproximateLocation(_Model): # pylint: disable=docstring-keyword-should-match-keyword-only """Web search approximate location. diff --git a/sdk/ai/azure-ai-projects/azure/ai/projects/models/_patch.py b/sdk/ai/azure-ai-projects/azure/ai/projects/models/_patch.py index 81717c62e046..5f26540b9ffe 100644 --- a/sdk/ai/azure-ai-projects/azure/ai/projects/models/_patch.py +++ b/sdk/ai/azure-ai-projects/azure/ai/projects/models/_patch.py @@ -34,6 +34,7 @@ ) from ._models import CustomCredential as CustomCredentialGenerated from ..models import ( + AgentInsightRunResult, AgentOptimizationJobResult, DataGenerationJobResult, EvaluatorVersion, @@ -61,6 +62,7 @@ ) _BETA_OPERATION_FEATURE_HEADERS: Final[dict] = { + "agent_insight_monitors": _FoundryFeaturesOptInKeys.AGENT_INSIGHTS_V1_PREVIEW.value, "evaluation_taxonomies": _FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW.value, "evaluators": _FoundryFeaturesOptInKeys.EVALUATIONS_V1_PREVIEW.value, "insights": _FoundryFeaturesOptInKeys.INSIGHTS_V1_PREVIEW.value, @@ -624,8 +626,89 @@ def from_continuation_token( return cls(client, initial_response, deserialization_callback, polling_method) +class AgentInsightRunLROPoller(LROPoller[AgentInsightRunResult]): + """Custom LROPoller for Agent Insights run operations.""" + + def __init__(self, client: Any, initial_response: Any, deserialization_callback: Any, polling_method: Any) -> None: + self._run_id = DatasetGenerationLROPoller._get_job_id(initial_response) + super().__init__(client, initial_response, deserialization_callback, polling_method) + + @property + def details(self) -> Mapping[str, Any]: + """Returns metadata associated with the Agent Insights run operation. + + The mapping contains a ``run_id`` key whose value is the created run ID. Use it to call + ``get_run`` or ``cancel_run`` while the run is still in progress. + + :return: A mapping containing the ``run_id`` key. + :rtype: Mapping[str, Any] + """ + return {"run_id": self._run_id} + + @classmethod + def from_continuation_token( + cls, polling_method: PollingMethod[AgentInsightRunResult], continuation_token: str, **kwargs: Any + ) -> "AgentInsightRunLROPoller": + """Create a poller from a continuation token. + + :param polling_method: The polling strategy to adopt. + :type polling_method: ~azure.core.polling.PollingMethod + :param continuation_token: An opaque continuation token. + :type continuation_token: str + :return: An instance of AgentInsightRunLROPoller. + :rtype: AgentInsightRunLROPoller + """ + client, initial_response, deserialization_callback = polling_method.from_continuation_token( + continuation_token, **kwargs + ) + return cls(client, initial_response, deserialization_callback, polling_method) + + +class AsyncAgentInsightRunLROPoller(AsyncLROPoller[AgentInsightRunResult]): + """Custom AsyncLROPoller for Agent Insights run operations.""" + + def __init__(self, client: Any, initial_response: Any, deserialization_callback: Any, polling_method: Any) -> None: + super().__init__(client, initial_response, deserialization_callback, polling_method) + self._run_id = DatasetGenerationLROPoller._get_job_id(initial_response) + + @property + def details(self) -> Mapping[str, Any]: + """Returns metadata associated with the Agent Insights run operation. + + The mapping contains a ``run_id`` key whose value is the created run ID. Use it to call + ``get_run`` or ``cancel_run`` while the run is still in progress. + + :return: A mapping containing the ``run_id`` key. + :rtype: Mapping[str, Any] + """ + return {"run_id": self._run_id} + + @classmethod + def from_continuation_token( + cls, + polling_method: AsyncPollingMethod[AgentInsightRunResult], + continuation_token: str, + **kwargs: Any, + ) -> "AsyncAgentInsightRunLROPoller": + """Create a poller from a continuation token. + + :param polling_method: The polling strategy to adopt. + :type polling_method: ~azure.core.polling.AsyncPollingMethod + :param continuation_token: An opaque continuation token. + :type continuation_token: str + :return: An instance of AsyncAgentInsightRunLROPoller. + :rtype: AsyncAgentInsightRunLROPoller + """ + client, initial_response, deserialization_callback = polling_method.from_continuation_token( + continuation_token, **kwargs + ) + return cls(client, initial_response, deserialization_callback, polling_method) + + __all__: List[str] = [ + "AgentInsightRunLROPoller", "AgentOptimizationLROPoller", + "AsyncAgentInsightRunLROPoller", "AsyncAgentOptimizationLROPoller", "AsyncDatasetGenerationLROPoller", "AsyncEvaluatorGenerationLROPoller", diff --git a/sdk/ai/azure-ai-projects/azure/ai/projects/operations/_operations.py b/sdk/ai/azure-ai-projects/azure/ai/projects/operations/_operations.py index e351ab3442fb..b48860dbfb32 100644 --- a/sdk/ai/azure-ai-projects/azure/ai/projects/operations/_operations.py +++ b/sdk/ai/azure-ai-projects/azure/ai/projects/operations/_operations.py @@ -565,6 +565,94 @@ def build_agents_get_session_log_stream_request( # pylint: disable=name-too-lon return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) +def build_agents_publish_to_microsoft365_request( # pylint: disable=name-too-long + agent_name: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/agents/{agent_name}/microsoft365/publish" + path_format_arguments = { + "agent_name": _SERIALIZER.url("agent_name", agent_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_agents_get_microsoft365_package_request( # pylint: disable=name-too-long + agent_name: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + accept = _headers.pop("Accept", "application/zip") + + # Construct URL + _url = "/agents/{agent_name}/microsoft365/zip" + path_format_arguments = { + "agent_name": _SERIALIZER.url("agent_name", agent_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_agents_get_microsoft365_publish_defaults_request( # pylint: disable=name-too-long + agent_name: str, *, publish_as_digital_worker: Optional[bool] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/agents/{agent_name}/microsoft365/publishdefaults" + path_format_arguments = { + "agent_name": _SERIALIZER.url("agent_name", agent_name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + if publish_as_digital_worker is not None: + _params["publishAsDigitalWorker"] = _SERIALIZER.query( + "publish_as_digital_worker", publish_as_digital_worker, "bool" + ) + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + def build_agents_upload_session_file_request( agent_name: str, session_id: str, *, path: str, **kwargs: Any ) -> HttpRequest: @@ -1425,8 +1513,14 @@ def build_toolboxes_delete_version_request(name: str, version: str, **kwargs: An return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_beta_evaluation_taxonomies_get_request( # pylint: disable=name-too-long - name: str, **kwargs: Any +def build_beta_agent_insight_monitors_list_request( # pylint: disable=name-too-long + *, + after: Optional[str] = None, + before: Optional[str] = None, + limit: Optional[int] = None, + order: Optional[Union[str, _models.PageOrder]] = None, + agent_name: Optional[str] = None, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -1435,14 +1529,19 @@ def build_beta_evaluation_taxonomies_get_request( # pylint: disable=name-too-lo accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/evaluationtaxonomies/{name}" - path_format_arguments = { - "name": _SERIALIZER.url("name", name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore + _url = "/agent_insight_monitors" # Construct parameters + if after is not None: + _params["after"] = _SERIALIZER.query("after", after, "str") + if before is not None: + _params["before"] = _SERIALIZER.query("before", before, "str") + if limit is not None: + _params["limit"] = _SERIALIZER.query("limit", limit, "int") + if order is not None: + _params["order"] = _SERIALIZER.query("order", order, "str") + if agent_name is not None: + _params["agent_name"] = _SERIALIZER.query("agent_name", agent_name, "str") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers @@ -1451,8 +1550,30 @@ def build_beta_evaluation_taxonomies_get_request( # pylint: disable=name-too-lo return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_beta_evaluation_taxonomies_list_request( # pylint: disable=name-too-long - *, input_name: Optional[str] = None, input_type: Optional[str] = None, **kwargs: Any +def build_beta_agent_insight_monitors_create_request(**kwargs: Any) -> HttpRequest: # pylint: disable=name-too-long + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/agent_insight_monitors" + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_beta_agent_insight_monitors_get_request( # pylint: disable=name-too-long + monitor_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -1461,14 +1582,15 @@ def build_beta_evaluation_taxonomies_list_request( # pylint: disable=name-too-l accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/evaluationtaxonomies" + _url = "/agent_insight_monitors/{monitor_id}" + path_format_arguments = { + "monitor_id": _SERIALIZER.url("monitor_id", monitor_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if input_name is not None: - _params["inputName"] = _SERIALIZER.query("input_name", input_name, "str") - if input_type is not None: - _params["inputType"] = _SERIALIZER.query("input_type", input_type, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -1476,16 +1598,16 @@ def build_beta_evaluation_taxonomies_list_request( # pylint: disable=name-too-l return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_beta_evaluation_taxonomies_delete_request( # pylint: disable=name-too-long - name: str, **kwargs: Any +def build_beta_agent_insight_monitors_delete_request( # pylint: disable=name-too-long + monitor_id: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) # Construct URL - _url = "/evaluationtaxonomies/{name}" + _url = "/agent_insight_monitors/{monitor_id}" path_format_arguments = { - "name": _SERIALIZER.url("name", name, "str"), + "monitor_id": _SERIALIZER.url("monitor_id", monitor_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1496,8 +1618,8 @@ def build_beta_evaluation_taxonomies_delete_request( # pylint: disable=name-too return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_beta_evaluation_taxonomies_create_request( # pylint: disable=name-too-long - name: str, **kwargs: Any +def build_beta_agent_insight_monitors_update_request( # pylint: disable=name-too-long + monitor_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -1507,9 +1629,9 @@ def build_beta_evaluation_taxonomies_create_request( # pylint: disable=name-too accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/evaluationtaxonomies/{name}" + _url = "/agent_insight_monitors/{monitor_id}" path_format_arguments = { - "name": _SERIALIZER.url("name", name, "str"), + "monitor_id": _SERIALIZER.url("monitor_id", monitor_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1522,11 +1644,31 @@ def build_beta_evaluation_taxonomies_create_request( # pylint: disable=name-too _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_beta_evaluation_taxonomies_update_request( # pylint: disable=name-too-long - name: str, **kwargs: Any +def build_beta_agent_insight_monitors_reset_request( # pylint: disable=name-too-long + monitor_id: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + # Construct URL + _url = "/agent_insight_monitors/{monitor_id}:reset" + path_format_arguments = { + "monitor_id": _SERIALIZER.url("monitor_id", monitor_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="POST", url=_url, params=_params, **kwargs) + + +def build_beta_agent_insight_monitors_create_run_request( # pylint: disable=name-too-long + monitor_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -1536,9 +1678,9 @@ def build_beta_evaluation_taxonomies_update_request( # pylint: disable=name-too accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/evaluationtaxonomies/{name}" + _url = "/agent_insight_monitors/{monitor_id}/runs" path_format_arguments = { - "name": _SERIALIZER.url("name", name, "str"), + "monitor_id": _SERIALIZER.url("monitor_id", monitor_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1551,14 +1693,18 @@ def build_beta_evaluation_taxonomies_update_request( # pylint: disable=name-too _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_beta_evaluators_list_versions_request( # pylint: disable=name-too-long - name: str, +def build_beta_agent_insight_monitors_list_runs_request( # pylint: disable=name-too-long + monitor_id: str, *, - type: Optional[Union[Literal["builtin"], Literal["custom"], Literal["all"], str]] = None, + after: Optional[str] = None, + before: Optional[str] = None, limit: Optional[int] = None, + order: Optional[Union[str, _models.PageOrder]] = None, + status: Optional[Union[str, _models.JobStatus]] = None, + trigger: Optional[Union[str, _models.AgentInsightRunTrigger]] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -1568,19 +1714,27 @@ def build_beta_evaluators_list_versions_request( # pylint: disable=name-too-lon accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/evaluators/{name}/versions" + _url = "/agent_insight_monitors/{monitor_id}/runs" path_format_arguments = { - "name": _SERIALIZER.url("name", name, "str"), + "monitor_id": _SERIALIZER.url("monitor_id", monitor_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if type is not None: - _params["type"] = _SERIALIZER.query("type", type, "str") + if after is not None: + _params["after"] = _SERIALIZER.query("after", after, "str") + if before is not None: + _params["before"] = _SERIALIZER.query("before", before, "str") if limit is not None: _params["limit"] = _SERIALIZER.query("limit", limit, "int") + if order is not None: + _params["order"] = _SERIALIZER.query("order", order, "str") + if status is not None: + _params["status"] = _SERIALIZER.query("status", status, "str") + if trigger is not None: + _params["trigger"] = _SERIALIZER.query("trigger", trigger, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -1588,11 +1742,8 @@ def build_beta_evaluators_list_versions_request( # pylint: disable=name-too-lon return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_beta_evaluators_list_request( - *, - type: Optional[Union[Literal["builtin"], Literal["custom"], Literal["all"], str]] = None, - limit: Optional[int] = None, - **kwargs: Any +def build_beta_agent_insight_monitors_get_run_request( # pylint: disable=name-too-long + monitor_id: str, run_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -1601,14 +1752,16 @@ def build_beta_evaluators_list_request( accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/evaluators" + _url = "/agent_insight_monitors/{monitor_id}/runs/{run_id}" + path_format_arguments = { + "monitor_id": _SERIALIZER.url("monitor_id", monitor_id, "str"), + "run_id": _SERIALIZER.url("run_id", run_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - if type is not None: - _params["type"] = _SERIALIZER.query("type", type, "str") - if limit is not None: - _params["limit"] = _SERIALIZER.query("limit", limit, "int") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -1616,8 +1769,8 @@ def build_beta_evaluators_list_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_beta_evaluators_get_version_request( # pylint: disable=name-too-long - name: str, version: str, **kwargs: Any +def build_beta_agent_insight_monitors_cancel_run_request( # pylint: disable=name-too-long + monitor_id: str, run_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -1626,10 +1779,10 @@ def build_beta_evaluators_get_version_request( # pylint: disable=name-too-long accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/evaluators/{name}/versions/{version}" + _url = "/agent_insight_monitors/{monitor_id}/runs/{run_id}:cancel" path_format_arguments = { - "name": _SERIALIZER.url("name", name, "str"), - "version": _SERIALIZER.url("version", version, "str"), + "monitor_id": _SERIALIZER.url("monitor_id", monitor_id, "str"), + "run_id": _SERIALIZER.url("run_id", run_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1640,61 +1793,92 @@ def build_beta_evaluators_get_version_request( # pylint: disable=name-too-long # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_beta_evaluators_delete_version_request( # pylint: disable=name-too-long - name: str, version: str, **kwargs: Any +def build_beta_agent_insight_monitors_list_insights_request( # pylint: disable=name-too-long + monitor_id: str, + *, + after: Optional[str] = None, + before: Optional[str] = None, + limit: Optional[int] = None, + order: Optional[Union[str, _models.PageOrder]] = None, + category: Optional[str] = None, + severity: Optional[Union[str, _models.AgentInsightSeverity]] = None, + status: Optional[Union[str, _models.AgentInsightStatus]] = None, + include_details: Optional[bool] = None, + **kwargs: Any ) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + accept = _headers.pop("Accept", "application/json") + # Construct URL - _url = "/evaluators/{name}/versions/{version}" + _url = "/agent_insight_monitors/{monitor_id}/insights" path_format_arguments = { - "name": _SERIALIZER.url("name", name, "str"), - "version": _SERIALIZER.url("version", version, "str"), + "monitor_id": _SERIALIZER.url("monitor_id", monitor_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters + if after is not None: + _params["after"] = _SERIALIZER.query("after", after, "str") + if before is not None: + _params["before"] = _SERIALIZER.query("before", before, "str") + if limit is not None: + _params["limit"] = _SERIALIZER.query("limit", limit, "int") + if order is not None: + _params["order"] = _SERIALIZER.query("order", order, "str") + if category is not None: + _params["category"] = _SERIALIZER.query("category", category, "str") + if severity is not None: + _params["severity"] = _SERIALIZER.query("severity", severity, "str") + if status is not None: + _params["status"] = _SERIALIZER.query("status", status, "str") + if include_details is not None: + _params["include_details"] = _SERIALIZER.query("include_details", include_details, "bool") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_beta_evaluators_create_version_request( # pylint: disable=name-too-long - name: str, **kwargs: Any + +def build_beta_agent_insight_monitors_get_insight_request( # pylint: disable=name-too-long + monitor_id: str, insight_id: str, *, include_details: Optional[bool] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/evaluators/{name}/versions" + _url = "/agent_insight_monitors/{monitor_id}/insights/{insight_id}" path_format_arguments = { - "name": _SERIALIZER.url("name", name, "str"), + "monitor_id": _SERIALIZER.url("monitor_id", monitor_id, "str"), + "insight_id": _SERIALIZER.url("insight_id", insight_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters + if include_details is not None: + _params["include_details"] = _SERIALIZER.query("include_details", include_details, "bool") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_beta_evaluators_update_version_request( # pylint: disable=name-too-long - name: str, version: str, **kwargs: Any +def build_beta_agent_insight_monitors_update_insight_request( # pylint: disable=name-too-long + monitor_id: str, insight_id: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -1704,10 +1888,10 @@ def build_beta_evaluators_update_version_request( # pylint: disable=name-too-lo accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/evaluators/{name}/versions/{version}" + _url = "/agent_insight_monitors/{monitor_id}/insights/{insight_id}" path_format_arguments = { - "name": _SERIALIZER.url("name", name, "str"), - "version": _SERIALIZER.url("version", version, "str"), + "monitor_id": _SERIALIZER.url("monitor_id", monitor_id, "str"), + "insight_id": _SERIALIZER.url("insight_id", insight_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1723,21 +1907,19 @@ def build_beta_evaluators_update_version_request( # pylint: disable=name-too-lo return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_beta_evaluators_pending_upload_request( # pylint: disable=name-too-long - name: str, version: str, **kwargs: Any -) -> HttpRequest: +def build_beta_evaluation_taxonomies_get_request( # pylint: disable=name-too-long + name: str, **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/evaluators/{name}/versions/{version}/startPendingUpload" + _url = "/evaluationtaxonomies/{name}" path_format_arguments = { "name": _SERIALIZER.url("name", name, "str"), - "version": _SERIALIZER.url("version", version, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1746,15 +1928,58 @@ def build_beta_evaluators_pending_upload_request( # pylint: disable=name-too-lo _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if content_type is not None: - _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_beta_evaluators_get_credentials_request( # pylint: disable=name-too-long - name: str, version: str, **kwargs: Any +def build_beta_evaluation_taxonomies_list_request( # pylint: disable=name-too-long + *, input_name: Optional[str] = None, input_type: Optional[str] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/evaluationtaxonomies" + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if input_name is not None: + _params["inputName"] = _SERIALIZER.query("input_name", input_name, "str") + if input_type is not None: + _params["inputType"] = _SERIALIZER.query("input_type", input_type, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_beta_evaluation_taxonomies_delete_request( # pylint: disable=name-too-long + name: str, **kwargs: Any +) -> HttpRequest: + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + # Construct URL + _url = "/evaluationtaxonomies/{name}" + path_format_arguments = { + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_beta_evaluation_taxonomies_create_request( # pylint: disable=name-too-long + name: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -1764,10 +1989,9 @@ def build_beta_evaluators_get_credentials_request( # pylint: disable=name-too-l accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/evaluators/{name}/versions/{version}/credentials" + _url = "/evaluationtaxonomies/{name}" path_format_arguments = { "name": _SERIALIZER.url("name", name, "str"), - "version": _SERIALIZER.url("version", version, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1780,11 +2004,11 @@ def build_beta_evaluators_get_credentials_request( # pylint: disable=name-too-l _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PUT", url=_url, params=_params, headers=_headers, **kwargs) -def build_beta_evaluators_create_generation_job_request( # pylint: disable=name-too-long - *, operation_id: Optional[str] = None, **kwargs: Any +def build_beta_evaluation_taxonomies_update_request( # pylint: disable=name-too-long + name: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -1794,23 +2018,30 @@ def build_beta_evaluators_create_generation_job_request( # pylint: disable=name accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/evaluator_generation_jobs" + _url = "/evaluationtaxonomies/{name}" + path_format_arguments = { + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if operation_id is not None: - _headers["Operation-Id"] = _SERIALIZER.header("operation_id", operation_id, "str") if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_beta_evaluators_get_generation_job_request( # pylint: disable=name-too-long - job_id: str, **kwargs: Any +def build_beta_evaluators_list_versions_request( # pylint: disable=name-too-long + name: str, + *, + type: Optional[Union[Literal["builtin"], Literal["custom"], Literal["all"], str]] = None, + limit: Optional[int] = None, + **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -1819,15 +2050,19 @@ def build_beta_evaluators_get_generation_job_request( # pylint: disable=name-to accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/evaluator_generation_jobs/{jobId}" + _url = "/evaluators/{name}/versions" path_format_arguments = { - "jobId": _SERIALIZER.url("job_id", job_id, "str"), + "name": _SERIALIZER.url("name", name, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if type is not None: + _params["type"] = _SERIALIZER.query("type", type, "str") + if limit is not None: + _params["limit"] = _SERIALIZER.query("limit", limit, "int") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -1835,12 +2070,10 @@ def build_beta_evaluators_get_generation_job_request( # pylint: disable=name-to return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_beta_evaluators_list_generation_jobs_request( # pylint: disable=name-too-long +def build_beta_evaluators_list_request( *, + type: Optional[Union[Literal["builtin"], Literal["custom"], Literal["all"], str]] = None, limit: Optional[int] = None, - order: Optional[Union[str, _models.PageOrder]] = None, - after: Optional[str] = None, - before: Optional[str] = None, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) @@ -1850,18 +2083,14 @@ def build_beta_evaluators_list_generation_jobs_request( # pylint: disable=name- accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/evaluator_generation_jobs" + _url = "/evaluators" # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + if type is not None: + _params["type"] = _SERIALIZER.query("type", type, "str") if limit is not None: _params["limit"] = _SERIALIZER.query("limit", limit, "int") - if order is not None: - _params["order"] = _SERIALIZER.query("order", order, "str") - if after is not None: - _params["after"] = _SERIALIZER.query("after", after, "str") - if before is not None: - _params["before"] = _SERIALIZER.query("before", before, "str") - _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -1869,8 +2098,8 @@ def build_beta_evaluators_list_generation_jobs_request( # pylint: disable=name- return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_beta_evaluators_cancel_generation_job_request( # pylint: disable=name-too-long - job_id: str, **kwargs: Any +def build_beta_evaluators_get_version_request( # pylint: disable=name-too-long + name: str, version: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -1879,9 +2108,10 @@ def build_beta_evaluators_cancel_generation_job_request( # pylint: disable=name accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/evaluator_generation_jobs/{jobId}:cancel" + _url = "/evaluators/{name}/versions/{version}" path_format_arguments = { - "jobId": _SERIALIZER.url("job_id", job_id, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "version": _SERIALIZER.url("version", version, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1892,19 +2122,20 @@ def build_beta_evaluators_cancel_generation_job_request( # pylint: disable=name # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_beta_evaluators_delete_generation_job_request( # pylint: disable=name-too-long - job_id: str, **kwargs: Any +def build_beta_evaluators_delete_version_request( # pylint: disable=name-too-long + name: str, version: str, **kwargs: Any ) -> HttpRequest: _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) # Construct URL - _url = "/evaluator_generation_jobs/{jobId}" + _url = "/evaluators/{name}/versions/{version}" path_format_arguments = { - "jobId": _SERIALIZER.url("job_id", job_id, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "version": _SERIALIZER.url("version", version, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -1915,7 +2146,9 @@ def build_beta_evaluators_delete_generation_job_request( # pylint: disable=name return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) -def build_beta_insights_generate_request(**kwargs: Any) -> HttpRequest: +def build_beta_evaluators_create_version_request( # pylint: disable=name-too-long + name: str, **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -1924,18 +2157,17 @@ def build_beta_insights_generate_request(**kwargs: Any) -> HttpRequest: accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/insights" + _url = "/evaluators/{name}/versions" + path_format_arguments = { + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers - if "Repeatability-Request-ID" not in _headers: - _headers["Repeatability-Request-ID"] = str(uuid.uuid4()) - if "Repeatability-First-Sent" not in _headers: - _headers["Repeatability-First-Sent"] = _SERIALIZER.serialize_data( - datetime.datetime.now(datetime.timezone.utc), "rfc-1123" - ) if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -1943,72 +2175,69 @@ def build_beta_insights_generate_request(**kwargs: Any) -> HttpRequest: return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_beta_insights_get_request( - insight_id: str, *, include_coordinates: Optional[bool] = None, **kwargs: Any +def build_beta_evaluators_update_version_request( # pylint: disable=name-too-long + name: str, version: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/insights/{id}" + _url = "/evaluators/{name}/versions/{version}" path_format_arguments = { - "id": _SERIALIZER.url("insight_id", insight_id, "str"), + "name": _SERIALIZER.url("name", name, "str"), + "version": _SERIALIZER.url("version", version, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if include_coordinates is not None: - _params["includeCoordinates"] = _SERIALIZER.query("include_coordinates", include_coordinates, "bool") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="PATCH", url=_url, params=_params, headers=_headers, **kwargs) -def build_beta_insights_list_request( - *, - type: Optional[Union[str, _models.InsightType]] = None, - eval_id: Optional[str] = None, - run_id: Optional[str] = None, - agent_name: Optional[str] = None, - include_coordinates: Optional[bool] = None, - **kwargs: Any +def build_beta_evaluators_pending_upload_request( # pylint: disable=name-too-long + name: str, version: str, **kwargs: Any ) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/insights" + _url = "/evaluators/{name}/versions/{version}/startPendingUpload" + path_format_arguments = { + "name": _SERIALIZER.url("name", name, "str"), + "version": _SERIALIZER.url("version", version, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters - if type is not None: - _params["type"] = _SERIALIZER.query("type", type, "str") - if eval_id is not None: - _params["evalId"] = _SERIALIZER.query("eval_id", eval_id, "str") - if run_id is not None: - _params["runId"] = _SERIALIZER.query("run_id", run_id, "str") - if agent_name is not None: - _params["agentName"] = _SERIALIZER.query("agent_name", agent_name, "str") - if include_coordinates is not None: - _params["includeCoordinates"] = _SERIALIZER.query("include_coordinates", include_coordinates, "bool") _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_beta_memory_stores_create_request(**kwargs: Any) -> HttpRequest: +def build_beta_evaluators_get_credentials_request( # pylint: disable=name-too-long + name: str, version: str, **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -2017,7 +2246,13 @@ def build_beta_memory_stores_create_request(**kwargs: Any) -> HttpRequest: accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/memory_stores" + _url = "/evaluators/{name}/versions/{version}/credentials" + path_format_arguments = { + "name": _SERIALIZER.url("name", name, "str"), + "version": _SERIALIZER.url("version", version, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") @@ -2030,7 +2265,9 @@ def build_beta_memory_stores_create_request(**kwargs: Any) -> HttpRequest: return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_beta_memory_stores_update_request(name: str, **kwargs: Any) -> HttpRequest: +def build_beta_evaluators_create_generation_job_request( # pylint: disable=name-too-long + *, operation_id: Optional[str] = None, **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -2039,17 +2276,14 @@ def build_beta_memory_stores_update_request(name: str, **kwargs: Any) -> HttpReq accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/memory_stores/{name}" - path_format_arguments = { - "name": _SERIALIZER.url("name", name, "str"), - } - - _url: str = _url.format(**path_format_arguments) # type: ignore + _url = "/evaluator_generation_jobs" # Construct parameters _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") # Construct headers + if operation_id is not None: + _headers["Operation-Id"] = _SERIALIZER.header("operation_id", operation_id, "str") if content_type is not None: _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") @@ -2057,7 +2291,9 @@ def build_beta_memory_stores_update_request(name: str, **kwargs: Any) -> HttpReq return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_beta_memory_stores_get_request(name: str, **kwargs: Any) -> HttpRequest: +def build_beta_evaluators_get_generation_job_request( # pylint: disable=name-too-long + job_id: str, **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -2065,9 +2301,9 @@ def build_beta_memory_stores_get_request(name: str, **kwargs: Any) -> HttpReques accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/memory_stores/{name}" + _url = "/evaluator_generation_jobs/{jobId}" path_format_arguments = { - "name": _SERIALIZER.url("name", name, "str"), + "jobId": _SERIALIZER.url("job_id", job_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -2081,7 +2317,7 @@ def build_beta_memory_stores_get_request(name: str, **kwargs: Any) -> HttpReques return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_beta_memory_stores_list_request( +def build_beta_evaluators_list_generation_jobs_request( # pylint: disable=name-too-long *, limit: Optional[int] = None, order: Optional[Union[str, _models.PageOrder]] = None, @@ -2096,7 +2332,7 @@ def build_beta_memory_stores_list_request( accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/memory_stores" + _url = "/evaluator_generation_jobs" # Construct parameters if limit is not None: @@ -2115,7 +2351,9 @@ def build_beta_memory_stores_list_request( return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) -def build_beta_memory_stores_delete_request(name: str, **kwargs: Any) -> HttpRequest: +def build_beta_evaluators_cancel_generation_job_request( # pylint: disable=name-too-long + job_id: str, **kwargs: Any +) -> HttpRequest: _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) @@ -2123,9 +2361,9 @@ def build_beta_memory_stores_delete_request(name: str, **kwargs: Any) -> HttpReq accept = _headers.pop("Accept", "application/json") # Construct URL - _url = "/memory_stores/{name}" + _url = "/evaluator_generation_jobs/{jobId}:cancel" path_format_arguments = { - "name": _SERIALIZER.url("name", name, "str"), + "jobId": _SERIALIZER.url("job_id", job_id, "str"), } _url: str = _url.format(**path_format_arguments) # type: ignore @@ -2136,21 +2374,265 @@ def build_beta_memory_stores_delete_request(name: str, **kwargs: Any) -> HttpReq # Construct headers _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") - return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) -def build_beta_memory_stores_search_memories_request( # pylint: disable=name-too-long - name: str, **kwargs: Any +def build_beta_evaluators_delete_generation_job_request( # pylint: disable=name-too-long + job_id: str, **kwargs: Any ) -> HttpRequest: - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) - accept = _headers.pop("Accept", "application/json") - # Construct URL - _url = "/memory_stores/{name}:search_memories" + _url = "/evaluator_generation_jobs/{jobId}" + path_format_arguments = { + "jobId": _SERIALIZER.url("job_id", job_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, **kwargs) + + +def build_beta_insights_generate_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/insights" + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if "Repeatability-Request-ID" not in _headers: + _headers["Repeatability-Request-ID"] = str(uuid.uuid4()) + if "Repeatability-First-Sent" not in _headers: + _headers["Repeatability-First-Sent"] = _SERIALIZER.serialize_data( + datetime.datetime.now(datetime.timezone.utc), "rfc-1123" + ) + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_beta_insights_get_request( + insight_id: str, *, include_coordinates: Optional[bool] = None, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/insights/{id}" + path_format_arguments = { + "id": _SERIALIZER.url("insight_id", insight_id, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + if include_coordinates is not None: + _params["includeCoordinates"] = _SERIALIZER.query("include_coordinates", include_coordinates, "bool") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_beta_insights_list_request( + *, + type: Optional[Union[str, _models.InsightType]] = None, + eval_id: Optional[str] = None, + run_id: Optional[str] = None, + agent_name: Optional[str] = None, + include_coordinates: Optional[bool] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/insights" + + # Construct parameters + if type is not None: + _params["type"] = _SERIALIZER.query("type", type, "str") + if eval_id is not None: + _params["evalId"] = _SERIALIZER.query("eval_id", eval_id, "str") + if run_id is not None: + _params["runId"] = _SERIALIZER.query("run_id", run_id, "str") + if agent_name is not None: + _params["agentName"] = _SERIALIZER.query("agent_name", agent_name, "str") + if include_coordinates is not None: + _params["includeCoordinates"] = _SERIALIZER.query("include_coordinates", include_coordinates, "bool") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_beta_memory_stores_create_request(**kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/memory_stores" + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_beta_memory_stores_update_request(name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/memory_stores/{name}" + path_format_arguments = { + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + if content_type is not None: + _headers["Content-Type"] = _SERIALIZER.header("content_type", content_type, "str") + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="POST", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_beta_memory_stores_get_request(name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/memory_stores/{name}" + path_format_arguments = { + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_beta_memory_stores_list_request( + *, + limit: Optional[int] = None, + order: Optional[Union[str, _models.PageOrder]] = None, + after: Optional[str] = None, + before: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/memory_stores" + + # Construct parameters + if limit is not None: + _params["limit"] = _SERIALIZER.query("limit", limit, "int") + if order is not None: + _params["order"] = _SERIALIZER.query("order", order, "str") + if after is not None: + _params["after"] = _SERIALIZER.query("after", after, "str") + if before is not None: + _params["before"] = _SERIALIZER.query("before", before, "str") + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="GET", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_beta_memory_stores_delete_request(name: str, **kwargs: Any) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/memory_stores/{name}" + path_format_arguments = { + "name": _SERIALIZER.url("name", name, "str"), + } + + _url: str = _url.format(**path_format_arguments) # type: ignore + + # Construct parameters + _params["api-version"] = _SERIALIZER.query("api_version", api_version, "str") + + # Construct headers + _headers["Accept"] = _SERIALIZER.header("accept", accept, "str") + + return HttpRequest(method="DELETE", url=_url, params=_params, headers=_headers, **kwargs) + + +def build_beta_memory_stores_search_memories_request( # pylint: disable=name-too-long + name: str, **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + api_version: str = kwargs.pop("api_version", _params.pop("api-version", "v1")) + accept = _headers.pop("Accept", "application/json") + + # Construct URL + _url = "/memory_stores/{name}:search_memories" path_format_arguments = { "name": _SERIALIZER.url("name", name, "str"), } @@ -3615,6 +4097,9 @@ def __init__(self, *args, **kwargs) -> None: self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + self.agent_insight_monitors = BetaAgentInsightMonitorsOperations( + self._client, self._config, self._serialize, self._deserialize + ) self.evaluation_taxonomies = BetaEvaluationTaxonomiesOperations( self._client, self._config, self._serialize, self._deserialize ) @@ -3896,6 +4381,7 @@ def create_version( metadata: Optional[dict[str, str]] = None, description: Optional[str] = None, blueprint_reference: Optional[_models.AgentBlueprintReference] = None, + digital_worker_type: Optional[Union[str, _models.DigitalWorkerType]] = None, draft: Optional[bool] = None, **kwargs: Any ) -> _models.AgentVersionDetails: @@ -3910,8 +4396,8 @@ def create_version( * Can contain hyphens in the middle * Must not exceed 63 characters. Required. :type agent_name: str - :keyword definition: The agent definition. This can be a workflow, hosted agent, or a simple - agent definition. Required. + :keyword definition: The agent definition. This can be a prompt, workflow, hosted, external, or + voice agent definition. Required. :paramtype definition: ~azure.ai.projects.models.AgentDefinition :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". @@ -3927,6 +4413,9 @@ def create_version( :paramtype description: str :keyword blueprint_reference: The blueprint reference for the agent. Default value is None. :paramtype blueprint_reference: ~azure.ai.projects.models.AgentBlueprintReference + :keyword digital_worker_type: (Preview) The type of digital worker (previously known as + ``autopilot``). If omitted, it is not a digital worker. "m365" Default value is None. + :paramtype digital_worker_type: str or ~azure.ai.projects.models.DigitalWorkerType :keyword draft: (Preview) Whether this agent version is a draft (candidate) rather than a release. The service defaults to ``false`` if a value is not specified by the caller. Draft versions are recorded but excluded from default 'latest' resolution and are not auto-promoted. @@ -3997,6 +4486,7 @@ def create_version( metadata: Optional[dict[str, str]] = None, description: Optional[str] = None, blueprint_reference: Optional[_models.AgentBlueprintReference] = None, + digital_worker_type: Optional[Union[str, _models.DigitalWorkerType]] = None, draft: Optional[bool] = None, **kwargs: Any ) -> _models.AgentVersionDetails: @@ -4013,8 +4503,8 @@ def create_version( :type agent_name: str :param body: Is either a JSON type or a IO[bytes] type. Required. :type body: JSON or IO[bytes] - :keyword definition: The agent definition. This can be a workflow, hosted agent, or a simple - agent definition. Required. + :keyword definition: The agent definition. This can be a prompt, workflow, hosted, external, or + voice agent definition. Required. :paramtype definition: ~azure.ai.projects.models.AgentDefinition :keyword metadata: Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured @@ -4027,6 +4517,9 @@ def create_version( :paramtype description: str :keyword blueprint_reference: The blueprint reference for the agent. Default value is None. :paramtype blueprint_reference: ~azure.ai.projects.models.AgentBlueprintReference + :keyword digital_worker_type: (Preview) The type of digital worker (previously known as + ``autopilot``). If omitted, it is not a digital worker. "m365" Default value is None. + :paramtype digital_worker_type: str or ~azure.ai.projects.models.DigitalWorkerType :keyword draft: (Preview) Whether this agent version is a draft (candidate) rather than a release. The service defaults to ``false`` if a value is not specified by the caller. Draft versions are recorded but excluded from default 'latest' resolution and are not auto-promoted. @@ -4057,6 +4550,7 @@ def create_version( "blueprint_reference": blueprint_reference, "definition": definition, "description": description, + "digital_worker_type": digital_worker_type, "draft": draft, "metadata": metadata, } @@ -5607,91 +6101,271 @@ def get_session_log_stream( return deserialized # type: ignore @overload - def upload_session_file( + def publish_to_microsoft365( self, agent_name: str, - session_id: str, - content: bytes, *, - path: str, - content_type: str = "application/octet-stream", + publish_scope: Union[str, _models.Microsoft365PublishScope], + content_type: str = "application/json", + agent_display_name: Optional[str] = None, + bot_service_arm_id: Optional[str] = None, + publish_as_autopilot: Optional[bool] = None, + access_boundaries: Optional[List[Union[str, _models.ActivityProtocolAccessBoundary]]] = None, + optional_permission_scopes: Optional[List[_models.Microsoft365PermissionScopes]] = None, + can_respond_without_mention: Optional[bool] = None, + app_version: Optional[str] = None, + short_description: Optional[str] = None, + full_description: Optional[str] = None, + developer_name: Optional[str] = None, + developer_website_url: Optional[str] = None, + privacy_url: Optional[str] = None, + terms_of_use_url: Optional[str] = None, + color_icon_base64: Optional[str] = None, + outline_icon_base64: Optional[str] = None, **kwargs: Any - ) -> _models.SessionFileWriteResult: - """Upload a session file. + ) -> _models.Microsoft365PublishResult: + """Publish an agent to Microsoft 365. - Uploads binary file content to the specified path in the session sandbox. The service stores - the file relative to the session home directory and rejects payloads larger than 50 MB. + Publishes a Foundry agent to Microsoft 365 / Microsoft Teams and returns the published title + and Teams app ids. - :param agent_name: The name of the agent. Required. + :param agent_name: The name of the agent to publish. Required. :type agent_name: str - :param session_id: The session ID. Required. - :type session_id: str - :param content: Required. - :type content: bytes - :keyword path: The destination file path within the sandbox, relative to the session home - directory. Required. - :paramtype path: str - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/octet-stream". + :keyword publish_scope: Publish scope for the Teams app. Known values are: "Personal", + "Shared", and "Tenant". Required. + :paramtype publish_scope: str or ~azure.ai.projects.models.Microsoft365PublishScope + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". :paramtype content_type: str - :return: SessionFileWriteResult. The SessionFileWriteResult is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.SessionFileWriteResult + :keyword agent_display_name: Display name used as the published Teams app name. When omitted, + the agent name from the route is + used. Default value is None. + :paramtype agent_display_name: str + :keyword bot_service_arm_id: ARM resource id of the Azure Bot Service that fronts this agent in + Microsoft Teams. Required for + workspaces on the default bot-based Teams backend; optional for workspaces on the API-based + backend. + Must not be supplied when ``publishAsAutopilot`` is true. Default value is None. + :paramtype bot_service_arm_id: str + :keyword publish_as_autopilot: When true, the agent is published as an autopilot (digital + worker) agent: the bot id is taken from + the agent's blueprint identity and the generated Teams manifest is marked as a digital worker. + Default value is None. + :paramtype publish_as_autopilot: bool + :keyword access_boundaries: Activity-protocol access boundaries to apply to the agent when + publishing as an autopilot agent. + An empty list clears the existing boundaries. When omitted, the existing boundaries are left + unchanged. Default value is None. + :paramtype access_boundaries: list[str or + ~azure.ai.projects.models.ActivityProtocolAccessBoundary] + :keyword optional_permission_scopes: Exact selection of delegated permission scopes to grant to + the autopilot blueprint. May only be + supplied when ``publishAsAutopilot`` is true. When omitted or empty, the platform's default + permission set is used. Mandatory platform permissions are always granted and are not affected + by + this value. Default value is None. + :paramtype optional_permission_scopes: + list[~azure.ai.projects.models.Microsoft365PermissionScopes] + :keyword can_respond_without_mention: Controls how the published agent responds to Teams + messages: when true it responds to all messages + on its surfaces, when false only when it is at-mentioned. When omitted, the agent's existing + Teams + message-notification setting is left unchanged. Default value is None. + :paramtype can_respond_without_mention: bool + :keyword app_version: App version (for example ``1.2.3``) written into the Teams manifest. May + contain only digits and + periods, must not start with ``0``, and must end with a digit. When omitted, a platform + default is + used. Default value is None. + :paramtype app_version: str + :keyword short_description: Short, one-line description shown in the Teams app listing. Default + value is None. + :paramtype short_description: str + :keyword full_description: Full description shown on the Teams app details page. Default value + is None. + :paramtype full_description: str + :keyword developer_name: Display name of the developer / publisher shown in the Teams app + listing. Default value is None. + :paramtype developer_name: str + :keyword developer_website_url: Developer / publisher website URL shown in the Teams app + listing. Must be an https URL. Default value is None. + :paramtype developer_website_url: str + :keyword privacy_url: Privacy policy URL shown in the Teams app listing. Must be an http or + https URL. Default value is None. + :paramtype privacy_url: str + :keyword terms_of_use_url: Terms-of-use URL shown in the Teams app listing. Default value is + None. + :paramtype terms_of_use_url: str + :keyword color_icon_base64: Optional base64-encoded PNG used as the color (full-bleed) icon in + the Teams app package. Must be a + 192x192 PNG (perfect square, no border or rounded corners). Max 1 MB after decode. When + omitted, the + platform default color icon is used. Default value is None. + :paramtype color_icon_base64: str + :keyword outline_icon_base64: Optional base64-encoded PNG used as the outline icon in the Teams + app package. Must be a 32x32 PNG. + Max 1 MB after decode. When omitted, the platform default outline icon is used. Default value + is None. + :paramtype outline_icon_base64: str + :return: Microsoft365PublishResult. The Microsoft365PublishResult is compatible with + MutableMapping + :rtype: ~azure.ai.projects.models.Microsoft365PublishResult :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def upload_session_file( - self, - agent_name: str, - session_id: str, - content: IO[bytes], - *, - path: str, - content_type: str = "application/octet-stream", - **kwargs: Any - ) -> _models.SessionFileWriteResult: - """Upload a session file. + def publish_to_microsoft365( + self, agent_name: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.Microsoft365PublishResult: + """Publish an agent to Microsoft 365. - Uploads binary file content to the specified path in the session sandbox. The service stores - the file relative to the session home directory and rejects payloads larger than 50 MB. + Publishes a Foundry agent to Microsoft 365 / Microsoft Teams and returns the published title + and Teams app ids. - :param agent_name: The name of the agent. Required. + :param agent_name: The name of the agent to publish. Required. :type agent_name: str - :param session_id: The session ID. Required. - :type session_id: str - :param content: Required. - :type content: IO[bytes] - :keyword path: The destination file path within the sandbox, relative to the session home - directory. Required. - :paramtype path: str + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Microsoft365PublishResult. The Microsoft365PublishResult is compatible with + MutableMapping + :rtype: ~azure.ai.projects.models.Microsoft365PublishResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def publish_to_microsoft365( + self, agent_name: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.Microsoft365PublishResult: + """Publish an agent to Microsoft 365. + + Publishes a Foundry agent to Microsoft 365 / Microsoft Teams and returns the published title + and Teams app ids. + + :param agent_name: The name of the agent to publish. Required. + :type agent_name: str + :param body: Required. + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/octet-stream". + Default value is "application/json". :paramtype content_type: str - :return: SessionFileWriteResult. The SessionFileWriteResult is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.SessionFileWriteResult + :return: Microsoft365PublishResult. The Microsoft365PublishResult is compatible with + MutableMapping + :rtype: ~azure.ai.projects.models.Microsoft365PublishResult :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def upload_session_file( - self, agent_name: str, session_id: str, content: Union[bytes, IO[bytes]], *, path: str, **kwargs: Any - ) -> _models.SessionFileWriteResult: - """Upload a session file. + def publish_to_microsoft365( # pylint: disable=too-many-locals + self, + agent_name: str, + body: Union[JSON, IO[bytes]] = _Unset, + *, + publish_scope: Union[str, _models.Microsoft365PublishScope] = _Unset, + agent_display_name: Optional[str] = None, + bot_service_arm_id: Optional[str] = None, + publish_as_autopilot: Optional[bool] = None, + access_boundaries: Optional[List[Union[str, _models.ActivityProtocolAccessBoundary]]] = None, + optional_permission_scopes: Optional[List[_models.Microsoft365PermissionScopes]] = None, + can_respond_without_mention: Optional[bool] = None, + app_version: Optional[str] = None, + short_description: Optional[str] = None, + full_description: Optional[str] = None, + developer_name: Optional[str] = None, + developer_website_url: Optional[str] = None, + privacy_url: Optional[str] = None, + terms_of_use_url: Optional[str] = None, + color_icon_base64: Optional[str] = None, + outline_icon_base64: Optional[str] = None, + **kwargs: Any + ) -> _models.Microsoft365PublishResult: + """Publish an agent to Microsoft 365. - Uploads binary file content to the specified path in the session sandbox. The service stores - the file relative to the session home directory and rejects payloads larger than 50 MB. + Publishes a Foundry agent to Microsoft 365 / Microsoft Teams and returns the published title + and Teams app ids. - :param agent_name: The name of the agent. Required. + :param agent_name: The name of the agent to publish. Required. :type agent_name: str - :param session_id: The session ID. Required. - :type session_id: str - :param content: Is either a bytes type or a IO[bytes] type. Required. - :type content: bytes or IO[bytes] - :keyword path: The destination file path within the sandbox, relative to the session home - directory. Required. - :paramtype path: str - :return: SessionFileWriteResult. The SessionFileWriteResult is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.SessionFileWriteResult + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :keyword publish_scope: Publish scope for the Teams app. Known values are: "Personal", + "Shared", and "Tenant". Required. + :paramtype publish_scope: str or ~azure.ai.projects.models.Microsoft365PublishScope + :keyword agent_display_name: Display name used as the published Teams app name. When omitted, + the agent name from the route is + used. Default value is None. + :paramtype agent_display_name: str + :keyword bot_service_arm_id: ARM resource id of the Azure Bot Service that fronts this agent in + Microsoft Teams. Required for + workspaces on the default bot-based Teams backend; optional for workspaces on the API-based + backend. + Must not be supplied when ``publishAsAutopilot`` is true. Default value is None. + :paramtype bot_service_arm_id: str + :keyword publish_as_autopilot: When true, the agent is published as an autopilot (digital + worker) agent: the bot id is taken from + the agent's blueprint identity and the generated Teams manifest is marked as a digital worker. + Default value is None. + :paramtype publish_as_autopilot: bool + :keyword access_boundaries: Activity-protocol access boundaries to apply to the agent when + publishing as an autopilot agent. + An empty list clears the existing boundaries. When omitted, the existing boundaries are left + unchanged. Default value is None. + :paramtype access_boundaries: list[str or + ~azure.ai.projects.models.ActivityProtocolAccessBoundary] + :keyword optional_permission_scopes: Exact selection of delegated permission scopes to grant to + the autopilot blueprint. May only be + supplied when ``publishAsAutopilot`` is true. When omitted or empty, the platform's default + permission set is used. Mandatory platform permissions are always granted and are not affected + by + this value. Default value is None. + :paramtype optional_permission_scopes: + list[~azure.ai.projects.models.Microsoft365PermissionScopes] + :keyword can_respond_without_mention: Controls how the published agent responds to Teams + messages: when true it responds to all messages + on its surfaces, when false only when it is at-mentioned. When omitted, the agent's existing + Teams + message-notification setting is left unchanged. Default value is None. + :paramtype can_respond_without_mention: bool + :keyword app_version: App version (for example ``1.2.3``) written into the Teams manifest. May + contain only digits and + periods, must not start with ``0``, and must end with a digit. When omitted, a platform + default is + used. Default value is None. + :paramtype app_version: str + :keyword short_description: Short, one-line description shown in the Teams app listing. Default + value is None. + :paramtype short_description: str + :keyword full_description: Full description shown on the Teams app details page. Default value + is None. + :paramtype full_description: str + :keyword developer_name: Display name of the developer / publisher shown in the Teams app + listing. Default value is None. + :paramtype developer_name: str + :keyword developer_website_url: Developer / publisher website URL shown in the Teams app + listing. Must be an https URL. Default value is None. + :paramtype developer_website_url: str + :keyword privacy_url: Privacy policy URL shown in the Teams app listing. Must be an http or + https URL. Default value is None. + :paramtype privacy_url: str + :keyword terms_of_use_url: Terms-of-use URL shown in the Teams app listing. Default value is + None. + :paramtype terms_of_use_url: str + :keyword color_icon_base64: Optional base64-encoded PNG used as the color (full-bleed) icon in + the Teams app package. Must be a + 192x192 PNG (perfect square, no border or rounded corners). Max 1 MB after decode. When + omitted, the + platform default color icon is used. Default value is None. + :paramtype color_icon_base64: str + :keyword outline_icon_base64: Optional base64-encoded PNG used as the outline icon in the Teams + app package. Must be a 32x32 PNG. + Max 1 MB after decode. When omitted, the platform default outline icon is used. Default value + is None. + :paramtype outline_icon_base64: str + :return: Microsoft365PublishResult. The Microsoft365PublishResult is compatible with + MutableMapping + :rtype: ~azure.ai.projects.models.Microsoft365PublishResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -5706,15 +6380,39 @@ def upload_session_file( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.SessionFileWriteResult] = kwargs.pop("cls", None) + cls: ClsType[_models.Microsoft365PublishResult] = kwargs.pop("cls", None) - content_type = content_type or "application/octet-stream" - _content = content + if body is _Unset: + if publish_scope is _Unset: + raise TypeError("missing required argument: publish_scope") + body = { + "accessBoundaries": access_boundaries, + "agentDisplayName": agent_display_name, + "appVersion": app_version, + "botServiceArmId": bot_service_arm_id, + "canRespondWithoutMention": can_respond_without_mention, + "colorIconBase64": color_icon_base64, + "developerName": developer_name, + "developerWebsiteUrl": developer_website_url, + "fullDescription": full_description, + "optionalPermissionScopes": optional_permission_scopes, + "outlineIconBase64": outline_icon_base64, + "privacyUrl": privacy_url, + "publishAsAutopilot": publish_as_autopilot, + "publishScope": publish_scope, + "shortDescription": short_description, + "termsOfUseUrl": terms_of_use_url, + } + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/json" + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_agents_upload_session_file_request( + _request = build_agents_publish_to_microsoft365_request( agent_name=agent_name, - session_id=session_id, - path=path, content_type=content_type, api_version=self._config.api_version, content=_content, @@ -5734,7 +6432,7 @@ def upload_session_file( response = pipeline_response.http_response - if response.status_code not in [201]: + if response.status_code not in [200]: if _stream: try: response.read() # Load the body in memory and close the socket @@ -5750,27 +6448,273 @@ def upload_session_file( if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.SessionFileWriteResult, response.json()) + deserialized = _deserialize(_models.Microsoft365PublishResult, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore + @overload + def get_microsoft365_package( + self, + agent_name: str, + *, + publish_scope: Union[str, _models.Microsoft365PublishScope], + content_type: str = "application/json", + agent_display_name: Optional[str] = None, + bot_service_arm_id: Optional[str] = None, + publish_as_autopilot: Optional[bool] = None, + access_boundaries: Optional[List[Union[str, _models.ActivityProtocolAccessBoundary]]] = None, + optional_permission_scopes: Optional[List[_models.Microsoft365PermissionScopes]] = None, + can_respond_without_mention: Optional[bool] = None, + app_version: Optional[str] = None, + short_description: Optional[str] = None, + full_description: Optional[str] = None, + developer_name: Optional[str] = None, + developer_website_url: Optional[str] = None, + privacy_url: Optional[str] = None, + terms_of_use_url: Optional[str] = None, + color_icon_base64: Optional[str] = None, + outline_icon_base64: Optional[str] = None, + **kwargs: Any + ) -> Iterator[bytes]: + """Generate a Microsoft 365 app package. + + Generates the Microsoft Teams app package (zip) for a Foundry agent from the supplied publish + request, without publishing it. Returns the app package as ``application/zip``. + + :param agent_name: The name of the agent to generate the app package for. Required. + :type agent_name: str + :keyword publish_scope: Publish scope for the Teams app. Known values are: "Personal", + "Shared", and "Tenant". Required. + :paramtype publish_scope: str or ~azure.ai.projects.models.Microsoft365PublishScope + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword agent_display_name: Display name used as the published Teams app name. When omitted, + the agent name from the route is + used. Default value is None. + :paramtype agent_display_name: str + :keyword bot_service_arm_id: ARM resource id of the Azure Bot Service that fronts this agent in + Microsoft Teams. Required for + workspaces on the default bot-based Teams backend; optional for workspaces on the API-based + backend. + Must not be supplied when ``publishAsAutopilot`` is true. Default value is None. + :paramtype bot_service_arm_id: str + :keyword publish_as_autopilot: When true, the agent is published as an autopilot (digital + worker) agent: the bot id is taken from + the agent's blueprint identity and the generated Teams manifest is marked as a digital worker. + Default value is None. + :paramtype publish_as_autopilot: bool + :keyword access_boundaries: Activity-protocol access boundaries to apply to the agent when + publishing as an autopilot agent. + An empty list clears the existing boundaries. When omitted, the existing boundaries are left + unchanged. Default value is None. + :paramtype access_boundaries: list[str or + ~azure.ai.projects.models.ActivityProtocolAccessBoundary] + :keyword optional_permission_scopes: Exact selection of delegated permission scopes to grant to + the autopilot blueprint. May only be + supplied when ``publishAsAutopilot`` is true. When omitted or empty, the platform's default + permission set is used. Mandatory platform permissions are always granted and are not affected + by + this value. Default value is None. + :paramtype optional_permission_scopes: + list[~azure.ai.projects.models.Microsoft365PermissionScopes] + :keyword can_respond_without_mention: Controls how the published agent responds to Teams + messages: when true it responds to all messages + on its surfaces, when false only when it is at-mentioned. When omitted, the agent's existing + Teams + message-notification setting is left unchanged. Default value is None. + :paramtype can_respond_without_mention: bool + :keyword app_version: App version (for example ``1.2.3``) written into the Teams manifest. May + contain only digits and + periods, must not start with ``0``, and must end with a digit. When omitted, a platform + default is + used. Default value is None. + :paramtype app_version: str + :keyword short_description: Short, one-line description shown in the Teams app listing. Default + value is None. + :paramtype short_description: str + :keyword full_description: Full description shown on the Teams app details page. Default value + is None. + :paramtype full_description: str + :keyword developer_name: Display name of the developer / publisher shown in the Teams app + listing. Default value is None. + :paramtype developer_name: str + :keyword developer_website_url: Developer / publisher website URL shown in the Teams app + listing. Must be an https URL. Default value is None. + :paramtype developer_website_url: str + :keyword privacy_url: Privacy policy URL shown in the Teams app listing. Must be an http or + https URL. Default value is None. + :paramtype privacy_url: str + :keyword terms_of_use_url: Terms-of-use URL shown in the Teams app listing. Default value is + None. + :paramtype terms_of_use_url: str + :keyword color_icon_base64: Optional base64-encoded PNG used as the color (full-bleed) icon in + the Teams app package. Must be a + 192x192 PNG (perfect square, no border or rounded corners). Max 1 MB after decode. When + omitted, the + platform default color icon is used. Default value is None. + :paramtype color_icon_base64: str + :keyword outline_icon_base64: Optional base64-encoded PNG used as the outline icon in the Teams + app package. Must be a 32x32 PNG. + Max 1 MB after decode. When omitted, the platform default outline icon is used. Default value + is None. + :paramtype outline_icon_base64: str + :return: Iterator[bytes] + :rtype: Iterator[bytes] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def get_microsoft365_package( + self, agent_name: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> Iterator[bytes]: + """Generate a Microsoft 365 app package. + + Generates the Microsoft Teams app package (zip) for a Foundry agent from the supplied publish + request, without publishing it. Returns the app package as ``application/zip``. + + :param agent_name: The name of the agent to generate the app package for. Required. + :type agent_name: str + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: Iterator[bytes] + :rtype: Iterator[bytes] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def get_microsoft365_package( + self, agent_name: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> Iterator[bytes]: + """Generate a Microsoft 365 app package. + + Generates the Microsoft Teams app package (zip) for a Foundry agent from the supplied publish + request, without publishing it. Returns the app package as ``application/zip``. + + :param agent_name: The name of the agent to generate the app package for. Required. + :type agent_name: str + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: Iterator[bytes] + :rtype: Iterator[bytes] + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace - def download_session_file(self, agent_name: str, session_id: str, *, path: str, **kwargs: Any) -> Iterator[bytes]: - """Download a session file. + def get_microsoft365_package( # pylint: disable=too-many-locals + self, + agent_name: str, + body: Union[JSON, IO[bytes]] = _Unset, + *, + publish_scope: Union[str, _models.Microsoft365PublishScope] = _Unset, + agent_display_name: Optional[str] = None, + bot_service_arm_id: Optional[str] = None, + publish_as_autopilot: Optional[bool] = None, + access_boundaries: Optional[List[Union[str, _models.ActivityProtocolAccessBoundary]]] = None, + optional_permission_scopes: Optional[List[_models.Microsoft365PermissionScopes]] = None, + can_respond_without_mention: Optional[bool] = None, + app_version: Optional[str] = None, + short_description: Optional[str] = None, + full_description: Optional[str] = None, + developer_name: Optional[str] = None, + developer_website_url: Optional[str] = None, + privacy_url: Optional[str] = None, + terms_of_use_url: Optional[str] = None, + color_icon_base64: Optional[str] = None, + outline_icon_base64: Optional[str] = None, + **kwargs: Any + ) -> Iterator[bytes]: + """Generate a Microsoft 365 app package. - Downloads the file at the specified sandbox path as a binary stream. The path is resolved - relative to the session home directory. + Generates the Microsoft Teams app package (zip) for a Foundry agent from the supplied publish + request, without publishing it. Returns the app package as ``application/zip``. - :param agent_name: The name of the agent. Required. + :param agent_name: The name of the agent to generate the app package for. Required. :type agent_name: str - :param session_id: The session ID. Required. - :type session_id: str - :keyword path: The file path to download from the sandbox, relative to the session home - directory. Required. - :paramtype path: str + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :keyword publish_scope: Publish scope for the Teams app. Known values are: "Personal", + "Shared", and "Tenant". Required. + :paramtype publish_scope: str or ~azure.ai.projects.models.Microsoft365PublishScope + :keyword agent_display_name: Display name used as the published Teams app name. When omitted, + the agent name from the route is + used. Default value is None. + :paramtype agent_display_name: str + :keyword bot_service_arm_id: ARM resource id of the Azure Bot Service that fronts this agent in + Microsoft Teams. Required for + workspaces on the default bot-based Teams backend; optional for workspaces on the API-based + backend. + Must not be supplied when ``publishAsAutopilot`` is true. Default value is None. + :paramtype bot_service_arm_id: str + :keyword publish_as_autopilot: When true, the agent is published as an autopilot (digital + worker) agent: the bot id is taken from + the agent's blueprint identity and the generated Teams manifest is marked as a digital worker. + Default value is None. + :paramtype publish_as_autopilot: bool + :keyword access_boundaries: Activity-protocol access boundaries to apply to the agent when + publishing as an autopilot agent. + An empty list clears the existing boundaries. When omitted, the existing boundaries are left + unchanged. Default value is None. + :paramtype access_boundaries: list[str or + ~azure.ai.projects.models.ActivityProtocolAccessBoundary] + :keyword optional_permission_scopes: Exact selection of delegated permission scopes to grant to + the autopilot blueprint. May only be + supplied when ``publishAsAutopilot`` is true. When omitted or empty, the platform's default + permission set is used. Mandatory platform permissions are always granted and are not affected + by + this value. Default value is None. + :paramtype optional_permission_scopes: + list[~azure.ai.projects.models.Microsoft365PermissionScopes] + :keyword can_respond_without_mention: Controls how the published agent responds to Teams + messages: when true it responds to all messages + on its surfaces, when false only when it is at-mentioned. When omitted, the agent's existing + Teams + message-notification setting is left unchanged. Default value is None. + :paramtype can_respond_without_mention: bool + :keyword app_version: App version (for example ``1.2.3``) written into the Teams manifest. May + contain only digits and + periods, must not start with ``0``, and must end with a digit. When omitted, a platform + default is + used. Default value is None. + :paramtype app_version: str + :keyword short_description: Short, one-line description shown in the Teams app listing. Default + value is None. + :paramtype short_description: str + :keyword full_description: Full description shown on the Teams app details page. Default value + is None. + :paramtype full_description: str + :keyword developer_name: Display name of the developer / publisher shown in the Teams app + listing. Default value is None. + :paramtype developer_name: str + :keyword developer_website_url: Developer / publisher website URL shown in the Teams app + listing. Must be an https URL. Default value is None. + :paramtype developer_website_url: str + :keyword privacy_url: Privacy policy URL shown in the Teams app listing. Must be an http or + https URL. Default value is None. + :paramtype privacy_url: str + :keyword terms_of_use_url: Terms-of-use URL shown in the Teams app listing. Default value is + None. + :paramtype terms_of_use_url: str + :keyword color_icon_base64: Optional base64-encoded PNG used as the color (full-bleed) icon in + the Teams app package. Must be a + 192x192 PNG (perfect square, no border or rounded corners). Max 1 MB after decode. When + omitted, the + platform default color icon is used. Default value is None. + :paramtype color_icon_base64: str + :keyword outline_icon_base64: Optional base64-encoded PNG used as the outline icon in the Teams + app package. Must be a 32x32 PNG. + Max 1 MB after decode. When omitted, the platform default outline icon is used. Default value + is None. + :paramtype outline_icon_base64: str :return: Iterator[bytes] :rtype: Iterator[bytes] :raises ~azure.core.exceptions.HttpResponseError: @@ -5783,16 +6727,46 @@ def download_session_file(self, agent_name: str, session_id: str, *, path: str, } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_agents_download_session_file_request( + if body is _Unset: + if publish_scope is _Unset: + raise TypeError("missing required argument: publish_scope") + body = { + "accessBoundaries": access_boundaries, + "agentDisplayName": agent_display_name, + "appVersion": app_version, + "botServiceArmId": bot_service_arm_id, + "canRespondWithoutMention": can_respond_without_mention, + "colorIconBase64": color_icon_base64, + "developerName": developer_name, + "developerWebsiteUrl": developer_website_url, + "fullDescription": full_description, + "optionalPermissionScopes": optional_permission_scopes, + "outlineIconBase64": outline_icon_base64, + "privacyUrl": privacy_url, + "publishAsAutopilot": publish_as_autopilot, + "publishScope": publish_scope, + "shortDescription": short_description, + "termsOfUseUrl": terms_of_use_url, + } + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/json" + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_agents_get_microsoft365_package_request( agent_name=agent_name, - session_id=session_id, - path=path, + content_type=content_type, api_version=self._config.api_version, + content=_content, headers=_headers, params=_params, ) @@ -5822,141 +6796,33 @@ def download_session_file(self, agent_name: str, session_id: str, *, path: str, ) raise HttpResponseError(response=response, model=error) + response_headers = {} + response_headers["Content-Type"] = self._deserialize("str", response.headers.get("Content-Type")) + deserialized = response.iter_bytes() if _decompress else response.iter_raw() if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @distributed_trace - def list_session_files( - self, - agent_name: str, - session_id: str, - *, - path: Optional[str] = None, - limit: Optional[int] = None, - order: Optional[Union[str, _models.PageOrder]] = None, - before: Optional[str] = None, - **kwargs: Any - ) -> ItemPaged["_models.SessionDirectoryEntry"]: - """List session files. + def get_microsoft365_publish_defaults( + self, agent_name: str, *, publish_as_digital_worker: Optional[bool] = None, **kwargs: Any + ) -> _models.Microsoft365PublishDefaults: + """Get Microsoft 365 publish defaults. - Returns files and directories at the specified path in the session sandbox. The response - includes only the immediate children of the target directory and defaults to the session home - directory when no path is supplied. + Returns default and previously-published values used to pre-populate a Microsoft 365 publish + request for a Foundry agent. - :param agent_name: The name of the agent. Required. + :param agent_name: The name of the agent to get publish defaults for. Required. :type agent_name: str - :param session_id: The session ID. Required. - :type session_id: str - :keyword path: The directory path to list, relative to the session home directory. Defaults to - the home directory if not provided. Default value is None. - :paramtype path: str - :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and - 100, and the - default is 20. Default value is None. - :paramtype limit: int - :keyword order: Sort order by the ``created_at`` timestamp of the objects. ``asc`` for - ascending order and``desc`` - for descending order. Known values are: "asc" and "desc". Default value is None. - :paramtype order: str or ~azure.ai.projects.models.PageOrder - :keyword before: A cursor for use in pagination. ``before`` is an object ID that defines your - place in the list. - For instance, if you make a list request and receive 100 objects, ending with obj_foo, your - subsequent call can include before=obj_foo in order to fetch the previous page of the list. - Default value is None. - :paramtype before: str - :return: An iterator like instance of SessionDirectoryEntry - :rtype: ~azure.core.paging.ItemPaged[~azure.ai.projects.models.SessionDirectoryEntry] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.SessionDirectoryEntry]] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(_continuation_token=None): - - _request = build_agents_list_session_files_request( - agent_name=agent_name, - session_id=session_id, - path=path, - limit=limit, - order=order, - after=_continuation_token, - before=before, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - return _request - - def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize( - List[_models.SessionDirectoryEntry], - deserialized.get("entries", []), - ) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("last_id") or None, iter(list_of_elem) - - def get_next(_continuation_token=None): - _request = prepare_request(_continuation_token) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ApiErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def delete_session_file( # pylint: disable=inconsistent-return-statements - self, agent_name: str, session_id: str, *, path: str, recursive: Optional[bool] = None, **kwargs: Any - ) -> None: - """Delete a session file. - - Deletes the specified file or directory from the session sandbox. When ``recursive`` is false, - deleting a non-empty directory returns 409 Conflict. - - :param agent_name: The name of the agent. Required. - :type agent_name: str - :param session_id: The session ID. Required. - :type session_id: str - :keyword path: The file or directory path to delete, relative to the session home directory. - Required. - :paramtype path: str - :keyword recursive: Whether to recursively delete directory contents. The service defaults to - ``false`` if a value is not specified by the caller. Default value is None. - :paramtype recursive: bool - :return: None - :rtype: None + :keyword publish_as_digital_worker: When true, returns defaults for publishing the agent as an + autopilot (digital worker) agent. Default value is None. + :paramtype publish_as_digital_worker: bool + :return: Microsoft365PublishDefaults. The Microsoft365PublishDefaults is compatible with + MutableMapping + :rtype: ~azure.ai.projects.models.Microsoft365PublishDefaults :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -5970,13 +6836,11 @@ def delete_session_file( # pylint: disable=inconsistent-return-statements _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[_models.Microsoft365PublishDefaults] = kwargs.pop("cls", None) - _request = build_agents_delete_session_file_request( + _request = build_agents_get_microsoft365_publish_defaults_request( agent_name=agent_name, - session_id=session_id, - path=path, - recursive=recursive, + publish_as_digital_worker=publish_as_digital_worker, api_version=self._config.api_version, headers=_headers, params=_params, @@ -5986,14 +6850,20 @@ def delete_session_file( # pylint: disable=inconsistent-return-statements } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [204]: + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) error = _failsafe_deserialize( _models.ApiErrorResponse, @@ -6001,37 +6871,102 @@ def delete_session_file( # pylint: disable=inconsistent-return-statements ) raise HttpResponseError(response=response, model=error) + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Microsoft365PublishDefaults, response.json()) + if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore + return deserialized # type: ignore -class EvaluationRulesOperations: # pylint: disable=docstring-missing-param - """ - .. warning:: - **DO NOT** instantiate this class directly. + @overload + def upload_session_file( + self, + agent_name: str, + session_id: str, + content: bytes, + *, + path: str, + content_type: str = "application/octet-stream", + **kwargs: Any + ) -> _models.SessionFileWriteResult: + """Upload a session file. - Instead, you should access the following operations through - :class:`~azure.ai.projects.AIProjectClient`'s - :attr:`evaluation_rules` attribute. - """ + Uploads binary file content to the specified path in the session sandbox. The service stores + the file relative to the session home directory and rejects payloads larger than 50 MB. - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + :param agent_name: The name of the agent. Required. + :type agent_name: str + :param session_id: The session ID. Required. + :type session_id: str + :param content: Required. + :type content: bytes + :keyword path: The destination file path within the sandbox, relative to the session home + directory. Required. + :paramtype path: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/octet-stream". + :paramtype content_type: str + :return: SessionFileWriteResult. The SessionFileWriteResult is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.SessionFileWriteResult + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def upload_session_file( + self, + agent_name: str, + session_id: str, + content: IO[bytes], + *, + path: str, + content_type: str = "application/octet-stream", + **kwargs: Any + ) -> _models.SessionFileWriteResult: + """Upload a session file. + + Uploads binary file content to the specified path in the session sandbox. The service stores + the file relative to the session home directory and rejects payloads larger than 50 MB. + + :param agent_name: The name of the agent. Required. + :type agent_name: str + :param session_id: The session ID. Required. + :type session_id: str + :param content: Required. + :type content: IO[bytes] + :keyword path: The destination file path within the sandbox, relative to the session home + directory. Required. + :paramtype path: str + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/octet-stream". + :paramtype content_type: str + :return: SessionFileWriteResult. The SessionFileWriteResult is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.SessionFileWriteResult + :raises ~azure.core.exceptions.HttpResponseError: + """ @distributed_trace - def get(self, id: str, **kwargs: Any) -> _models.EvaluationRule: - """Get an evaluation rule. + def upload_session_file( + self, agent_name: str, session_id: str, content: Union[bytes, IO[bytes]], *, path: str, **kwargs: Any + ) -> _models.SessionFileWriteResult: + """Upload a session file. - Retrieves the specified evaluation rule and its configuration. + Uploads binary file content to the specified path in the session sandbox. The service stores + the file relative to the session home directory and rejects payloads larger than 50 MB. - :param id: Unique identifier for the evaluation rule. Required. - :type id: str - :return: EvaluationRule. The EvaluationRule is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.EvaluationRule + :param agent_name: The name of the agent. Required. + :type agent_name: str + :param session_id: The session ID. Required. + :type session_id: str + :param content: Is either a bytes type or a IO[bytes] type. Required. + :type content: bytes or IO[bytes] + :keyword path: The destination file path within the sandbox, relative to the session home + directory. Required. + :paramtype path: str + :return: SessionFileWriteResult. The SessionFileWriteResult is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.SessionFileWriteResult :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -6042,14 +6977,22 @@ def get(self, id: str, **kwargs: Any) -> _models.EvaluationRule: } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = kwargs.pop("headers", {}) or {} + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.EvaluationRule] = kwargs.pop("cls", None) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.SessionFileWriteResult] = kwargs.pop("cls", None) - _request = build_evaluation_rules_get_request( - id=id, + content_type = content_type or "application/octet-stream" + _content = content + + _request = build_agents_upload_session_file_request( + agent_name=agent_name, + session_id=session_id, + path=path, + content_type=content_type, api_version=self._config.api_version, + content=_content, headers=_headers, params=_params, ) @@ -6066,19 +7009,23 @@ def get(self, id: str, **kwargs: Any) -> _models.EvaluationRule: response = pipeline_response.http_response - if response.status_code not in [200]: + if response.status_code not in [201]: if _stream: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.EvaluationRule, response.json()) + deserialized = _deserialize(_models.SessionFileWriteResult, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -6086,15 +7033,21 @@ def get(self, id: str, **kwargs: Any) -> _models.EvaluationRule: return deserialized # type: ignore @distributed_trace - def delete(self, id: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements - """Delete an evaluation rule. + def download_session_file(self, agent_name: str, session_id: str, *, path: str, **kwargs: Any) -> Iterator[bytes]: + """Download a session file. - Removes the specified evaluation rule from the project. + Downloads the file at the specified sandbox path as a binary stream. The path is resolved + relative to the session home directory. - :param id: Unique identifier for the evaluation rule. Required. - :type id: str - :return: None - :rtype: None + :param agent_name: The name of the agent. Required. + :type agent_name: str + :param session_id: The session ID. Required. + :type session_id: str + :keyword path: The file path to download from the sandbox, relative to the session home + directory. Required. + :paramtype path: str + :return: Iterator[bytes] + :rtype: Iterator[bytes] :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -6108,10 +7061,12 @@ def delete(self, id: str, **kwargs: Any) -> None: # pylint: disable=inconsisten _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) - _request = build_evaluation_rules_delete_request( - id=id, + _request = build_agents_download_session_file_request( + agent_name=agent_name, + session_id=session_id, + path=path, api_version=self._config.api_version, headers=_headers, params=_params, @@ -6121,95 +7076,162 @@ def delete(self, id: str, **kwargs: Any) -> None: # pylint: disable=inconsisten } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", True) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [204]: + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() if cls: - return cls(pipeline_response, None, {}) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore - @overload - def create_or_update( - self, id: str, evaluation_rule: _models.EvaluationRule, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.EvaluationRule: - """Create or update an evaluation rule. + return deserialized # type: ignore - Creates a new evaluation rule, or replaces the existing rule when the identifier matches. + @distributed_trace + def list_session_files( + self, + agent_name: str, + session_id: str, + *, + path: Optional[str] = None, + limit: Optional[int] = None, + order: Optional[Union[str, _models.PageOrder]] = None, + before: Optional[str] = None, + **kwargs: Any + ) -> ItemPaged["_models.SessionDirectoryEntry"]: + """List session files. - :param id: Unique identifier for the evaluation rule. Required. - :type id: str - :param evaluation_rule: Evaluation rule resource. Required. - :type evaluation_rule: ~azure.ai.projects.models.EvaluationRule - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: EvaluationRule. The EvaluationRule is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.EvaluationRule + Returns files and directories at the specified path in the session sandbox. The response + includes only the immediate children of the target directory and defaults to the session home + directory when no path is supplied. + + :param agent_name: The name of the agent. Required. + :type agent_name: str + :param session_id: The session ID. Required. + :type session_id: str + :keyword path: The directory path to list, relative to the session home directory. Defaults to + the home directory if not provided. Default value is None. + :paramtype path: str + :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and + 100, and the + default is 20. Default value is None. + :paramtype limit: int + :keyword order: Sort order by the ``created_at`` timestamp of the objects. ``asc`` for + ascending order and``desc`` + for descending order. Known values are: "asc" and "desc". Default value is None. + :paramtype order: str or ~azure.ai.projects.models.PageOrder + :keyword before: A cursor for use in pagination. ``before`` is an object ID that defines your + place in the list. + For instance, if you make a list request and receive 100 objects, ending with obj_foo, your + subsequent call can include before=obj_foo in order to fetch the previous page of the list. + Default value is None. + :paramtype before: str + :return: An iterator like instance of SessionDirectoryEntry + :rtype: ~azure.core.paging.ItemPaged[~azure.ai.projects.models.SessionDirectoryEntry] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - @overload - def create_or_update( - self, id: str, evaluation_rule: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.EvaluationRule: - """Create or update an evaluation rule. + cls: ClsType[List[_models.SessionDirectoryEntry]] = kwargs.pop("cls", None) - Creates a new evaluation rule, or replaces the existing rule when the identifier matches. + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - :param id: Unique identifier for the evaluation rule. Required. - :type id: str - :param evaluation_rule: Evaluation rule resource. Required. - :type evaluation_rule: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: EvaluationRule. The EvaluationRule is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.EvaluationRule - :raises ~azure.core.exceptions.HttpResponseError: - """ + def prepare_request(_continuation_token=None): - @overload - def create_or_update( - self, id: str, evaluation_rule: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.EvaluationRule: - """Create or update an evaluation rule. + _request = build_agents_list_session_files_request( + agent_name=agent_name, + session_id=session_id, + path=path, + limit=limit, + order=order, + after=_continuation_token, + before=before, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + return _request - Creates a new evaluation rule, or replaces the existing rule when the identifier matches. + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.SessionDirectoryEntry], + deserialized.get("entries", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("last_id") or None, iter(list_of_elem) - :param id: Unique identifier for the evaluation rule. Required. - :type id: str - :param evaluation_rule: Evaluation rule resource. Required. - :type evaluation_rule: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: EvaluationRule. The EvaluationRule is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.EvaluationRule - :raises ~azure.core.exceptions.HttpResponseError: - """ + def get_next(_continuation_token=None): + _request = prepare_request(_continuation_token) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + return pipeline_response + + return ItemPaged(get_next, extract_data) @distributed_trace - def create_or_update( - self, id: str, evaluation_rule: Union[_models.EvaluationRule, JSON, IO[bytes]], **kwargs: Any - ) -> _models.EvaluationRule: - """Create or update an evaluation rule. + def delete_session_file( # pylint: disable=inconsistent-return-statements + self, agent_name: str, session_id: str, *, path: str, recursive: Optional[bool] = None, **kwargs: Any + ) -> None: + """Delete a session file. - Creates a new evaluation rule, or replaces the existing rule when the identifier matches. + Deletes the specified file or directory from the session sandbox. When ``recursive`` is false, + deleting a non-empty directory returns 409 Conflict. - :param id: Unique identifier for the evaluation rule. Required. - :type id: str - :param evaluation_rule: Evaluation rule resource. Is one of the following types: - EvaluationRule, JSON, IO[bytes] Required. - :type evaluation_rule: ~azure.ai.projects.models.EvaluationRule or JSON or IO[bytes] - :return: EvaluationRule. The EvaluationRule is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.EvaluationRule + :param agent_name: The name of the agent. Required. + :type agent_name: str + :param session_id: The session ID. Required. + :type session_id: str + :keyword path: The file or directory path to delete, relative to the session home directory. + Required. + :paramtype path: str + :keyword recursive: Whether to recursively delete directory contents. The service defaults to + ``false`` if a value is not specified by the caller. Default value is None. + :paramtype recursive: bool + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -6220,24 +7242,17 @@ def create_or_update( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.EvaluationRule] = kwargs.pop("cls", None) - - content_type = content_type or "application/json" - _content = None - if isinstance(evaluation_rule, (IOBase, bytes)): - _content = evaluation_rule - else: - _content = json.dumps(evaluation_rule, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_evaluation_rules_create_or_update_request( - id=id, - content_type=content_type, + _request = build_agents_delete_session_file_request( + agent_name=agent_name, + session_id=session_id, + path=path, + recursive=recursive, api_version=self._config.api_version, - content=_content, headers=_headers, params=_params, ) @@ -6246,150 +7261,33 @@ def create_or_update( } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200, 201]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - deserialized = _deserialize(_models.EvaluationRule, response.json()) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, None, {}) # type: ignore - return deserialized # type: ignore - @distributed_trace - def list( - self, - *, - action_type: Optional[Union[str, _models.EvaluationRuleActionType]] = None, - agent_name: Optional[str] = None, - enabled: Optional[bool] = None, - **kwargs: Any - ) -> ItemPaged["_models.EvaluationRule"]: - """List evaluation rules. - - Returns the evaluation rules configured for the project, optionally filtered by action type, - agent name, or enabled state. - - :keyword action_type: Filter by the type of evaluation rule. Known values are: - "continuousEvaluation" and "humanEvaluationPreview". Default value is None. - :paramtype action_type: str or ~azure.ai.projects.models.EvaluationRuleActionType - :keyword agent_name: Filter by the agent name. Default value is None. - :paramtype agent_name: str - :keyword enabled: Filter by the enabled status. Default value is None. - :paramtype enabled: bool - :return: An iterator like instance of EvaluationRule - :rtype: ~azure.core.paging.ItemPaged[~azure.ai.projects.models.EvaluationRule] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.EvaluationRule]] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(next_link=None): - if not next_link: - - _request = build_evaluation_rules_list_request( - action_type=action_type, - agent_name=agent_name, - enabled=enabled, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - return _request - - def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize( - List[_models.EvaluationRule], - deserialized.get("value", []), - ) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - -class ConnectionsOperations: # pylint: disable=docstring-missing-param +class EvaluationRulesOperations: # pylint: disable=docstring-missing-param """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.ai.projects.AIProjectClient`'s - :attr:`connections` attribute. + :attr:`evaluation_rules` attribute. """ def __init__(self, *args, **kwargs) -> None: @@ -6400,16 +7298,15 @@ def __init__(self, *args, **kwargs) -> None: self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def _get(self, name: str, **kwargs: Any) -> _models.Connection: - """Get a connection. + def get(self, id: str, **kwargs: Any) -> _models.EvaluationRule: + """Get an evaluation rule. - Retrieves the specified connection and its configuration details without including credential - values. + Retrieves the specified evaluation rule and its configuration. - :param name: The friendly name of the connection, provided by the user. Required. - :type name: str - :return: Connection. The Connection is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.Connection + :param id: Unique identifier for the evaluation rule. Required. + :type id: str + :return: EvaluationRule. The EvaluationRule is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.EvaluationRule :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -6423,10 +7320,10 @@ def _get(self, name: str, **kwargs: Any) -> _models.Connection: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.Connection] = kwargs.pop("cls", None) + cls: ClsType[_models.EvaluationRule] = kwargs.pop("cls", None) - _request = build_connections_get_request( - name=name, + _request = build_evaluation_rules_get_request( + id=id, api_version=self._config.api_version, headers=_headers, params=_params, @@ -6453,31 +7350,26 @@ def _get(self, name: str, **kwargs: Any) -> _models.Connection: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) - response_headers = {} - response_headers["x-ms-client-request-id"] = self._deserialize( - "str", response.headers.get("x-ms-client-request-id") - ) - if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.Connection, response.json()) + deserialized = _deserialize(_models.EvaluationRule, response.json()) if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore + return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore @distributed_trace - def _get_with_credentials(self, name: str, **kwargs: Any) -> _models.Connection: - """Get a connection with credentials. + def delete(self, id: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements + """Delete an evaluation rule. - Retrieves the specified connection together with its credential values. + Removes the specified evaluation rule from the project. - :param name: The friendly name of the connection, provided by the user. Required. - :type name: str - :return: Connection. The Connection is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.Connection + :param id: Unique identifier for the evaluation rule. Required. + :type id: str + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -6491,10 +7383,10 @@ def _get_with_credentials(self, name: str, **kwargs: Any) -> _models.Connection: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.Connection] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_connections_get_with_credentials_request( - name=name, + _request = build_evaluation_rules_delete_request( + id=id, api_version=self._config.api_version, headers=_headers, params=_params, @@ -6504,178 +7396,187 @@ def _get_with_credentials(self, name: str, **kwargs: Any) -> _models.Connection: } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) - response_headers = {} - response_headers["x-ms-client-request-id"] = self._deserialize( - "str", response.headers.get("x-ms-client-request-id") - ) + if cls: + return cls(pipeline_response, None, {}) # type: ignore - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - deserialized = _deserialize(_models.Connection, response.json()) + @overload + def create_or_update( + self, id: str, evaluation_rule: _models.EvaluationRule, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.EvaluationRule: + """Create or update an evaluation rule. - if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore + Creates a new evaluation rule, or replaces the existing rule when the identifier matches. - return deserialized # type: ignore + :param id: Unique identifier for the evaluation rule. Required. + :type id: str + :param evaluation_rule: Evaluation rule resource. Required. + :type evaluation_rule: ~azure.ai.projects.models.EvaluationRule + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: EvaluationRule. The EvaluationRule is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.EvaluationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ - @distributed_trace - def list( - self, - *, - connection_type: Optional[Union[str, _models.ConnectionType]] = None, - default_connection: Optional[bool] = None, - **kwargs: Any - ) -> ItemPaged["_models.Connection"]: - """List connections. + @overload + def create_or_update( + self, id: str, evaluation_rule: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.EvaluationRule: + """Create or update an evaluation rule. - Returns the connections available in the current project, optionally filtered by type or - default status. + Creates a new evaluation rule, or replaces the existing rule when the identifier matches. - :keyword connection_type: Lists connections of this specific type. Known values are: - "AzureOpenAI", "AzureBlob", "AzureStorageAccount", "CognitiveSearch", "CosmosDB", "ApiKey", - "AppConfig", "AppInsights", "CustomKeys", and "RemoteTool_Preview". Default value is None. - :paramtype connection_type: str or ~azure.ai.projects.models.ConnectionType - :keyword default_connection: Lists connections that are default connections. Default value is - None. - :paramtype default_connection: bool - :return: An iterator like instance of Connection - :rtype: ~azure.core.paging.ItemPaged[~azure.ai.projects.models.Connection] + :param id: Unique identifier for the evaluation rule. Required. + :type id: str + :param evaluation_rule: Evaluation rule resource. Required. + :type evaluation_rule: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: EvaluationRule. The EvaluationRule is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.EvaluationRule :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.Connection]] = kwargs.pop("cls", None) - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) + @overload + def create_or_update( + self, id: str, evaluation_rule: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.EvaluationRule: + """Create or update an evaluation rule. - def prepare_request(next_link=None): - if not next_link: + Creates a new evaluation rule, or replaces the existing rule when the identifier matches. - _request = build_connections_list_request( - connection_type=connection_type, - default_connection=default_connection, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + :param id: Unique identifier for the evaluation rule. Required. + :type id: str + :param evaluation_rule: Evaluation rule resource. Required. + :type evaluation_rule: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: EvaluationRule. The EvaluationRule is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.EvaluationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + @distributed_trace + def create_or_update( + self, id: str, evaluation_rule: Union[_models.EvaluationRule, JSON, IO[bytes]], **kwargs: Any + ) -> _models.EvaluationRule: + """Create or update an evaluation rule. - return _request + Creates a new evaluation rule, or replaces the existing rule when the identifier matches. - def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize( - List[_models.Connection], - deserialized.get("value", []), - ) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, iter(list_of_elem) + :param id: Unique identifier for the evaluation rule. Required. + :type id: str + :param evaluation_rule: Evaluation rule resource. Is one of the following types: + EvaluationRule, JSON, IO[bytes] Required. + :type evaluation_rule: ~azure.ai.projects.models.EvaluationRule or JSON or IO[bytes] + :return: EvaluationRule. The EvaluationRule is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.EvaluationRule + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - def get_next(next_link=None): - _request = prepare_request(next_link) + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.EvaluationRule] = kwargs.pop("cls", None) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + content_type = content_type or "application/json" + _content = None + if isinstance(evaluation_rule, (IOBase, bytes)): + _content = evaluation_rule + else: + _content = json.dumps(evaluation_rule, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - return pipeline_response + _request = build_evaluation_rules_create_or_update_request( + id=id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - return ItemPaged(get_next, extract_data) + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response -class DatasetsOperations: # pylint: disable=docstring-missing-param - """ - .. warning:: - **DO NOT** instantiate this class directly. + if response.status_code not in [200, 201]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) - Instead, you should access the following operations through - :class:`~azure.ai.projects.AIProjectClient`'s - :attr:`datasets` attribute. - """ + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.EvaluationRule, response.json()) - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore @distributed_trace - def list_versions(self, name: str, **kwargs: Any) -> ItemPaged["_models.DatasetVersion"]: - """List versions. + def list( + self, + *, + action_type: Optional[Union[str, _models.EvaluationRuleActionType]] = None, + agent_name: Optional[str] = None, + enabled: Optional[bool] = None, + **kwargs: Any + ) -> ItemPaged["_models.EvaluationRule"]: + """List evaluation rules. - List all versions of the given DatasetVersion. + Returns the evaluation rules configured for the project, optionally filtered by action type, + agent name, or enabled state. - :param name: The name of the resource. Required. - :type name: str - :return: An iterator like instance of DatasetVersion - :rtype: ~azure.core.paging.ItemPaged[~azure.ai.projects.models.DatasetVersion] + :keyword action_type: Filter by the type of evaluation rule. Known values are: + "continuousEvaluation" and "humanEvaluationPreview". Default value is None. + :paramtype action_type: str or ~azure.ai.projects.models.EvaluationRuleActionType + :keyword agent_name: Filter by the agent name. Default value is None. + :paramtype agent_name: str + :keyword enabled: Filter by the enabled status. Default value is None. + :paramtype enabled: bool + :return: An iterator like instance of EvaluationRule + :rtype: ~azure.core.paging.ItemPaged[~azure.ai.projects.models.EvaluationRule] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.DatasetVersion]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.EvaluationRule]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -6688,8 +7589,10 @@ def list_versions(self, name: str, **kwargs: Any) -> ItemPaged["_models.DatasetV def prepare_request(next_link=None): if not next_link: - _request = build_datasets_list_versions_request( - name=name, + _request = build_evaluation_rules_list_request( + action_type=action_type, + agent_name=agent_name, + enabled=enabled, api_version=self._config.api_version, headers=_headers, params=_params, @@ -6729,7 +7632,7 @@ def prepare_request(next_link=None): def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() list_of_elem = _deserialize( - List[_models.DatasetVersion], + List[_models.EvaluationRule], deserialized.get("value", []), ) if cls: @@ -6753,21 +7656,37 @@ def get_next(next_link=None): return ItemPaged(get_next, extract_data) + +class ConnectionsOperations: # pylint: disable=docstring-missing-param + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.ai.projects.AIProjectClient`'s + :attr:`connections` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + @distributed_trace - def list(self, **kwargs: Any) -> ItemPaged["_models.DatasetVersion"]: - """List latest versions. + def _get(self, name: str, **kwargs: Any) -> _models.Connection: + """Get a connection. - List the latest version of each DatasetVersion. + Retrieves the specified connection and its configuration details without including credential + values. - :return: An iterator like instance of DatasetVersion - :rtype: ~azure.core.paging.ItemPaged[~azure.ai.projects.models.DatasetVersion] + :param name: The friendly name of the connection, provided by the user. Required. + :type name: str + :return: Connection. The Connection is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.Connection :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.DatasetVersion]] = kwargs.pop("cls", None) - error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -6776,104 +7695,13 @@ def list(self, **kwargs: Any) -> ItemPaged["_models.DatasetVersion"]: } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - _request = build_datasets_list_request( - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + cls: ClsType[_models.Connection] = kwargs.pop("cls", None) - return _request - - def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize( - List[_models.DatasetVersion], - deserialized.get("value", []), - ) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, iter(list_of_elem) - - def get_next(next_link=None): - _request = prepare_request(next_link) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def get(self, name: str, version: str, **kwargs: Any) -> _models.DatasetVersion: - """Get a version. - - Get the specific version of the DatasetVersion. The service returns 404 Not Found error if the - DatasetVersion does not exist. - - :param name: The name of the resource. Required. - :type name: str - :param version: The specific version id of the DatasetVersion to retrieve. Required. - :type version: str - :return: DatasetVersion. The DatasetVersion is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.DatasetVersion - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.DatasetVersion] = kwargs.pop("cls", None) - - _request = build_datasets_get_request( + _request = build_connections_get_request( name=name, - version=version, api_version=self._config.api_version, headers=_headers, params=_params, @@ -6900,29 +7728,31 @@ def get(self, name: str, version: str, **kwargs: Any) -> _models.DatasetVersion: map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) + response_headers = {} + response_headers["x-ms-client-request-id"] = self._deserialize( + "str", response.headers.get("x-ms-client-request-id") + ) + if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.DatasetVersion, response.json()) + deserialized = _deserialize(_models.Connection, response.json()) if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore + return cls(pipeline_response, deserialized, response_headers) # type: ignore return deserialized # type: ignore @distributed_trace - def delete(self, name: str, version: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements - """Delete a version. + def _get_with_credentials(self, name: str, **kwargs: Any) -> _models.Connection: + """Get a connection with credentials. - Delete the specific version of the DatasetVersion. The service returns 204 No Content if the - DatasetVersion was deleted successfully or if the DatasetVersion does not exist. + Retrieves the specified connection together with its credential values. - :param name: The name of the resource. Required. + :param name: The friendly name of the connection, provided by the user. Required. :type name: str - :param version: The version of the DatasetVersion to delete. Required. - :type version: str - :return: None - :rtype: None + :return: Connection. The Connection is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.Connection :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -6936,11 +7766,10 @@ def delete(self, name: str, version: str, **kwargs: Any) -> None: # pylint: dis _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[None] = kwargs.pop("cls", None) + cls: ClsType[_models.Connection] = kwargs.pop("cls", None) - _request = build_datasets_delete_request( + _request = build_connections_get_with_credentials_request( name=name, - version=version, api_version=self._config.api_version, headers=_headers, params=_params, @@ -6950,119 +7779,356 @@ def delete(self, name: str, version: str, **kwargs: Any) -> None: # pylint: dis } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _stream = False + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [204]: + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass map_error(status_code=response.status_code, response=response, error_map=error_map) raise HttpResponseError(response=response) - if cls: - return cls(pipeline_response, None, {}) # type: ignore + response_headers = {} + response_headers["x-ms-client-request-id"] = self._deserialize( + "str", response.headers.get("x-ms-client-request-id") + ) - @overload - def create_or_update( - self, - name: str, - version: str, - dataset_version: _models.DatasetVersion, - *, - content_type: str = "application/merge-patch+json", - **kwargs: Any - ) -> _models.DatasetVersion: - """Create or update a version. + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Connection, response.json()) - Create a new or update an existing DatasetVersion with the given version id. + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - :param name: The name of the resource. Required. - :type name: str - :param version: The specific version id of the DatasetVersion to create or update. Required. - :type version: str - :param dataset_version: The DatasetVersion to create or update. Required. - :type dataset_version: ~azure.ai.projects.models.DatasetVersion - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/merge-patch+json". - :paramtype content_type: str - :return: DatasetVersion. The DatasetVersion is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.DatasetVersion - :raises ~azure.core.exceptions.HttpResponseError: - """ + return deserialized # type: ignore - @overload - def create_or_update( + @distributed_trace + def list( self, - name: str, - version: str, - dataset_version: JSON, *, - content_type: str = "application/merge-patch+json", + connection_type: Optional[Union[str, _models.ConnectionType]] = None, + default_connection: Optional[bool] = None, **kwargs: Any - ) -> _models.DatasetVersion: - """Create or update a version. + ) -> ItemPaged["_models.Connection"]: + """List connections. - Create a new or update an existing DatasetVersion with the given version id. + Returns the connections available in the current project, optionally filtered by type or + default status. - :param name: The name of the resource. Required. - :type name: str - :param version: The specific version id of the DatasetVersion to create or update. Required. - :type version: str - :param dataset_version: The DatasetVersion to create or update. Required. - :type dataset_version: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/merge-patch+json". - :paramtype content_type: str - :return: DatasetVersion. The DatasetVersion is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.DatasetVersion + :keyword connection_type: Lists connections of this specific type. Known values are: + "AzureOpenAI", "AzureBlob", "AzureStorageAccount", "CognitiveSearch", "CosmosDB", "ApiKey", + "AppConfig", "AppInsights", "CustomKeys", and "RemoteTool_Preview". Default value is None. + :paramtype connection_type: str or ~azure.ai.projects.models.ConnectionType + :keyword default_connection: Lists connections that are default connections. Default value is + None. + :paramtype default_connection: bool + :return: An iterator like instance of Connection + :rtype: ~azure.core.paging.ItemPaged[~azure.ai.projects.models.Connection] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - @overload - def create_or_update( - self, - name: str, - version: str, - dataset_version: IO[bytes], - *, - content_type: str = "application/merge-patch+json", - **kwargs: Any - ) -> _models.DatasetVersion: - """Create or update a version. + cls: ClsType[List[_models.Connection]] = kwargs.pop("cls", None) - Create a new or update an existing DatasetVersion with the given version id. + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - :param name: The name of the resource. Required. - :type name: str - :param version: The specific version id of the DatasetVersion to create or update. Required. - :type version: str - :param dataset_version: The DatasetVersion to create or update. Required. - :type dataset_version: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/merge-patch+json". - :paramtype content_type: str - :return: DatasetVersion. The DatasetVersion is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.DatasetVersion - :raises ~azure.core.exceptions.HttpResponseError: - """ + def prepare_request(next_link=None): + if not next_link: - @distributed_trace - def create_or_update( - self, name: str, version: str, dataset_version: Union[_models.DatasetVersion, JSON, IO[bytes]], **kwargs: Any - ) -> _models.DatasetVersion: - """Create or update a version. + _request = build_connections_list_request( + connection_type=connection_type, + default_connection=default_connection, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - Create a new or update an existing DatasetVersion with the given version id. + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - :param name: The name of the resource. Required. - :type name: str - :param version: The specific version id of the DatasetVersion to create or update. Required. - :type version: str - :param dataset_version: The DatasetVersion to create or update. Is one of the following types: - DatasetVersion, JSON, IO[bytes] Required. - :type dataset_version: ~azure.ai.projects.models.DatasetVersion or JSON or IO[bytes] + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Connection], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class DatasetsOperations: # pylint: disable=docstring-missing-param + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.ai.projects.AIProjectClient`'s + :attr:`datasets` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_versions(self, name: str, **kwargs: Any) -> ItemPaged["_models.DatasetVersion"]: + """List versions. + + List all versions of the given DatasetVersion. + + :param name: The name of the resource. Required. + :type name: str + :return: An iterator like instance of DatasetVersion + :rtype: ~azure.core.paging.ItemPaged[~azure.ai.projects.models.DatasetVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DatasetVersion]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_datasets_list_versions_request( + name=name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.DatasetVersion], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list(self, **kwargs: Any) -> ItemPaged["_models.DatasetVersion"]: + """List latest versions. + + List the latest version of each DatasetVersion. + + :return: An iterator like instance of DatasetVersion + :rtype: ~azure.core.paging.ItemPaged[~azure.ai.projects.models.DatasetVersion] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.DatasetVersion]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_datasets_list_request( + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.DatasetVersion], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get(self, name: str, version: str, **kwargs: Any) -> _models.DatasetVersion: + """Get a version. + + Get the specific version of the DatasetVersion. The service returns 404 Not Found error if the + DatasetVersion does not exist. + + :param name: The name of the resource. Required. + :type name: str + :param version: The specific version id of the DatasetVersion to retrieve. Required. + :type version: str :return: DatasetVersion. The DatasetVersion is compatible with MutableMapping :rtype: ~azure.ai.projects.models.DatasetVersion :raises ~azure.core.exceptions.HttpResponseError: @@ -7075,25 +8141,1683 @@ def create_or_update( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.DatasetVersion] = kwargs.pop("cls", None) + + _request = build_datasets_get_request( + name=name, + version=version, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DatasetVersion, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete(self, name: str, version: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements + """Delete a version. + + Delete the specific version of the DatasetVersion. The service returns 204 No Content if the + DatasetVersion was deleted successfully or if the DatasetVersion does not exist. + + :param name: The name of the resource. Required. + :type name: str + :param version: The version of the DatasetVersion to delete. Required. + :type version: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_datasets_delete_request( + name=name, + version=version, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @overload + def create_or_update( + self, + name: str, + version: str, + dataset_version: _models.DatasetVersion, + *, + content_type: str = "application/merge-patch+json", + **kwargs: Any + ) -> _models.DatasetVersion: + """Create or update a version. + + Create a new or update an existing DatasetVersion with the given version id. + + :param name: The name of the resource. Required. + :type name: str + :param version: The specific version id of the DatasetVersion to create or update. Required. + :type version: str + :param dataset_version: The DatasetVersion to create or update. Required. + :type dataset_version: ~azure.ai.projects.models.DatasetVersion + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/merge-patch+json". + :paramtype content_type: str + :return: DatasetVersion. The DatasetVersion is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.DatasetVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + name: str, + version: str, + dataset_version: JSON, + *, + content_type: str = "application/merge-patch+json", + **kwargs: Any + ) -> _models.DatasetVersion: + """Create or update a version. + + Create a new or update an existing DatasetVersion with the given version id. + + :param name: The name of the resource. Required. + :type name: str + :param version: The specific version id of the DatasetVersion to create or update. Required. + :type version: str + :param dataset_version: The DatasetVersion to create or update. Required. + :type dataset_version: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/merge-patch+json". + :paramtype content_type: str + :return: DatasetVersion. The DatasetVersion is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.DatasetVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + name: str, + version: str, + dataset_version: IO[bytes], + *, + content_type: str = "application/merge-patch+json", + **kwargs: Any + ) -> _models.DatasetVersion: + """Create or update a version. + + Create a new or update an existing DatasetVersion with the given version id. + + :param name: The name of the resource. Required. + :type name: str + :param version: The specific version id of the DatasetVersion to create or update. Required. + :type version: str + :param dataset_version: The DatasetVersion to create or update. Required. + :type dataset_version: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/merge-patch+json". + :paramtype content_type: str + :return: DatasetVersion. The DatasetVersion is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.DatasetVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, name: str, version: str, dataset_version: Union[_models.DatasetVersion, JSON, IO[bytes]], **kwargs: Any + ) -> _models.DatasetVersion: + """Create or update a version. + + Create a new or update an existing DatasetVersion with the given version id. + + :param name: The name of the resource. Required. + :type name: str + :param version: The specific version id of the DatasetVersion to create or update. Required. + :type version: str + :param dataset_version: The DatasetVersion to create or update. Is one of the following types: + DatasetVersion, JSON, IO[bytes] Required. + :type dataset_version: ~azure.ai.projects.models.DatasetVersion or JSON or IO[bytes] + :return: DatasetVersion. The DatasetVersion is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.DatasetVersion + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.DatasetVersion] = kwargs.pop("cls", None) + + content_type = content_type or "application/merge-patch+json" + _content = None + if isinstance(dataset_version, (IOBase, bytes)): + _content = dataset_version + else: + _content = json.dumps(dataset_version, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_datasets_create_or_update_request( + name=name, + version=version, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DatasetVersion, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @overload + def pending_upload( + self, + name: str, + version: str, + pending_upload_request: _models.PendingUploadRequest, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PendingUploadResponse: + """Start a pending upload. + + Initiates a new pending upload or retrieves an existing one for the specified dataset version. + + :param name: The name of the resource. Required. + :type name: str + :param version: The specific version id of the DatasetVersion to operate on. Required. + :type version: str + :param pending_upload_request: The pending upload request parameters. Required. + :type pending_upload_request: ~azure.ai.projects.models.PendingUploadRequest + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: PendingUploadResponse. The PendingUploadResponse is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.PendingUploadResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def pending_upload( + self, + name: str, + version: str, + pending_upload_request: JSON, + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PendingUploadResponse: + """Start a pending upload. + + Initiates a new pending upload or retrieves an existing one for the specified dataset version. + + :param name: The name of the resource. Required. + :type name: str + :param version: The specific version id of the DatasetVersion to operate on. Required. + :type version: str + :param pending_upload_request: The pending upload request parameters. Required. + :type pending_upload_request: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: PendingUploadResponse. The PendingUploadResponse is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.PendingUploadResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def pending_upload( + self, + name: str, + version: str, + pending_upload_request: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any + ) -> _models.PendingUploadResponse: + """Start a pending upload. + + Initiates a new pending upload or retrieves an existing one for the specified dataset version. + + :param name: The name of the resource. Required. + :type name: str + :param version: The specific version id of the DatasetVersion to operate on. Required. + :type version: str + :param pending_upload_request: The pending upload request parameters. Required. + :type pending_upload_request: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: PendingUploadResponse. The PendingUploadResponse is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.PendingUploadResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def pending_upload( + self, + name: str, + version: str, + pending_upload_request: Union[_models.PendingUploadRequest, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.PendingUploadResponse: + """Start a pending upload. + + Initiates a new pending upload or retrieves an existing one for the specified dataset version. + + :param name: The name of the resource. Required. + :type name: str + :param version: The specific version id of the DatasetVersion to operate on. Required. + :type version: str + :param pending_upload_request: The pending upload request parameters. Is one of the following + types: PendingUploadRequest, JSON, IO[bytes] Required. + :type pending_upload_request: ~azure.ai.projects.models.PendingUploadRequest or JSON or + IO[bytes] + :return: PendingUploadResponse. The PendingUploadResponse is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.PendingUploadResponse + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.PendingUploadResponse] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(pending_upload_request, (IOBase, bytes)): + _content = pending_upload_request + else: + _content = json.dumps(pending_upload_request, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_datasets_pending_upload_request( + name=name, + version=version, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.PendingUploadResponse, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get_credentials(self, name: str, version: str, **kwargs: Any) -> _models.DatasetCredential: + """Get dataset credentials. + + Retrieves the SAS credential to access the storage account associated with a dataset version. + + :param name: The name of the resource. Required. + :type name: str + :param version: The specific version id of the DatasetVersion to operate on. Required. + :type version: str + :return: DatasetCredential. The DatasetCredential is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.DatasetCredential + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.DatasetCredential] = kwargs.pop("cls", None) + + _request = build_datasets_get_credentials_request( + name=name, + version=version, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.DatasetCredential, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class DeploymentsOperations: # pylint: disable=docstring-missing-param + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.ai.projects.AIProjectClient`'s + :attr:`deployments` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def get(self, name: str, **kwargs: Any) -> _models.Deployment: + """Get a deployment. + + Retrieves a deployed model. + + :param name: Name of the deployment. Required. + :type name: str + :return: Deployment. The Deployment is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.Deployment + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Deployment] = kwargs.pop("cls", None) + + _request = build_deployments_get_request( + name=name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + response_headers = {} + response_headers["x-ms-client-request-id"] = self._deserialize( + "str", response.headers.get("x-ms-client-request-id") + ) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Deployment, response.json()) + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list( + self, + *, + model_publisher: Optional[str] = None, + model_name: Optional[str] = None, + deployment_type: Optional[Union[str, _models.DeploymentType]] = None, + **kwargs: Any + ) -> ItemPaged["_models.Deployment"]: + """List deployments. + + Returns the deployed models available in the current project, optionally filtered by publisher, + model name, or deployment type. + + :keyword model_publisher: Model publisher to filter models by. Default value is None. + :paramtype model_publisher: str + :keyword model_name: Model name (the publisher specific name) to filter models by. Default + value is None. + :paramtype model_name: str + :keyword deployment_type: Type of deployment to filter list by. "ModelDeployment" Default value + is None. + :paramtype deployment_type: str or ~azure.ai.projects.models.DeploymentType + :return: An iterator like instance of Deployment + :rtype: ~azure.core.paging.ItemPaged[~azure.ai.projects.models.Deployment] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Deployment]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_deployments_list_request( + model_publisher=model_publisher, + model_name=model_name, + deployment_type=deployment_type, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Deployment], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + +class IndexesOperations: # pylint: disable=docstring-missing-param + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.ai.projects.AIProjectClient`'s + :attr:`indexes` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace + def list_versions(self, name: str, **kwargs: Any) -> ItemPaged["_models.Index"]: + """List versions. + + List all versions of the given Index. + + :param name: The name of the resource. Required. + :type name: str + :return: An iterator like instance of Index + :rtype: ~azure.core.paging.ItemPaged[~azure.ai.projects.models.Index] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Index]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_indexes_list_versions_request( + name=name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Index], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list(self, **kwargs: Any) -> ItemPaged["_models.Index"]: + """List latest versions. + + List the latest version of each Index. + + :return: An iterator like instance of Index + :rtype: ~azure.core.paging.ItemPaged[~azure.ai.projects.models.Index] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.Index]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(next_link=None): + if not next_link: + + _request = build_indexes_list_request( + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + else: + # make call to next link with the client's api-version + _parsed_next_link = urllib.parse.urlparse(next_link) + _next_request_params = case_insensitive_dict( + { + key: [urllib.parse.quote(v) for v in value] + for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() + } + ) + _next_request_params["api-version"] = self._config.api_version + _request = HttpRequest( + "GET", + urllib.parse.urljoin(next_link, _parsed_next_link.path), + headers=_headers, + params=_next_request_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url( + "self._config.endpoint", self._config.endpoint, "str", skip_quote=True + ), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.Index], + deserialized.get("value", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("nextLink") or None, iter(list_of_elem) + + def get_next(next_link=None): + _request = prepare_request(next_link) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get(self, name: str, version: str, **kwargs: Any) -> _models.Index: + """Get a version. + + Get the specific version of the Index. The service returns 404 Not Found error if the Index + does not exist. + + :param name: The name of the resource. Required. + :type name: str + :param version: The specific version id of the Index to retrieve. Required. + :type version: str + :return: Index. The Index is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.Index + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.Index] = kwargs.pop("cls", None) + + _request = build_indexes_get_request( + name=name, + version=version, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Index, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def delete(self, name: str, version: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements + """Delete a version. + + Delete the specific version of the Index. The service returns 204 No Content if the Index was + deleted successfully or if the Index does not exist. + + :param name: The name of the resource. Required. + :type name: str + :param version: The version of the Index to delete. Required. + :type version: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_indexes_delete_request( + name=name, + version=version, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + @overload + def create_or_update( + self, + name: str, + version: str, + index: _models.Index, + *, + content_type: str = "application/merge-patch+json", + **kwargs: Any + ) -> _models.Index: + """Create or update a version. + + Create a new or update an existing Index with the given version id. + + :param name: The name of the resource. Required. + :type name: str + :param version: The specific version id of the Index to create or update. Required. + :type version: str + :param index: The Index to create or update. Required. + :type index: ~azure.ai.projects.models.Index + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/merge-patch+json". + :paramtype content_type: str + :return: Index. The Index is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.Index + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, name: str, version: str, index: JSON, *, content_type: str = "application/merge-patch+json", **kwargs: Any + ) -> _models.Index: + """Create or update a version. + + Create a new or update an existing Index with the given version id. + + :param name: The name of the resource. Required. + :type name: str + :param version: The specific version id of the Index to create or update. Required. + :type version: str + :param index: The Index to create or update. Required. + :type index: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/merge-patch+json". + :paramtype content_type: str + :return: Index. The Index is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.Index + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_or_update( + self, + name: str, + version: str, + index: IO[bytes], + *, + content_type: str = "application/merge-patch+json", + **kwargs: Any + ) -> _models.Index: + """Create or update a version. + + Create a new or update an existing Index with the given version id. + + :param name: The name of the resource. Required. + :type name: str + :param version: The specific version id of the Index to create or update. Required. + :type version: str + :param index: The Index to create or update. Required. + :type index: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/merge-patch+json". + :paramtype content_type: str + :return: Index. The Index is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.Index + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_or_update( + self, name: str, version: str, index: Union[_models.Index, JSON, IO[bytes]], **kwargs: Any + ) -> _models.Index: + """Create or update a version. + + Create a new or update an existing Index with the given version id. + + :param name: The name of the resource. Required. + :type name: str + :param version: The specific version id of the Index to create or update. Required. + :type version: str + :param index: The Index to create or update. Is one of the following types: Index, JSON, + IO[bytes] Required. + :type index: ~azure.ai.projects.models.Index or JSON or IO[bytes] + :return: Index. The Index is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.Index + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.Index] = kwargs.pop("cls", None) + + content_type = content_type or "application/merge-patch+json" + _content = None + if isinstance(index, (IOBase, bytes)): + _content = index + else: + _content = json.dumps(index, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_indexes_create_or_update_request( + name=name, + version=version, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200, 201]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + raise HttpResponseError(response=response) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.Index, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + +class ToolboxesOperations: # pylint: disable=docstring-missing-param + """ + .. warning:: + **DO NOT** instantiate this class directly. + + Instead, you should access the following operations through + :class:`~azure.ai.projects.AIProjectClient`'s + :attr:`toolboxes` attribute. + """ + + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") + self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @overload + def create_version( + self, + name: str, + *, + tools: List[_models.ToolboxTool], + content_type: str = "application/json", + description: Optional[str] = None, + metadata: Optional[dict[str, str]] = None, + skills: Optional[List[_models.ToolboxSkill]] = None, + policies: Optional[_models.ToolboxPolicies] = None, + **kwargs: Any + ) -> _models.ToolboxVersionObject: + """Create a new version of a toolbox. + + Creates a new toolbox version, provisioning the toolbox itself if it does not already exist. + + :param name: The name of the toolbox. If the toolbox does not exist, it will be created. + Required. + :type name: str + :keyword tools: The list of tools to include in this version. Required. + :paramtype tools: list[~azure.ai.projects.models.ToolboxTool] + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :keyword description: A human-readable description of the toolbox. Default value is None. + :paramtype description: str + :keyword metadata: Arbitrary key-value metadata to associate with the toolbox. Default value is + None. + :paramtype metadata: dict[str, str] + :keyword skills: The list of skill sources to include in this version. A skill reference + specifies a skill name and optionally a version. If version is omitted, the skill's default + version is used. Default value is None. + :paramtype skills: list[~azure.ai.projects.models.ToolboxSkill] + :keyword policies: Policy configuration for this toolbox version. Default value is None. + :paramtype policies: ~azure.ai.projects.models.ToolboxPolicies + :return: ToolboxVersionObject. The ToolboxVersionObject is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.ToolboxVersionObject + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_version( + self, name: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ToolboxVersionObject: + """Create a new version of a toolbox. + + Creates a new toolbox version, provisioning the toolbox itself if it does not already exist. + + :param name: The name of the toolbox. If the toolbox does not exist, it will be created. + Required. + :type name: str + :param body: Required. + :type body: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: ToolboxVersionObject. The ToolboxVersionObject is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.ToolboxVersionObject + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def create_version( + self, name: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ToolboxVersionObject: + """Create a new version of a toolbox. + + Creates a new toolbox version, provisioning the toolbox itself if it does not already exist. + + :param name: The name of the toolbox. If the toolbox does not exist, it will be created. + Required. + :type name: str + :param body: Required. + :type body: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: ToolboxVersionObject. The ToolboxVersionObject is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.ToolboxVersionObject + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def create_version( + self, + name: str, + body: Union[JSON, IO[bytes]] = _Unset, + *, + tools: List[_models.ToolboxTool] = _Unset, + description: Optional[str] = None, + metadata: Optional[dict[str, str]] = None, + skills: Optional[List[_models.ToolboxSkill]] = None, + policies: Optional[_models.ToolboxPolicies] = None, + **kwargs: Any + ) -> _models.ToolboxVersionObject: + """Create a new version of a toolbox. + + Creates a new toolbox version, provisioning the toolbox itself if it does not already exist. + + :param name: The name of the toolbox. If the toolbox does not exist, it will be created. + Required. + :type name: str + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :keyword tools: The list of tools to include in this version. Required. + :paramtype tools: list[~azure.ai.projects.models.ToolboxTool] + :keyword description: A human-readable description of the toolbox. Default value is None. + :paramtype description: str + :keyword metadata: Arbitrary key-value metadata to associate with the toolbox. Default value is + None. + :paramtype metadata: dict[str, str] + :keyword skills: The list of skill sources to include in this version. A skill reference + specifies a skill name and optionally a version. If version is omitted, the skill's default + version is used. Default value is None. + :paramtype skills: list[~azure.ai.projects.models.ToolboxSkill] + :keyword policies: Policy configuration for this toolbox version. Default value is None. + :paramtype policies: ~azure.ai.projects.models.ToolboxPolicies + :return: ToolboxVersionObject. The ToolboxVersionObject is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.ToolboxVersionObject + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.ToolboxVersionObject] = kwargs.pop("cls", None) + + if body is _Unset: + if tools is _Unset: + raise TypeError("missing required argument: tools") + body = { + "description": description, + "metadata": metadata, + "policies": policies, + "skills": skills, + "tools": tools, + } + body = {k: v for k, v in body.items() if v is not None} + content_type = content_type or "application/json" + _content = None + if isinstance(body, (IOBase, bytes)): + _content = body + else: + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_toolboxes_create_version_request( + name=name, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ToolboxVersionObject, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def get(self, name: str, **kwargs: Any) -> _models.ToolboxObject: + """Retrieve a toolbox. + + Retrieves the specified toolbox and its current configuration. + + :param name: The name of the toolbox to retrieve. Required. + :type name: str + :return: ToolboxObject. The ToolboxObject is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.ToolboxObject + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[_models.ToolboxObject] = kwargs.pop("cls", None) + + _request = build_toolboxes_get_request( + name=name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [200]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.ToolboxObject, response.json()) + + if cls: + return cls(pipeline_response, deserialized, {}) # type: ignore + + return deserialized # type: ignore + + @distributed_trace + def list( + self, + *, + limit: Optional[int] = None, + order: Optional[Union[str, _models.PageOrder]] = None, + before: Optional[str] = None, + **kwargs: Any + ) -> ItemPaged["_models.ToolboxObject"]: + """List toolboxes. + + Returns the toolboxes available in the current project. + + :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and + 100, and the + default is 20. Default value is None. + :paramtype limit: int + :keyword order: Sort order by the ``created_at`` timestamp of the objects. ``asc`` for + ascending order and``desc`` + for descending order. Known values are: "asc" and "desc". Default value is None. + :paramtype order: str or ~azure.ai.projects.models.PageOrder + :keyword before: A cursor for use in pagination. ``before`` is an object ID that defines your + place in the list. + For instance, if you make a list request and receive 100 objects, ending with obj_foo, your + subsequent call can include before=obj_foo in order to fetch the previous page of the list. + Default value is None. + :paramtype before: str + :return: An iterator like instance of ToolboxObject + :rtype: ~azure.core.paging.ItemPaged[~azure.ai.projects.models.ToolboxObject] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ToolboxObject]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(_continuation_token=None): + + _request = build_toolboxes_list_request( + limit=limit, + order=order, + after=_continuation_token, + before=before, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ToolboxObject], + deserialized.get("data", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("last_id") or None, iter(list_of_elem) + + def get_next(_continuation_token=None): + _request = prepare_request(_continuation_token) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def list_versions( + self, + name: str, + *, + limit: Optional[int] = None, + order: Optional[Union[str, _models.PageOrder]] = None, + before: Optional[str] = None, + **kwargs: Any + ) -> ItemPaged["_models.ToolboxVersionObject"]: + """List toolbox versions. + + Returns the available versions for the specified toolbox. + + :param name: The name of the toolbox to list versions for. Required. + :type name: str + :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and + 100, and the + default is 20. Default value is None. + :paramtype limit: int + :keyword order: Sort order by the ``created_at`` timestamp of the objects. ``asc`` for + ascending order and``desc`` + for descending order. Known values are: "asc" and "desc". Default value is None. + :paramtype order: str or ~azure.ai.projects.models.PageOrder + :keyword before: A cursor for use in pagination. ``before`` is an object ID that defines your + place in the list. + For instance, if you make a list request and receive 100 objects, ending with obj_foo, your + subsequent call can include before=obj_foo in order to fetch the previous page of the list. + Default value is None. + :paramtype before: str + :return: An iterator like instance of ToolboxVersionObject + :rtype: ~azure.core.paging.ItemPaged[~azure.ai.projects.models.ToolboxVersionObject] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.ToolboxVersionObject]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + def prepare_request(_continuation_token=None): + + _request = build_toolboxes_list_versions_request( + name=name, + limit=limit, + order=order, + after=_continuation_token, + before=before, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + return _request + + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.ToolboxVersionObject], + deserialized.get("data", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("last_id") or None, iter(list_of_elem) + + def get_next(_continuation_token=None): + _request = prepare_request(_continuation_token) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + return pipeline_response + + return ItemPaged(get_next, extract_data) + + @distributed_trace + def get_version(self, name: str, version: str, **kwargs: Any) -> _models.ToolboxVersionObject: + """Retrieve a specific version of a toolbox. + + Retrieves the specified version of a toolbox by name and version identifier. + + :param name: The name of the toolbox. Required. + :type name: str + :param version: The version identifier to retrieve. Required. + :type version: str + :return: ToolboxVersionObject. The ToolboxVersionObject is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.ToolboxVersionObject + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.DatasetVersion] = kwargs.pop("cls", None) - - content_type = content_type or "application/merge-patch+json" - _content = None - if isinstance(dataset_version, (IOBase, bytes)): - _content = dataset_version - else: - _content = json.dumps(dataset_version, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + cls: ClsType[_models.ToolboxVersionObject] = kwargs.pop("cls", None) - _request = build_datasets_create_or_update_request( + _request = build_toolboxes_get_version_request( name=name, version=version, - content_type=content_type, api_version=self._config.api_version, - content=_content, headers=_headers, params=_params, ) @@ -7110,19 +9834,23 @@ def create_or_update( response = pipeline_response.http_response - if response.status_code not in [200, 201]: + if response.status_code not in [200]: if _stream: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.DatasetVersion, response.json()) + deserialized = _deserialize(_models.ToolboxVersionObject, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -7130,111 +9858,83 @@ def create_or_update( return deserialized # type: ignore @overload - def pending_upload( - self, - name: str, - version: str, - pending_upload_request: _models.PendingUploadRequest, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.PendingUploadResponse: - """Start a pending upload. + def update( + self, name: str, *, default_version: str, content_type: str = "application/json", **kwargs: Any + ) -> _models.ToolboxObject: + """Update a toolbox to point to a specific version. - Initiates a new pending upload or retrieves an existing one for the specified dataset version. + Updates the toolbox's default version pointer to the specified version. - :param name: The name of the resource. Required. + :param name: The name of the toolbox to update. Required. :type name: str - :param version: The specific version id of the DatasetVersion to operate on. Required. - :type version: str - :param pending_upload_request: The pending upload request parameters. Required. - :type pending_upload_request: ~azure.ai.projects.models.PendingUploadRequest + :keyword default_version: The version identifier that the toolbox should point to. When set, + the toolbox's default version will resolve to this version instead of the latest. Required. + :paramtype default_version: str :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: PendingUploadResponse. The PendingUploadResponse is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.PendingUploadResponse + :return: ToolboxObject. The ToolboxObject is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.ToolboxObject :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def pending_upload( - self, - name: str, - version: str, - pending_upload_request: JSON, - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.PendingUploadResponse: - """Start a pending upload. + def update( + self, name: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ToolboxObject: + """Update a toolbox to point to a specific version. - Initiates a new pending upload or retrieves an existing one for the specified dataset version. + Updates the toolbox's default version pointer to the specified version. - :param name: The name of the resource. Required. + :param name: The name of the toolbox to update. Required. :type name: str - :param version: The specific version id of the DatasetVersion to operate on. Required. - :type version: str - :param pending_upload_request: The pending upload request parameters. Required. - :type pending_upload_request: JSON + :param body: Required. + :type body: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :return: PendingUploadResponse. The PendingUploadResponse is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.PendingUploadResponse + :return: ToolboxObject. The ToolboxObject is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.ToolboxObject :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def pending_upload( - self, - name: str, - version: str, - pending_upload_request: IO[bytes], - *, - content_type: str = "application/json", - **kwargs: Any - ) -> _models.PendingUploadResponse: - """Start a pending upload. + def update( + self, name: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.ToolboxObject: + """Update a toolbox to point to a specific version. - Initiates a new pending upload or retrieves an existing one for the specified dataset version. + Updates the toolbox's default version pointer to the specified version. - :param name: The name of the resource. Required. + :param name: The name of the toolbox to update. Required. :type name: str - :param version: The specific version id of the DatasetVersion to operate on. Required. - :type version: str - :param pending_upload_request: The pending upload request parameters. Required. - :type pending_upload_request: IO[bytes] + :param body: Required. + :type body: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. Default value is "application/json". :paramtype content_type: str - :return: PendingUploadResponse. The PendingUploadResponse is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.PendingUploadResponse + :return: ToolboxObject. The ToolboxObject is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.ToolboxObject :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def pending_upload( - self, - name: str, - version: str, - pending_upload_request: Union[_models.PendingUploadRequest, JSON, IO[bytes]], - **kwargs: Any - ) -> _models.PendingUploadResponse: - """Start a pending upload. + def update( + self, name: str, body: Union[JSON, IO[bytes]] = _Unset, *, default_version: str = _Unset, **kwargs: Any + ) -> _models.ToolboxObject: + """Update a toolbox to point to a specific version. - Initiates a new pending upload or retrieves an existing one for the specified dataset version. + Updates the toolbox's default version pointer to the specified version. - :param name: The name of the resource. Required. + :param name: The name of the toolbox to update. Required. :type name: str - :param version: The specific version id of the DatasetVersion to operate on. Required. - :type version: str - :param pending_upload_request: The pending upload request parameters. Is one of the following - types: PendingUploadRequest, JSON, IO[bytes] Required. - :type pending_upload_request: ~azure.ai.projects.models.PendingUploadRequest or JSON or - IO[bytes] - :return: PendingUploadResponse. The PendingUploadResponse is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.PendingUploadResponse + :param body: Is either a JSON type or a IO[bytes] type. Required. + :type body: JSON or IO[bytes] + :keyword default_version: The version identifier that the toolbox should point to. When set, + the toolbox's default version will resolve to this version instead of the latest. Required. + :paramtype default_version: str + :return: ToolboxObject. The ToolboxObject is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.ToolboxObject :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -7249,18 +9949,22 @@ def pending_upload( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.PendingUploadResponse] = kwargs.pop("cls", None) + cls: ClsType[_models.ToolboxObject] = kwargs.pop("cls", None) + if body is _Unset: + if default_version is _Unset: + raise TypeError("missing required argument: default_version") + body = {"default_version": default_version} + body = {k: v for k, v in body.items() if v is not None} content_type = content_type or "application/json" _content = None - if isinstance(pending_upload_request, (IOBase, bytes)): - _content = pending_upload_request + if isinstance(body, (IOBase, bytes)): + _content = body else: - _content = json.dumps(pending_upload_request, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_datasets_pending_upload_request( + _request = build_toolboxes_update_request( name=name, - version=version, content_type=content_type, api_version=self._config.api_version, content=_content, @@ -7287,112 +9991,32 @@ def pending_upload( except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - deserialized = _deserialize(_models.PendingUploadResponse, response.json()) - - if cls: - return cls(pipeline_response, deserialized, {}) # type: ignore - - return deserialized # type: ignore - - @distributed_trace - def get_credentials(self, name: str, version: str, **kwargs: Any) -> _models.DatasetCredential: - """Get dataset credentials. - - Retrieves the SAS credential to access the storage account associated with a dataset version. - - :param name: The name of the resource. Required. - :type name: str - :param version: The specific version id of the DatasetVersion to operate on. Required. - :type version: str - :return: DatasetCredential. The DatasetCredential is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.DatasetCredential - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[_models.DatasetCredential] = kwargs.pop("cls", None) - - _request = build_datasets_get_credentials_request( - name=name, - version=version, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [200]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.DatasetCredential, response.json()) + deserialized = _deserialize(_models.ToolboxObject, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - -class DeploymentsOperations: # pylint: disable=docstring-missing-param - """ - .. warning:: - **DO NOT** instantiate this class directly. - - Instead, you should access the following operations through - :class:`~azure.ai.projects.AIProjectClient`'s - :attr:`deployments` attribute. - """ - - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") - @distributed_trace - def get(self, name: str, **kwargs: Any) -> _models.Deployment: - """Get a deployment. + def delete(self, name: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements + """Delete a toolbox. - Retrieves a deployed model. + Removes the specified toolbox along with all of its versions. - :param name: Name of the deployment. Required. + :param name: The name of the toolbox to delete. Required. :type name: str - :return: Deployment. The Deployment is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.Deployment + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -7406,9 +10030,9 @@ def get(self, name: str, **kwargs: Any) -> _models.Deployment: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.Deployment] = kwargs.pop("cls", None) + cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_deployments_get_request( + _request = build_toolboxes_delete_request( name=name, api_version=self._config.api_version, headers=_headers, @@ -7419,69 +10043,40 @@ def get(self, name: str, **kwargs: Any) -> _models.Deployment: } _request.url = self._client.format_url(_request.url, **path_format_arguments) - _decompress = kwargs.pop("decompress", True) - _stream = kwargs.pop("stream", False) + _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access _request, stream=_stream, **kwargs ) response = pipeline_response.http_response - if response.status_code not in [200]: - if _stream: - try: - response.read() # Load the body in memory and close the socket - except (StreamConsumedError, StreamClosedError): - pass + if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - response_headers = {} - response_headers["x-ms-client-request-id"] = self._deserialize( - "str", response.headers.get("x-ms-client-request-id") - ) - - if _stream: - deserialized = response.iter_bytes() if _decompress else response.iter_raw() - else: - deserialized = _deserialize(_models.Deployment, response.json()) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) if cls: - return cls(pipeline_response, deserialized, response_headers) # type: ignore - - return deserialized # type: ignore + return cls(pipeline_response, None, {}) # type: ignore @distributed_trace - def list( - self, - *, - model_publisher: Optional[str] = None, - model_name: Optional[str] = None, - deployment_type: Optional[Union[str, _models.DeploymentType]] = None, - **kwargs: Any - ) -> ItemPaged["_models.Deployment"]: - """List deployments. + def delete_version( # pylint: disable=inconsistent-return-statements + self, name: str, version: str, **kwargs: Any + ) -> None: + """Delete a specific version of a toolbox. - Returns the deployed models available in the current project, optionally filtered by publisher, - model name, or deployment type. + Removes the specified version of a toolbox. - :keyword model_publisher: Model publisher to filter models by. Default value is None. - :paramtype model_publisher: str - :keyword model_name: Model name (the publisher specific name) to filter models by. Default - value is None. - :paramtype model_name: str - :keyword deployment_type: Type of deployment to filter list by. "ModelDeployment" Default value - is None. - :paramtype deployment_type: str or ~azure.ai.projects.models.DeploymentType - :return: An iterator like instance of Deployment - :rtype: ~azure.core.paging.ItemPaged[~azure.ai.projects.models.Deployment] + :param name: The name of the toolbox. Required. + :type name: str + :param version: The version identifier to delete. Required. + :type version: str + :return: None + :rtype: None :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.Deployment]] = kwargs.pop("cls", None) - error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -7490,85 +10085,50 @@ def list( } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - _request = build_deployments_list_request( - model_publisher=model_publisher, - model_name=model_name, - deployment_type=deployment_type, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + cls: ClsType[None] = kwargs.pop("cls", None) - return _request + _request = build_toolboxes_delete_version_request( + name=name, + version=version, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize( - List[_models.Deployment], - deserialized.get("value", []), - ) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, iter(list_of_elem) + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - def get_next(next_link=None): - _request = prepare_request(next_link) + response = pipeline_response.http_response - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) - - return pipeline_response + raise HttpResponseError(response=response, model=error) - return ItemPaged(get_next, extract_data) + if cls: + return cls(pipeline_response, None, {}) # type: ignore -class IndexesOperations: # pylint: disable=docstring-missing-param +class BetaAgentInsightMonitorsOperations: # pylint: disable=docstring-missing-param """ .. warning:: **DO NOT** instantiate this class directly. Instead, you should access the following operations through :class:`~azure.ai.projects.AIProjectClient`'s - :attr:`indexes` attribute. + :attr:`agent_insight_monitors` attribute. """ def __init__(self, *args, **kwargs) -> None: @@ -7579,21 +10139,35 @@ def __init__(self, *args, **kwargs) -> None: self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") @distributed_trace - def list_versions(self, name: str, **kwargs: Any) -> ItemPaged["_models.Index"]: - """List versions. - - List all versions of the given Index. + def list( + self, + *, + before: Optional[str] = None, + limit: Optional[int] = None, + order: Optional[Union[str, _models.PageOrder]] = None, + agent_name: Optional[str] = None, + **kwargs: Any + ) -> ItemPaged["_models.AgentInsightMonitorListItem"]: + """List Agent Insights monitors, optionally filtered by agent name. - :param name: The name of the resource. Required. - :type name: str - :return: An iterator like instance of Index - :rtype: ~azure.core.paging.ItemPaged[~azure.ai.projects.models.Index] + :keyword before: A cursor that identifies the first item in the next page. Default value is + None. + :paramtype before: str + :keyword limit: The maximum number of items to return. Defaults to 20. Default value is None. + :paramtype limit: int + :keyword order: Sort order by creation time. Defaults to descending. Known values are: "asc" + and "desc". Default value is None. + :paramtype order: str or ~azure.ai.projects.models.PageOrder + :keyword agent_name: Filter monitors by agent name. Default value is None. + :paramtype agent_name: str + :return: An iterator like instance of AgentInsightMonitorListItem + :rtype: ~azure.core.paging.ItemPaged[~azure.ai.projects.models.AgentInsightMonitorListItem] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.Index]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.AgentInsightMonitorListItem]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -7603,59 +10177,36 @@ def list_versions(self, name: str, **kwargs: Any) -> ItemPaged["_models.Index"]: } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: - - _request = build_indexes_list_versions_request( - name=name, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + def prepare_request(_continuation_token=None): + _request = build_beta_agent_insight_monitors_list_request( + after=_continuation_token, + before=before, + limit=limit, + order=order, + agent_name=agent_name, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) return _request def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() list_of_elem = _deserialize( - List[_models.Index], - deserialized.get("value", []), + List[_models.AgentInsightMonitorListItem], + deserialized.get("data", []), ) if cls: list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, iter(list_of_elem) + return deserialized.get("last_id") or None, iter(list_of_elem) - def get_next(next_link=None): - _request = prepare_request(next_link) + def get_next(_continuation_token=None): + _request = prepare_request(_continuation_token) _stream = False pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access @@ -7665,27 +10216,77 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) return pipeline_response return ItemPaged(get_next, extract_data) - @distributed_trace - def list(self, **kwargs: Any) -> ItemPaged["_models.Index"]: - """List latest versions. + @overload + def create( + self, monitor: _models.AgentInsightMonitorCreate, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.AgentInsightMonitor: + """Create an Agent Insights monitor for an agent. - List the latest version of each Index. + :param monitor: The monitor to create. Required. + :type monitor: ~azure.ai.projects.models.AgentInsightMonitorCreate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: AgentInsightMonitor. The AgentInsightMonitor is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.AgentInsightMonitor + :raises ~azure.core.exceptions.HttpResponseError: + """ - :return: An iterator like instance of Index - :rtype: ~azure.core.paging.ItemPaged[~azure.ai.projects.models.Index] + @overload + def create( + self, monitor: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> _models.AgentInsightMonitor: + """Create an Agent Insights monitor for an agent. + + :param monitor: The monitor to create. Required. + :type monitor: JSON + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: AgentInsightMonitor. The AgentInsightMonitor is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.AgentInsightMonitor :raises ~azure.core.exceptions.HttpResponseError: """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.Index]] = kwargs.pop("cls", None) + @overload + def create( + self, monitor: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> _models.AgentInsightMonitor: + """Create an Agent Insights monitor for an agent. + + :param monitor: The monitor to create. Required. + :type monitor: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: AgentInsightMonitor. The AgentInsightMonitor is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.AgentInsightMonitor + :raises ~azure.core.exceptions.HttpResponseError: + """ + @distributed_trace + def create( + self, monitor: Union[_models.AgentInsightMonitorCreate, JSON, IO[bytes]], **kwargs: Any + ) -> _models.AgentInsightMonitor: + """Create an Agent Insights monitor for an agent. + + :param monitor: The monitor to create. Is one of the following types: + AgentInsightMonitorCreate, JSON, IO[bytes] Required. + :type monitor: ~azure.ai.projects.models.AgentInsightMonitorCreate or JSON or IO[bytes] + :return: AgentInsightMonitor. The AgentInsightMonitor is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.AgentInsightMonitor + :raises ~azure.core.exceptions.HttpResponseError: + """ error_map: MutableMapping = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, @@ -7694,86 +10295,73 @@ def list(self, **kwargs: Any) -> ItemPaged["_models.Index"]: } error_map.update(kwargs.pop("error_map", {}) or {}) - def prepare_request(next_link=None): - if not next_link: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} - _request = build_indexes_list_request( - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AgentInsightMonitor] = kwargs.pop("cls", None) - else: - # make call to next link with the client's api-version - _parsed_next_link = urllib.parse.urlparse(next_link) - _next_request_params = case_insensitive_dict( - { - key: [urllib.parse.quote(v) for v in value] - for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items() - } - ) - _next_request_params["api-version"] = self._config.api_version - _request = HttpRequest( - "GET", - urllib.parse.urljoin(next_link, _parsed_next_link.path), - headers=_headers, - params=_next_request_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url( - "self._config.endpoint", self._config.endpoint, "str", skip_quote=True - ), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) + content_type = content_type or "application/json" + _content = None + if isinstance(monitor, (IOBase, bytes)): + _content = monitor + else: + _content = json.dumps(monitor, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - return _request + _request = build_beta_agent_insight_monitors_create_request( + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) - def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize( - List[_models.Index], - deserialized.get("value", []), - ) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("nextLink") or None, iter(list_of_elem) + _decompress = kwargs.pop("decompress", True) + _stream = kwargs.pop("stream", False) + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) - def get_next(next_link=None): - _request = prepare_request(next_link) + response = pipeline_response.http_response - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs + if response.status_code not in [201]: + if _stream: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, ) - response = pipeline_response.http_response + raise HttpResponseError(response=response, model=error) - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + response_headers = {} + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) - return pipeline_response + if _stream: + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + else: + deserialized = _deserialize(_models.AgentInsightMonitor, response.json()) - return ItemPaged(get_next, extract_data) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore - @distributed_trace - def get(self, name: str, version: str, **kwargs: Any) -> _models.Index: - """Get a version. + return deserialized # type: ignore - Get the specific version of the Index. The service returns 404 Not Found error if the Index - does not exist. + @distributed_trace + def get(self, monitor_id: str, **kwargs: Any) -> _models.AgentInsightMonitor: + """Get an Agent Insights monitor. - :param name: The name of the resource. Required. - :type name: str - :param version: The specific version id of the Index to retrieve. Required. - :type version: str - :return: Index. The Index is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.Index + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :return: AgentInsightMonitor. The AgentInsightMonitor is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.AgentInsightMonitor :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -7787,11 +10375,10 @@ def get(self, name: str, version: str, **kwargs: Any) -> _models.Index: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.Index] = kwargs.pop("cls", None) + cls: ClsType[_models.AgentInsightMonitor] = kwargs.pop("cls", None) - _request = build_indexes_get_request( - name=name, - version=version, + _request = build_beta_agent_insight_monitors_get_request( + monitor_id=monitor_id, api_version=self._config.api_version, headers=_headers, params=_params, @@ -7816,12 +10403,16 @@ def get(self, name: str, version: str, **kwargs: Any) -> _models.Index: except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.Index, response.json()) + deserialized = _deserialize(_models.AgentInsightMonitor, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -7829,16 +10420,11 @@ def get(self, name: str, version: str, **kwargs: Any) -> _models.Index: return deserialized # type: ignore @distributed_trace - def delete(self, name: str, version: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements - """Delete a version. - - Delete the specific version of the Index. The service returns 204 No Content if the Index was - deleted successfully or if the Index does not exist. + def delete(self, monitor_id: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements + """Delete an Agent Insights monitor and all of its runs, insights, and state. - :param name: The name of the resource. Required. - :type name: str - :param version: The version of the Index to delete. Required. - :type version: str + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str :return: None :rtype: None :raises ~azure.core.exceptions.HttpResponseError: @@ -7856,9 +10442,8 @@ def delete(self, name: str, version: str, **kwargs: Any) -> None: # pylint: dis cls: ClsType[None] = kwargs.pop("cls", None) - _request = build_indexes_delete_request( - name=name, - version=version, + _request = build_beta_agent_insight_monitors_delete_request( + monitor_id=monitor_id, api_version=self._config.api_version, headers=_headers, params=_params, @@ -7877,106 +10462,87 @@ def delete(self, name: str, version: str, **kwargs: Any) -> None: # pylint: dis if response.status_code not in [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) if cls: return cls(pipeline_response, None, {}) # type: ignore @overload - def create_or_update( + def update( self, - name: str, - version: str, - index: _models.Index, + monitor_id: str, + monitor: _models.AgentInsightMonitorUpdate, *, content_type: str = "application/merge-patch+json", **kwargs: Any - ) -> _models.Index: - """Create or update a version. - - Create a new or update an existing Index with the given version id. + ) -> _models.AgentInsightMonitor: + """Update an Agent Insights monitor. - :param name: The name of the resource. Required. - :type name: str - :param version: The specific version id of the Index to create or update. Required. - :type version: str - :param index: The Index to create or update. Required. - :type index: ~azure.ai.projects.models.Index + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :param monitor: The monitor fields to update. Required. + :type monitor: ~azure.ai.projects.models.AgentInsightMonitorUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/merge-patch+json". :paramtype content_type: str - :return: Index. The Index is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.Index + :return: AgentInsightMonitor. The AgentInsightMonitor is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.AgentInsightMonitor :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def create_or_update( - self, name: str, version: str, index: JSON, *, content_type: str = "application/merge-patch+json", **kwargs: Any - ) -> _models.Index: - """Create or update a version. - - Create a new or update an existing Index with the given version id. - - :param name: The name of the resource. Required. - :type name: str - :param version: The specific version id of the Index to create or update. Required. - :type version: str - :param index: The Index to create or update. Required. - :type index: JSON + def update( + self, monitor_id: str, monitor: JSON, *, content_type: str = "application/merge-patch+json", **kwargs: Any + ) -> _models.AgentInsightMonitor: + """Update an Agent Insights monitor. + + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :param monitor: The monitor fields to update. Required. + :type monitor: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/merge-patch+json". :paramtype content_type: str - :return: Index. The Index is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.Index + :return: AgentInsightMonitor. The AgentInsightMonitor is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.AgentInsightMonitor :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def create_or_update( - self, - name: str, - version: str, - index: IO[bytes], - *, - content_type: str = "application/merge-patch+json", - **kwargs: Any - ) -> _models.Index: - """Create or update a version. - - Create a new or update an existing Index with the given version id. - - :param name: The name of the resource. Required. - :type name: str - :param version: The specific version id of the Index to create or update. Required. - :type version: str - :param index: The Index to create or update. Required. - :type index: IO[bytes] + def update( + self, monitor_id: str, monitor: IO[bytes], *, content_type: str = "application/merge-patch+json", **kwargs: Any + ) -> _models.AgentInsightMonitor: + """Update an Agent Insights monitor. + + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :param monitor: The monitor fields to update. Required. + :type monitor: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/merge-patch+json". - :paramtype content_type: str - :return: Index. The Index is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.Index - :raises ~azure.core.exceptions.HttpResponseError: - """ - - @distributed_trace - def create_or_update( - self, name: str, version: str, index: Union[_models.Index, JSON, IO[bytes]], **kwargs: Any - ) -> _models.Index: - """Create or update a version. - - Create a new or update an existing Index with the given version id. - - :param name: The name of the resource. Required. - :type name: str - :param version: The specific version id of the Index to create or update. Required. - :type version: str - :param index: The Index to create or update. Is one of the following types: Index, JSON, - IO[bytes] Required. - :type index: ~azure.ai.projects.models.Index or JSON or IO[bytes] - :return: Index. The Index is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.Index + Default value is "application/merge-patch+json". + :paramtype content_type: str + :return: AgentInsightMonitor. The AgentInsightMonitor is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.AgentInsightMonitor + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def update( + self, monitor_id: str, monitor: Union[_models.AgentInsightMonitorUpdate, JSON, IO[bytes]], **kwargs: Any + ) -> _models.AgentInsightMonitor: + """Update an Agent Insights monitor. + + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :param monitor: The monitor fields to update. Is one of the following types: + AgentInsightMonitorUpdate, JSON, IO[bytes] Required. + :type monitor: ~azure.ai.projects.models.AgentInsightMonitorUpdate or JSON or IO[bytes] + :return: AgentInsightMonitor. The AgentInsightMonitor is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.AgentInsightMonitor :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -7991,18 +10557,17 @@ def create_or_update( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.Index] = kwargs.pop("cls", None) + cls: ClsType[_models.AgentInsightMonitor] = kwargs.pop("cls", None) content_type = content_type or "application/merge-patch+json" _content = None - if isinstance(index, (IOBase, bytes)): - _content = index + if isinstance(monitor, (IOBase, bytes)): + _content = monitor else: - _content = json.dumps(index, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = json.dumps(monitor, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_indexes_create_or_update_request( - name=name, - version=version, + _request = build_beta_agent_insight_monitors_update_request( + monitor_id=monitor_id, content_type=content_type, api_version=self._config.api_version, content=_content, @@ -8022,163 +10587,395 @@ def create_or_update( response = pipeline_response.http_response - if response.status_code not in [200, 201]: + if response.status_code not in [200]: if _stream: try: response.read() # Load the body in memory and close the socket except (StreamConsumedError, StreamClosedError): pass map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.Index, response.json()) + deserialized = _deserialize(_models.AgentInsightMonitor, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore + @distributed_trace + def reset(self, monitor_id: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements + """Reset an Agent Insights monitor's overview, checkpoint, and active insight state. -class ToolboxesOperations: # pylint: disable=docstring-missing-param - """ - .. warning:: - **DO NOT** instantiate this class directly. + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :return: None + :rtype: None + :raises ~azure.core.exceptions.HttpResponseError: + """ + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - Instead, you should access the following operations through - :class:`~azure.ai.projects.AIProjectClient`'s - :attr:`toolboxes` attribute. - """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} - def __init__(self, *args, **kwargs) -> None: - input_args = list(args) - self._client: PipelineClient = input_args.pop(0) if input_args else kwargs.pop("client") - self._config: AIProjectClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config") - self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer") - self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer") + cls: ClsType[None] = kwargs.pop("cls", None) + + _request = build_beta_agent_insight_monitors_reset_request( + monitor_id=monitor_id, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + if cls: + return cls(pipeline_response, None, {}) # type: ignore + + def _create_run_initial( + self, monitor_id: str, run: Union[_models.AgentInsightRunCreate, JSON, IO[bytes]], **kwargs: Any + ) -> Iterator[bytes]: + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[Iterator[bytes]] = kwargs.pop("cls", None) + + content_type = content_type or "application/json" + _content = None + if isinstance(run, (IOBase, bytes)): + _content = run + else: + _content = json.dumps(run, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + + _request = build_beta_agent_insight_monitors_create_run_request( + monitor_id=monitor_id, + content_type=content_type, + api_version=self._config.api_version, + content=_content, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + + _decompress = kwargs.pop("decompress", True) + _stream = True + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + + response = pipeline_response.http_response + + if response.status_code not in [201]: + try: + response.read() # Load the body in memory and close the socket + except (StreamConsumedError, StreamClosedError): + pass + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) + + response_headers = {} + response_headers["Operation-Location"] = self._deserialize("str", response.headers.get("Operation-Location")) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = response.iter_bytes() if _decompress else response.iter_raw() + + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + + return deserialized # type: ignore @overload - def create_version( + def begin_create_run( self, - name: str, + monitor_id: str, + run: _models.AgentInsightRunCreate, *, - tools: List[_models.ToolboxTool], content_type: str = "application/json", - description: Optional[str] = None, - metadata: Optional[dict[str, str]] = None, - skills: Optional[List[_models.ToolboxSkill]] = None, - policies: Optional[_models.ToolboxPolicies] = None, **kwargs: Any - ) -> _models.ToolboxVersionObject: - """Create a new version of a toolbox. + ) -> LROPoller[_models.AgentInsightRunResult]: + """Start an Agent Insights run for a monitor. - Creates a new toolbox version, provisioning the toolbox itself if it does not already exist. + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :param run: Run inputs. Send an empty object to use the default 168-hour lookback window. + Required. + :type run: ~azure.ai.projects.models.AgentInsightRunCreate + :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns AgentInsightRunResult. The AgentInsightRunResult + is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.ai.projects.models.AgentInsightRunResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ - :param name: The name of the toolbox. If the toolbox does not exist, it will be created. + @overload + def begin_create_run( + self, monitor_id: str, run: JSON, *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.AgentInsightRunResult]: + """Start an Agent Insights run for a monitor. + + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :param run: Run inputs. Send an empty object to use the default 168-hour lookback window. Required. - :type name: str - :keyword tools: The list of tools to include in this version. Required. - :paramtype tools: list[~azure.ai.projects.models.ToolboxTool] + :type run: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. Default value is "application/json". :paramtype content_type: str - :keyword description: A human-readable description of the toolbox. Default value is None. - :paramtype description: str - :keyword metadata: Arbitrary key-value metadata to associate with the toolbox. Default value is + :return: An instance of LROPoller that returns AgentInsightRunResult. The AgentInsightRunResult + is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.ai.projects.models.AgentInsightRunResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @overload + def begin_create_run( + self, monitor_id: str, run: IO[bytes], *, content_type: str = "application/json", **kwargs: Any + ) -> LROPoller[_models.AgentInsightRunResult]: + """Start an Agent Insights run for a monitor. + + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :param run: Run inputs. Send an empty object to use the default 168-hour lookback window. + Required. + :type run: IO[bytes] + :keyword content_type: Body Parameter content-type. Content type parameter for binary body. + Default value is "application/json". + :paramtype content_type: str + :return: An instance of LROPoller that returns AgentInsightRunResult. The AgentInsightRunResult + is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.ai.projects.models.AgentInsightRunResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + + @distributed_trace + def begin_create_run( + self, monitor_id: str, run: Union[_models.AgentInsightRunCreate, JSON, IO[bytes]], **kwargs: Any + ) -> LROPoller[_models.AgentInsightRunResult]: + """Start an Agent Insights run for a monitor. + + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :param run: Run inputs. Send an empty object to use the default 168-hour lookback window. Is + one of the following types: AgentInsightRunCreate, JSON, IO[bytes] Required. + :type run: ~azure.ai.projects.models.AgentInsightRunCreate or JSON or IO[bytes] + :return: An instance of LROPoller that returns AgentInsightRunResult. The AgentInsightRunResult + is compatible with MutableMapping + :rtype: ~azure.core.polling.LROPoller[~azure.ai.projects.models.AgentInsightRunResult] + :raises ~azure.core.exceptions.HttpResponseError: + """ + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) + cls: ClsType[_models.AgentInsightRunResult] = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + cont_token: Optional[str] = kwargs.pop("continuation_token", None) + if cont_token is None: + raw_result = self._create_run_initial( + monitor_id=monitor_id, + run=run, + content_type=content_type, + cls=lambda x, y, z: x, + headers=_headers, + params=_params, + **kwargs + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Operation-Location"] = self._deserialize( + "str", response.headers.get("Operation-Location") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = _deserialize(_models.AgentInsightRunResult, response.json().get("result", {})) + if cls: + return cls(pipeline_response, deserialized, response_headers) # type: ignore + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, LROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if cont_token: + return LROPoller[_models.AgentInsightRunResult].from_continuation_token( + polling_method=polling_method, + continuation_token=cont_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + return LROPoller[_models.AgentInsightRunResult]( + self._client, raw_result, get_long_running_output, polling_method # type: ignore + ) + + @distributed_trace + def list_runs( + self, + monitor_id: str, + *, + before: Optional[str] = None, + limit: Optional[int] = None, + order: Optional[Union[str, _models.PageOrder]] = None, + status: Optional[Union[str, _models.JobStatus]] = None, + trigger: Optional[Union[str, _models.AgentInsightRunTrigger]] = None, + **kwargs: Any + ) -> ItemPaged["_models.AgentInsightRun"]: + """List Agent Insights runs for a monitor. + + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :keyword before: A cursor that identifies the first item in the next page. Default value is None. - :paramtype metadata: dict[str, str] - :keyword skills: The list of skill sources to include in this version. A skill reference - specifies a skill name and optionally a version. If version is omitted, the skill's default - version is used. Default value is None. - :paramtype skills: list[~azure.ai.projects.models.ToolboxSkill] - :keyword policies: Policy configuration for this toolbox version. Default value is None. - :paramtype policies: ~azure.ai.projects.models.ToolboxPolicies - :return: ToolboxVersionObject. The ToolboxVersionObject is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.ToolboxVersionObject + :paramtype before: str + :keyword limit: The maximum number of items to return. Defaults to 20. Default value is None. + :paramtype limit: int + :keyword order: Sort order by creation time. Defaults to descending. Known values are: "asc" + and "desc". Default value is None. + :paramtype order: str or ~azure.ai.projects.models.PageOrder + :keyword status: Filter runs by status. Known values are: "queued", "in_progress", "succeeded", + "failed", and "cancelled". Default value is None. + :paramtype status: str or ~azure.ai.projects.models.JobStatus + :keyword trigger: Filter runs by trigger. Known values are: "on_demand" and "scheduled". + Default value is None. + :paramtype trigger: str or ~azure.ai.projects.models.AgentInsightRunTrigger + :return: An iterator like instance of AgentInsightRun + :rtype: ~azure.core.paging.ItemPaged[~azure.ai.projects.models.AgentInsightRun] :raises ~azure.core.exceptions.HttpResponseError: """ + _headers = kwargs.pop("headers", {}) or {} + _params = kwargs.pop("params", {}) or {} + + cls: ClsType[List[_models.AgentInsightRun]] = kwargs.pop("cls", None) + + error_map: MutableMapping = { + 401: ClientAuthenticationError, + 404: ResourceNotFoundError, + 409: ResourceExistsError, + 304: ResourceNotModifiedError, + } + error_map.update(kwargs.pop("error_map", {}) or {}) - @overload - def create_version( - self, name: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.ToolboxVersionObject: - """Create a new version of a toolbox. + def prepare_request(_continuation_token=None): - Creates a new toolbox version, provisioning the toolbox itself if it does not already exist. + _request = build_beta_agent_insight_monitors_list_runs_request( + monitor_id=monitor_id, + after=_continuation_token, + before=before, + limit=limit, + order=order, + status=status, + trigger=trigger, + api_version=self._config.api_version, + headers=_headers, + params=_params, + ) + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + _request.url = self._client.format_url(_request.url, **path_format_arguments) + return _request - :param name: The name of the toolbox. If the toolbox does not exist, it will be created. - Required. - :type name: str - :param body: Required. - :type body: JSON - :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". - :paramtype content_type: str - :return: ToolboxVersionObject. The ToolboxVersionObject is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.ToolboxVersionObject - :raises ~azure.core.exceptions.HttpResponseError: - """ + def extract_data(pipeline_response): + deserialized = pipeline_response.http_response.json() + list_of_elem = _deserialize( + List[_models.AgentInsightRun], + deserialized.get("data", []), + ) + if cls: + list_of_elem = cls(list_of_elem) # type: ignore + return deserialized.get("last_id") or None, iter(list_of_elem) - @overload - def create_version( - self, name: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.ToolboxVersionObject: - """Create a new version of a toolbox. + def get_next(_continuation_token=None): + _request = prepare_request(_continuation_token) - Creates a new toolbox version, provisioning the toolbox itself if it does not already exist. + _stream = False + pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access + _request, stream=_stream, **kwargs + ) + response = pipeline_response.http_response - :param name: The name of the toolbox. If the toolbox does not exist, it will be created. - Required. - :type name: str - :param body: Required. - :type body: IO[bytes] - :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". - :paramtype content_type: str - :return: ToolboxVersionObject. The ToolboxVersionObject is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.ToolboxVersionObject - :raises ~azure.core.exceptions.HttpResponseError: - """ + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = _failsafe_deserialize( + _models.ApiErrorResponse, + response, + ) + raise HttpResponseError(response=response, model=error) - @distributed_trace - def create_version( - self, - name: str, - body: Union[JSON, IO[bytes]] = _Unset, - *, - tools: List[_models.ToolboxTool] = _Unset, - description: Optional[str] = None, - metadata: Optional[dict[str, str]] = None, - skills: Optional[List[_models.ToolboxSkill]] = None, - policies: Optional[_models.ToolboxPolicies] = None, - **kwargs: Any - ) -> _models.ToolboxVersionObject: - """Create a new version of a toolbox. + return pipeline_response - Creates a new toolbox version, provisioning the toolbox itself if it does not already exist. + return ItemPaged(get_next, extract_data) - :param name: The name of the toolbox. If the toolbox does not exist, it will be created. - Required. - :type name: str - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] - :keyword tools: The list of tools to include in this version. Required. - :paramtype tools: list[~azure.ai.projects.models.ToolboxTool] - :keyword description: A human-readable description of the toolbox. Default value is None. - :paramtype description: str - :keyword metadata: Arbitrary key-value metadata to associate with the toolbox. Default value is - None. - :paramtype metadata: dict[str, str] - :keyword skills: The list of skill sources to include in this version. A skill reference - specifies a skill name and optionally a version. If version is omitted, the skill's default - version is used. Default value is None. - :paramtype skills: list[~azure.ai.projects.models.ToolboxSkill] - :keyword policies: Policy configuration for this toolbox version. Default value is None. - :paramtype policies: ~azure.ai.projects.models.ToolboxPolicies - :return: ToolboxVersionObject. The ToolboxVersionObject is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.ToolboxVersionObject + @distributed_trace + def get_run(self, monitor_id: str, run_id: str, **kwargs: Any) -> _models.AgentInsightRun: + """Get an Agent Insights run. + + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :param run_id: The identifier of the run. Required. + :type run_id: str + :return: AgentInsightRun. The AgentInsightRun is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.AgentInsightRun :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -8189,35 +10986,15 @@ def create_version( } error_map.update(kwargs.pop("error_map", {}) or {}) - _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ToolboxVersionObject] = kwargs.pop("cls", None) - - if body is _Unset: - if tools is _Unset: - raise TypeError("missing required argument: tools") - body = { - "description": description, - "metadata": metadata, - "policies": policies, - "skills": skills, - "tools": tools, - } - body = {k: v for k, v in body.items() if v is not None} - content_type = content_type or "application/json" - _content = None - if isinstance(body, (IOBase, bytes)): - _content = body - else: - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + cls: ClsType[_models.AgentInsightRun] = kwargs.pop("cls", None) - _request = build_toolboxes_create_version_request( - name=name, - content_type=content_type, + _request = build_beta_agent_insight_monitors_get_run_request( + monitor_id=monitor_id, + run_id=run_id, api_version=self._config.api_version, - content=_content, headers=_headers, params=_params, ) @@ -8250,7 +11027,7 @@ def create_version( if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.ToolboxVersionObject, response.json()) + deserialized = _deserialize(_models.AgentInsightRun, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -8258,15 +11035,15 @@ def create_version( return deserialized # type: ignore @distributed_trace - def get(self, name: str, **kwargs: Any) -> _models.ToolboxObject: - """Retrieve a toolbox. - - Retrieves the specified toolbox and its current configuration. + def cancel_run(self, monitor_id: str, run_id: str, **kwargs: Any) -> _models.AgentInsightRun: + """Cancel an Agent Insights run. - :param name: The name of the toolbox to retrieve. Required. - :type name: str - :return: ToolboxObject. The ToolboxObject is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.ToolboxObject + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :param run_id: The identifier of the run. Required. + :type run_id: str + :return: AgentInsightRun. The AgentInsightRun is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.AgentInsightRun :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -8280,10 +11057,11 @@ def get(self, name: str, **kwargs: Any) -> _models.ToolboxObject: _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.ToolboxObject] = kwargs.pop("cls", None) + cls: ClsType[_models.AgentInsightRun] = kwargs.pop("cls", None) - _request = build_toolboxes_get_request( - name=name, + _request = build_beta_agent_insight_monitors_cancel_run_request( + monitor_id=monitor_id, + run_id=run_id, api_version=self._config.api_version, headers=_headers, params=_params, @@ -8317,7 +11095,7 @@ def get(self, name: str, **kwargs: Any) -> _models.ToolboxObject: if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.ToolboxObject, response.json()) + deserialized = _deserialize(_models.AgentInsightRun, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -8325,135 +11103,50 @@ def get(self, name: str, **kwargs: Any) -> _models.ToolboxObject: return deserialized # type: ignore @distributed_trace - def list( + def list_insights( self, + monitor_id: str, *, - limit: Optional[int] = None, - order: Optional[Union[str, _models.PageOrder]] = None, before: Optional[str] = None, - **kwargs: Any - ) -> ItemPaged["_models.ToolboxObject"]: - """List toolboxes. - - Returns the toolboxes available in the current project. - - :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and - 100, and the - default is 20. Default value is None. - :paramtype limit: int - :keyword order: Sort order by the ``created_at`` timestamp of the objects. ``asc`` for - ascending order and``desc`` - for descending order. Known values are: "asc" and "desc". Default value is None. - :paramtype order: str or ~azure.ai.projects.models.PageOrder - :keyword before: A cursor for use in pagination. ``before`` is an object ID that defines your - place in the list. - For instance, if you make a list request and receive 100 objects, ending with obj_foo, your - subsequent call can include before=obj_foo in order to fetch the previous page of the list. - Default value is None. - :paramtype before: str - :return: An iterator like instance of ToolboxObject - :rtype: ~azure.core.paging.ItemPaged[~azure.ai.projects.models.ToolboxObject] - :raises ~azure.core.exceptions.HttpResponseError: - """ - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[List[_models.ToolboxObject]] = kwargs.pop("cls", None) - - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - def prepare_request(_continuation_token=None): - - _request = build_toolboxes_list_request( - limit=limit, - order=order, - after=_continuation_token, - before=before, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - return _request - - def extract_data(pipeline_response): - deserialized = pipeline_response.http_response.json() - list_of_elem = _deserialize( - List[_models.ToolboxObject], - deserialized.get("data", []), - ) - if cls: - list_of_elem = cls(list_of_elem) # type: ignore - return deserialized.get("last_id") or None, iter(list_of_elem) - - def get_next(_continuation_token=None): - _request = prepare_request(_continuation_token) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - response = pipeline_response.http_response - - if response.status_code not in [200]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ApiErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error) - - return pipeline_response - - return ItemPaged(get_next, extract_data) - - @distributed_trace - def list_versions( - self, - name: str, - *, limit: Optional[int] = None, order: Optional[Union[str, _models.PageOrder]] = None, - before: Optional[str] = None, + category: Optional[str] = None, + severity: Optional[Union[str, _models.AgentInsightSeverity]] = None, + status: Optional[Union[str, _models.AgentInsightStatus]] = None, + include_details: Optional[bool] = None, **kwargs: Any - ) -> ItemPaged["_models.ToolboxVersionObject"]: - """List toolbox versions. - - Returns the available versions for the specified toolbox. + ) -> ItemPaged["_models.AgentInsight"]: + """List current insights for an Agent Insights monitor. - :param name: The name of the toolbox to list versions for. Required. - :type name: str - :keyword limit: A limit on the number of objects to be returned. Limit can range between 1 and - 100, and the - default is 20. Default value is None. + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :keyword before: A cursor that identifies the first item in the next page. Default value is + None. + :paramtype before: str + :keyword limit: The maximum number of items to return. Defaults to 20. Default value is None. :paramtype limit: int - :keyword order: Sort order by the ``created_at`` timestamp of the objects. ``asc`` for - ascending order and``desc`` - for descending order. Known values are: "asc" and "desc". Default value is None. + :keyword order: Sort order by creation time. Defaults to descending. Known values are: "asc" + and "desc". Default value is None. :paramtype order: str or ~azure.ai.projects.models.PageOrder - :keyword before: A cursor for use in pagination. ``before`` is an object ID that defines your - place in the list. - For instance, if you make a list request and receive 100 objects, ending with obj_foo, your - subsequent call can include before=obj_foo in order to fetch the previous page of the list. + :keyword category: Filter insights by category. Default value is None. + :paramtype category: str + :keyword severity: Filter insights by severity. Known values are: "high", "medium", and "low". Default value is None. - :paramtype before: str - :return: An iterator like instance of ToolboxVersionObject - :rtype: ~azure.core.paging.ItemPaged[~azure.ai.projects.models.ToolboxVersionObject] + :paramtype severity: str or ~azure.ai.projects.models.AgentInsightSeverity + :keyword status: Filter insights by lifecycle status. Known values are: "active", "resolved", + and "ignored". Default value is None. + :paramtype status: str or ~azure.ai.projects.models.AgentInsightStatus + :keyword include_details: Whether to include expanded insight details such as evidence and run + links in the response. Defaults to false. Default value is None. + :paramtype include_details: bool + :return: An iterator like instance of AgentInsight + :rtype: ~azure.core.paging.ItemPaged[~azure.ai.projects.models.AgentInsight] :raises ~azure.core.exceptions.HttpResponseError: """ _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[List[_models.ToolboxVersionObject]] = kwargs.pop("cls", None) + cls: ClsType[List[_models.AgentInsight]] = kwargs.pop("cls", None) error_map: MutableMapping = { 401: ClientAuthenticationError, @@ -8465,12 +11158,16 @@ def list_versions( def prepare_request(_continuation_token=None): - _request = build_toolboxes_list_versions_request( - name=name, - limit=limit, - order=order, + _request = build_beta_agent_insight_monitors_list_insights_request( + monitor_id=monitor_id, after=_continuation_token, before=before, + limit=limit, + order=order, + category=category, + severity=severity, + status=status, + include_details=include_details, api_version=self._config.api_version, headers=_headers, params=_params, @@ -8484,7 +11181,7 @@ def prepare_request(_continuation_token=None): def extract_data(pipeline_response): deserialized = pipeline_response.http_response.json() list_of_elem = _deserialize( - List[_models.ToolboxVersionObject], + List[_models.AgentInsight], deserialized.get("data", []), ) if cls: @@ -8513,17 +11210,20 @@ def get_next(_continuation_token=None): return ItemPaged(get_next, extract_data) @distributed_trace - def get_version(self, name: str, version: str, **kwargs: Any) -> _models.ToolboxVersionObject: - """Retrieve a specific version of a toolbox. - - Retrieves the specified version of a toolbox by name and version identifier. - - :param name: The name of the toolbox. Required. - :type name: str - :param version: The version identifier to retrieve. Required. - :type version: str - :return: ToolboxVersionObject. The ToolboxVersionObject is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.ToolboxVersionObject + def get_insight( + self, monitor_id: str, insight_id: str, *, include_details: Optional[bool] = None, **kwargs: Any + ) -> _models.AgentInsight: + """Get a full insight for an Agent Insights monitor. + + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :param insight_id: The identifier of the insight. Required. + :type insight_id: str + :keyword include_details: Whether to include expanded insight details such as evidence and run + links in the response. Defaults to false. Default value is None. + :paramtype include_details: bool + :return: AgentInsight. The AgentInsight is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.AgentInsight :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -8537,11 +11237,12 @@ def get_version(self, name: str, version: str, **kwargs: Any) -> _models.Toolbox _headers = kwargs.pop("headers", {}) or {} _params = kwargs.pop("params", {}) or {} - cls: ClsType[_models.ToolboxVersionObject] = kwargs.pop("cls", None) + cls: ClsType[_models.AgentInsight] = kwargs.pop("cls", None) - _request = build_toolboxes_get_version_request( - name=name, - version=version, + _request = build_beta_agent_insight_monitors_get_insight_request( + monitor_id=monitor_id, + insight_id=insight_id, + include_details=include_details, api_version=self._config.api_version, headers=_headers, params=_params, @@ -8575,7 +11276,7 @@ def get_version(self, name: str, version: str, **kwargs: Any) -> _models.Toolbox if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.ToolboxVersionObject, response.json()) + deserialized = _deserialize(_models.AgentInsight, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore @@ -8583,83 +11284,102 @@ def get_version(self, name: str, version: str, **kwargs: Any) -> _models.Toolbox return deserialized # type: ignore @overload - def update( - self, name: str, *, default_version: str, content_type: str = "application/json", **kwargs: Any - ) -> _models.ToolboxObject: - """Update a toolbox to point to a specific version. - - Updates the toolbox's default version pointer to the specified version. + def update_insight( + self, + monitor_id: str, + insight_id: str, + update: _models.AgentInsightUpdate, + *, + content_type: str = "application/merge-patch+json", + **kwargs: Any + ) -> _models.AgentInsight: + """Update the lifecycle status of an insight. - :param name: The name of the toolbox to update. Required. - :type name: str - :keyword default_version: The version identifier that the toolbox should point to. When set, - the toolbox's default version will resolve to this version instead of the latest. Required. - :paramtype default_version: str + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :param insight_id: The identifier of the insight. Required. + :type insight_id: str + :param update: The insight fields to update. Required. + :type update: ~azure.ai.projects.models.AgentInsightUpdate :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". + Default value is "application/merge-patch+json". :paramtype content_type: str - :return: ToolboxObject. The ToolboxObject is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.ToolboxObject + :return: AgentInsight. The AgentInsight is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.AgentInsight :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def update( - self, name: str, body: JSON, *, content_type: str = "application/json", **kwargs: Any - ) -> _models.ToolboxObject: - """Update a toolbox to point to a specific version. - - Updates the toolbox's default version pointer to the specified version. + def update_insight( + self, + monitor_id: str, + insight_id: str, + update: JSON, + *, + content_type: str = "application/merge-patch+json", + **kwargs: Any + ) -> _models.AgentInsight: + """Update the lifecycle status of an insight. - :param name: The name of the toolbox to update. Required. - :type name: str - :param body: Required. - :type body: JSON + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :param insight_id: The identifier of the insight. Required. + :type insight_id: str + :param update: The insight fields to update. Required. + :type update: JSON :keyword content_type: Body Parameter content-type. Content type parameter for JSON body. - Default value is "application/json". + Default value is "application/merge-patch+json". :paramtype content_type: str - :return: ToolboxObject. The ToolboxObject is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.ToolboxObject + :return: AgentInsight. The AgentInsight is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.AgentInsight :raises ~azure.core.exceptions.HttpResponseError: """ @overload - def update( - self, name: str, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any - ) -> _models.ToolboxObject: - """Update a toolbox to point to a specific version. - - Updates the toolbox's default version pointer to the specified version. + def update_insight( + self, + monitor_id: str, + insight_id: str, + update: IO[bytes], + *, + content_type: str = "application/merge-patch+json", + **kwargs: Any + ) -> _models.AgentInsight: + """Update the lifecycle status of an insight. - :param name: The name of the toolbox to update. Required. - :type name: str - :param body: Required. - :type body: IO[bytes] + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :param insight_id: The identifier of the insight. Required. + :type insight_id: str + :param update: The insight fields to update. Required. + :type update: IO[bytes] :keyword content_type: Body Parameter content-type. Content type parameter for binary body. - Default value is "application/json". + Default value is "application/merge-patch+json". :paramtype content_type: str - :return: ToolboxObject. The ToolboxObject is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.ToolboxObject + :return: AgentInsight. The AgentInsight is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.AgentInsight :raises ~azure.core.exceptions.HttpResponseError: """ @distributed_trace - def update( - self, name: str, body: Union[JSON, IO[bytes]] = _Unset, *, default_version: str = _Unset, **kwargs: Any - ) -> _models.ToolboxObject: - """Update a toolbox to point to a specific version. - - Updates the toolbox's default version pointer to the specified version. + def update_insight( + self, + monitor_id: str, + insight_id: str, + update: Union[_models.AgentInsightUpdate, JSON, IO[bytes]], + **kwargs: Any + ) -> _models.AgentInsight: + """Update the lifecycle status of an insight. - :param name: The name of the toolbox to update. Required. - :type name: str - :param body: Is either a JSON type or a IO[bytes] type. Required. - :type body: JSON or IO[bytes] - :keyword default_version: The version identifier that the toolbox should point to. When set, - the toolbox's default version will resolve to this version instead of the latest. Required. - :paramtype default_version: str - :return: ToolboxObject. The ToolboxObject is compatible with MutableMapping - :rtype: ~azure.ai.projects.models.ToolboxObject + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :param insight_id: The identifier of the insight. Required. + :type insight_id: str + :param update: The insight fields to update. Is one of the following types: AgentInsightUpdate, + JSON, IO[bytes] Required. + :type update: ~azure.ai.projects.models.AgentInsightUpdate or JSON or IO[bytes] + :return: AgentInsight. The AgentInsight is compatible with MutableMapping + :rtype: ~azure.ai.projects.models.AgentInsight :raises ~azure.core.exceptions.HttpResponseError: """ error_map: MutableMapping = { @@ -8674,22 +11394,18 @@ def update( _params = kwargs.pop("params", {}) or {} content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None)) - cls: ClsType[_models.ToolboxObject] = kwargs.pop("cls", None) + cls: ClsType[_models.AgentInsight] = kwargs.pop("cls", None) - if body is _Unset: - if default_version is _Unset: - raise TypeError("missing required argument: default_version") - body = {"default_version": default_version} - body = {k: v for k, v in body.items() if v is not None} - content_type = content_type or "application/json" + content_type = content_type or "application/merge-patch+json" _content = None - if isinstance(body, (IOBase, bytes)): - _content = body + if isinstance(update, (IOBase, bytes)): + _content = update else: - _content = json.dumps(body, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore + _content = json.dumps(update, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore - _request = build_toolboxes_update_request( - name=name, + _request = build_beta_agent_insight_monitors_update_insight_request( + monitor_id=monitor_id, + insight_id=insight_id, content_type=content_type, api_version=self._config.api_version, content=_content, @@ -8725,126 +11441,13 @@ def update( if _stream: deserialized = response.iter_bytes() if _decompress else response.iter_raw() else: - deserialized = _deserialize(_models.ToolboxObject, response.json()) + deserialized = _deserialize(_models.AgentInsight, response.json()) if cls: return cls(pipeline_response, deserialized, {}) # type: ignore return deserialized # type: ignore - @distributed_trace - def delete(self, name: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements - """Delete a toolbox. - - Removes the specified toolbox along with all of its versions. - - :param name: The name of the toolbox to delete. Required. - :type name: str - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_toolboxes_delete_request( - name=name, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ApiErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - - @distributed_trace - def delete_version( # pylint: disable=inconsistent-return-statements - self, name: str, version: str, **kwargs: Any - ) -> None: - """Delete a specific version of a toolbox. - - Removes the specified version of a toolbox. - - :param name: The name of the toolbox. Required. - :type name: str - :param version: The version identifier to delete. Required. - :type version: str - :return: None - :rtype: None - :raises ~azure.core.exceptions.HttpResponseError: - """ - error_map: MutableMapping = { - 401: ClientAuthenticationError, - 404: ResourceNotFoundError, - 409: ResourceExistsError, - 304: ResourceNotModifiedError, - } - error_map.update(kwargs.pop("error_map", {}) or {}) - - _headers = kwargs.pop("headers", {}) or {} - _params = kwargs.pop("params", {}) or {} - - cls: ClsType[None] = kwargs.pop("cls", None) - - _request = build_toolboxes_delete_version_request( - name=name, - version=version, - api_version=self._config.api_version, - headers=_headers, - params=_params, - ) - path_format_arguments = { - "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), - } - _request.url = self._client.format_url(_request.url, **path_format_arguments) - - _stream = False - pipeline_response: PipelineResponse = self._client._pipeline.run( # pylint: disable=protected-access - _request, stream=_stream, **kwargs - ) - - response = pipeline_response.http_response - - if response.status_code not in [204]: - map_error(status_code=response.status_code, response=response, error_map=error_map) - error = _failsafe_deserialize( - _models.ApiErrorResponse, - response, - ) - raise HttpResponseError(response=response, model=error) - - if cls: - return cls(pipeline_response, None, {}) # type: ignore - class BetaEvaluationTaxonomiesOperations: # pylint: disable=docstring-missing-param """ @@ -14353,6 +16956,7 @@ def create_or_update( enabled: Optional[bool] = None, triggers: Optional[dict[str, _models.RoutineTrigger]] = None, action: Optional[_models.RoutineAction] = None, + authorization: Optional[_models.RoutineAuthorization] = None, **kwargs: Any ) -> _models.Routine: """Create or update a routine. @@ -14373,6 +16977,9 @@ def create_or_update( :paramtype triggers: dict[str, ~azure.ai.projects.models.RoutineTrigger] :keyword action: The action executed when the routine fires. Default value is None. :paramtype action: ~azure.ai.projects.models.RoutineAction + :keyword authorization: Optional authorization configuration for dispatching a newly created + routine. Ignored when updating an existing routine. Default value is None. + :paramtype authorization: ~azure.ai.projects.models.RoutineAuthorization :return: Routine. The Routine is compatible with MutableMapping :rtype: ~azure.ai.projects.models.Routine :raises ~azure.core.exceptions.HttpResponseError: @@ -14428,6 +17035,7 @@ def create_or_update( enabled: Optional[bool] = None, triggers: Optional[dict[str, _models.RoutineTrigger]] = None, action: Optional[_models.RoutineAction] = None, + authorization: Optional[_models.RoutineAuthorization] = None, **kwargs: Any ) -> _models.Routine: """Create or update a routine. @@ -14447,6 +17055,9 @@ def create_or_update( :paramtype triggers: dict[str, ~azure.ai.projects.models.RoutineTrigger] :keyword action: The action executed when the routine fires. Default value is None. :paramtype action: ~azure.ai.projects.models.RoutineAction + :keyword authorization: Optional authorization configuration for dispatching a newly created + routine. Ignored when updating an existing routine. Default value is None. + :paramtype authorization: ~azure.ai.projects.models.RoutineAuthorization :return: Routine. The Routine is compatible with MutableMapping :rtype: ~azure.ai.projects.models.Routine :raises ~azure.core.exceptions.HttpResponseError: @@ -14466,7 +17077,13 @@ def create_or_update( cls: ClsType[_models.Routine] = kwargs.pop("cls", None) if body is _Unset: - body = {"action": action, "description": description, "enabled": enabled, "triggers": triggers} + body = { + "action": action, + "authorization": authorization, + "description": description, + "enabled": enabled, + "triggers": triggers, + } body = {k: v for k, v in body.items() if v is not None} content_type = content_type or "application/json" _content = None diff --git a/sdk/ai/azure-ai-projects/azure/ai/projects/operations/_patch.py b/sdk/ai/azure-ai-projects/azure/ai/projects/operations/_patch.py index 3970566daddf..4231ea89f96a 100644 --- a/sdk/ai/azure-ai-projects/azure/ai/projects/operations/_patch.py +++ b/sdk/ai/azure-ai-projects/azure/ai/projects/operations/_patch.py @@ -13,6 +13,7 @@ from typing import Any, Callable, List from ..models._patch import _FOUNDRY_FEATURES_HEADER_NAME, _BETA_OPERATION_FEATURE_HEADERS, _has_header_case_insensitive from ._patch_agents import AgentsOperations, BetaAgentsOperations +from ._patch_agent_insights import BetaAgentInsightMonitorsOperations from ._patch_datasets import BetaDatasetsOperations, DatasetsOperations from ._patch_evaluators import BetaEvaluatorsOperations from ._patch_evaluation_rules import EvaluationRulesOperations @@ -96,6 +97,8 @@ class BetaOperations(GeneratedBetaOperations): agents: BetaAgentsOperations """:class:`~azure.ai.projects.operations.BetaAgentsOperations` operations""" + agent_insight_monitors: BetaAgentInsightMonitorsOperations + """:class:`~azure.ai.projects.operations.BetaAgentInsightMonitorsOperations` operations""" evaluation_taxonomies: BetaEvaluationTaxonomiesOperations """:class:`~azure.ai.projects.operations.BetaEvaluationTaxonomiesOperations` operations""" evaluators: BetaEvaluatorsOperations @@ -129,6 +132,10 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: self.models = BetaModelsOperations(self._client, self._config, self._serialize, self._deserialize) # Replace with patched class that returns DatasetGenerationLROPoller self.datasets = BetaDatasetsOperations(self._client, self._config, self._serialize, self._deserialize) + # Replace with patched class that returns AgentInsightRunLROPoller + self.agent_insight_monitors = BetaAgentInsightMonitorsOperations( + self._client, self._config, self._serialize, self._deserialize + ) for property_name, foundry_features_value in _BETA_OPERATION_FEATURE_HEADERS.items(): setattr( @@ -140,6 +147,7 @@ def __init__(self, *args: Any, **kwargs: Any) -> None: __all__: List[str] = [ "AgentsOperations", + "BetaAgentInsightMonitorsOperations", "BetaAgentsOperations", "BetaDatasetsOperations", "BetaEvaluationTaxonomiesOperations", diff --git a/sdk/ai/azure-ai-projects/azure/ai/projects/operations/_patch_agent_insights.py b/sdk/ai/azure-ai-projects/azure/ai/projects/operations/_patch_agent_insights.py new file mode 100644 index 000000000000..d8639ca05d71 --- /dev/null +++ b/sdk/ai/azure-ai-projects/azure/ai/projects/operations/_patch_agent_insights.py @@ -0,0 +1,136 @@ +# pylint: disable=line-too-long,useless-suppression +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" + +from typing import Any, IO, Optional, Union, cast, overload +from collections.abc import MutableMapping + +from azure.core.polling import NoPolling, PollingMethod +from azure.core.polling.base_polling import LROBasePolling +from azure.core.tracing.decorator import distributed_trace +from azure.core.utils import case_insensitive_dict + +from ._operations import ( + BetaAgentInsightMonitorsOperations as BetaAgentInsightMonitorsOperationsGenerated, +) +from .. import models as _models +from .._utils.model_base import _deserialize +from ..models import AgentInsightRunLROPoller + +JSON = MutableMapping[str, Any] + + +class BetaAgentInsightMonitorsOperations(BetaAgentInsightMonitorsOperationsGenerated): + """Custom operations for beta Agent Insights monitors.""" + + @overload + def begin_create_run( + self, + monitor_id: str, + run: _models.AgentInsightRunCreate, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> AgentInsightRunLROPoller: ... + + @overload + def begin_create_run( + self, + monitor_id: str, + run: JSON, + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> AgentInsightRunLROPoller: ... + + @overload + def begin_create_run( + self, + monitor_id: str, + run: IO[bytes], + *, + content_type: str = "application/json", + **kwargs: Any, + ) -> AgentInsightRunLROPoller: ... + + @distributed_trace + def begin_create_run( + self, + monitor_id: str, + run: Union[_models.AgentInsightRunCreate, JSON, IO[bytes]], + **kwargs: Any, + ) -> AgentInsightRunLROPoller: + """Start an Agent Insights run for a monitor. + + :param monitor_id: The identifier of the monitor. Required. + :type monitor_id: str + :param run: Run inputs. Send an empty object to use the default 168-hour lookback window. Is + one of the following types: AgentInsightRunCreate, JSON, IO[bytes] Required. + :type run: ~azure.ai.projects.models.AgentInsightRunCreate or JSON or IO[bytes] + :return: A poller that returns AgentInsightRunResult and exposes the run ID in ``details``. + :rtype: ~azure.ai.projects.models.AgentInsightRunLROPoller + :raises ~azure.core.exceptions.HttpResponseError: + """ + headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + params = kwargs.pop("params", {}) or {} + + content_type: Optional[str] = kwargs.pop("content_type", headers.pop("Content-Type", None)) + cls = kwargs.pop("cls", None) + polling: Union[bool, PollingMethod] = kwargs.pop("polling", True) + lro_delay = kwargs.pop("polling_interval", self._config.polling_interval) + continuation_token: Optional[str] = kwargs.pop("continuation_token", None) + raw_result = None + if continuation_token is None: + raw_result = self._create_run_initial( + monitor_id=monitor_id, + run=run, + content_type=content_type, + cls=lambda x, y, z: x, + headers=headers, + params=params, + **kwargs, + ) + raw_result.http_response.read() # type: ignore + kwargs.pop("error_map", None) + + def get_long_running_output(pipeline_response): + response_headers = {} + response = pipeline_response.http_response + response_headers["Operation-Location"] = self._deserialize( + "str", response.headers.get("Operation-Location") + ) + response_headers["Location"] = self._deserialize("str", response.headers.get("Location")) + + deserialized = _deserialize(_models.AgentInsightRunResult, response.json().get("result", {})) + if cls: + return cls(pipeline_response, deserialized, response_headers) + return deserialized + + path_format_arguments = { + "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True), + } + + if polling is True: + polling_method: PollingMethod = cast( + PollingMethod, + LROBasePolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs), + ) + elif polling is False: + polling_method = cast(PollingMethod, NoPolling()) + else: + polling_method = polling + if continuation_token: + return AgentInsightRunLROPoller.from_continuation_token( + polling_method=polling_method, + continuation_token=continuation_token, + client=self._client, + deserialization_callback=get_long_running_output, + ) + assert raw_result is not None + return AgentInsightRunLROPoller(self._client, raw_result, get_long_running_output, polling_method) # type: ignore diff --git a/sdk/ai/azure-ai-projects/samples/agents/sample_workflow_multi_agent.py b/sdk/ai/azure-ai-projects/samples/agents/sample_workflow_multi_agent.py deleted file mode 100644 index f2ce47c55b7c..000000000000 --- a/sdk/ai/azure-ai-projects/samples/agents/sample_workflow_multi_agent.py +++ /dev/null @@ -1,182 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ - -""" -DESCRIPTION: - This sample demonstrates how to create a multi-agent workflow using a synchronous client - with a student agent answering the question first and then a teacher agent checking the answer. - -USAGE: - python sample_workflow_multi_agent.py - - Before running the sample: - - pip install "azure-ai-projects>=2.0.0" python-dotenv aiohttp - - Set these environment variables with your own values: - 1) FOUNDRY_PROJECT_ENDPOINT - The Azure AI Project endpoint, as found in the Overview - page of your Microsoft Foundry portal. - 2) FOUNDRY_MODEL_NAME - The deployment name of the AI model, as found under the "Name" column in - the "Models + endpoints" tab in your Microsoft Foundry project. -""" - -import os -from dotenv import load_dotenv - -from azure.identity import DefaultAzureCredential -from azure.ai.projects import AIProjectClient -from azure.ai.projects.models import ( - PromptAgentDefinition, - WorkflowAgentDefinition, -) - -load_dotenv() - -endpoint = os.environ["FOUNDRY_PROJECT_ENDPOINT"] - -with ( - DefaultAzureCredential() as credential, - AIProjectClient(endpoint=endpoint, credential=credential, allow_preview=True) as project_client, - project_client.get_openai_client() as openai_client, -): - # Create Teacher Agent - teacher_agent = project_client.agents.create_version( - agent_name="teacher-agent", - definition=PromptAgentDefinition( - model=os.environ["FOUNDRY_MODEL_NAME"], - instructions="""You are a teacher that create pre-school math question for student and check answer. - If the answer is correct, you stop the conversation by saying [COMPLETE]. - If the answer is wrong, you ask student to fix it.""", - ), - ) - print(f"Agent created (id: {teacher_agent.id}, name: {teacher_agent.name}, version: {teacher_agent.version})") - - # Create Student Agent - student_agent = project_client.agents.create_version( - agent_name="student-agent", - definition=PromptAgentDefinition( - model=os.environ["FOUNDRY_MODEL_NAME"], - instructions="""You are a student who answers questions from the teacher. - When the teacher gives you a question, you answer it.""", - ), - ) - print(f"Agent created (id: {student_agent.id}, name: {student_agent.name}, version: {student_agent.version})") - - # Create Multi-Agent Workflow - workflow_yaml = """ -kind: workflow -trigger: - kind: OnConversationStart - id: my_workflow - actions: - - kind: SetVariable - id: set_variable_input_task - variable: Local.LatestMessage - value: "=UserMessage(System.LastMessageText)" - - - kind: CreateConversation - id: create_student_conversation - conversationId: Local.StudentConversationId - - - kind: CreateConversation - id: create_teacher_conversation - conversationId: Local.TeacherConversationId - - - kind: InvokeAzureAgent - id: student_agent - description: The student node - conversationId: "=Local.StudentConversationId" - agent: - name: {student_agent.name} - input: - messages: "=Local.LatestMessage" - output: - messages: Local.LatestMessage - - - kind: InvokeAzureAgent - id: teacher_agent - description: The teacher node - conversationId: "=Local.TeacherConversationId" - agent: - name: {teacher_agent.name} - input: - messages: "=Local.LatestMessage" - output: - messages: Local.LatestMessage - - - kind: SendActivity - id: send_teacher_reply - activity: "{{Last(Local.LatestMessage).Text}}" - - - kind: SetVariable - id: set_variable_turncount - variable: Local.TurnCount - value: "=Local.TurnCount + 1" - - - kind: ConditionGroup - id: completion_check - conditions: - - condition: '=!IsBlank(Find("[COMPLETE]", Upper(Last(Local.LatestMessage).Text)))' - id: check_done - actions: - - kind: EndConversation - id: end_workflow - - - condition: "=Local.TurnCount >= 4" - id: check_turn_count_exceeded - actions: - - kind: SendActivity - id: send_activity_tired - activity: "Let's try again later...I am tired." - - elseActions: - - kind: GotoAction - id: goto_student_agent - actionId: student_agent -""" - - workflow = project_client.agents.create_version( - agent_name="student-teacher-workflow", - definition=WorkflowAgentDefinition(workflow=workflow_yaml), - ) - - print(f"Agent created (id: {workflow.id}, name: {workflow.name}, version: {workflow.version})") - - conversation = openai_client.conversations.create() - print(f"Created conversation (id: {conversation.id})") - - stream = openai_client.responses.create( - conversation=conversation.id, - extra_body={"agent_reference": {"name": workflow.name, "type": "agent_reference"}}, - input="1 + 1 = ?", - stream=True, - ) - - for event in stream: - print(f"Event {event.sequence_number} type '{event.type}'", end="") - if ( - event.type in ("response.output_item.added", "response.output_item.done") - ) and event.item.type == "workflow_action": # pyright: ignore [reportAttributeAccessIssue] - print( - f": item action ID '{event.item.action_id}' is '{event.item.status}' (previous action ID: '{event.item.previous_action_id}')", # pyright: ignore [reportAttributeAccessIssue] - end="", - ) - elif event.type == "response.completed": - response = openai_client.responses.retrieve(event.response.id) - print(f": Final Response: {response}", end="") - print("", flush=True) - - openai_client.conversations.delete(conversation_id=conversation.id) - print("Conversation deleted") - - project_client.agents.delete_version(agent_name=workflow.name, agent_version=workflow.version) - print("Workflow deleted") - - project_client.agents.delete_version(agent_name=student_agent.name, agent_version=student_agent.version) - print("Student Agent deleted") - - project_client.agents.delete_version(agent_name=teacher_agent.name, agent_version=teacher_agent.version) - print("Teacher Agent deleted") diff --git a/sdk/ai/azure-ai-projects/samples/agents/sample_workflow_multi_agent_async.py b/sdk/ai/azure-ai-projects/samples/agents/sample_workflow_multi_agent_async.py deleted file mode 100644 index 8673b7ac284d..000000000000 --- a/sdk/ai/azure-ai-projects/samples/agents/sample_workflow_multi_agent_async.py +++ /dev/null @@ -1,188 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ - -""" -DESCRIPTION: - This sample demonstrates how to create a multi-agent workflow using an asynchronous client - with a student agent answering the question first and then a teacher agent checking the answer. - -USAGE: - python sample_workflow_multi_agent_async.py - - Before running the sample: - - pip install "azure-ai-projects>=2.0.0" python-dotenv aiohttp - - Set these environment variables with your own values: - 1) FOUNDRY_PROJECT_ENDPOINT - The Azure AI Project endpoint, as found in the Overview - page of your Microsoft Foundry portal. - 2) FOUNDRY_MODEL_NAME - The deployment name of the AI model, as found under the "Name" column in - the "Models + endpoints" tab in your Microsoft Foundry project. -""" - -import os -import asyncio -from dotenv import load_dotenv - -from azure.identity.aio import DefaultAzureCredential -from azure.ai.projects.aio import AIProjectClient -from azure.ai.projects.models import ( - PromptAgentDefinition, - WorkflowAgentDefinition, -) - -load_dotenv() - -endpoint = os.environ["FOUNDRY_PROJECT_ENDPOINT"] - - -async def main(): - - async with ( - DefaultAzureCredential() as credential, - AIProjectClient(endpoint=endpoint, credential=credential, allow_preview=True) as project_client, - project_client.get_openai_client() as openai_client, - ): - - teacher_agent = await project_client.agents.create_version( - agent_name="teacher-agent-async", - definition=PromptAgentDefinition( - model=os.environ["FOUNDRY_MODEL_NAME"], - instructions="""You are a teacher that create pre-school math question for student and check answer. - If the answer is correct, you stop the conversation by saying [COMPLETE]. - If the answer is wrong, you ask student to fix it.""", - ), - ) - print(f"Agent created (id: {teacher_agent.id}, name: {teacher_agent.name}, version: {teacher_agent.version})") - - student_agent = await project_client.agents.create_version( - agent_name="student-agent-async", - definition=PromptAgentDefinition( - model=os.environ["FOUNDRY_MODEL_NAME"], - instructions="""You are a student who answers questions from the teacher. - When the teacher gives you a question, you answer it.""", - ), - ) - print(f"Agent created (id: {student_agent.id}, name: {student_agent.name}, version: {student_agent.version})") - - workflow_yaml = """ -kind: workflow -trigger: - kind: OnConversationStart - id: my_workflow - actions: - - kind: SetVariable - id: set_variable_input_task - variable: Local.LatestMessage - value: "=UserMessage(System.LastMessageText)" - - - kind: CreateConversation - id: create_student_conversation - conversationId: Local.StudentConversationId - - - kind: CreateConversation - id: create_teacher_conversation - conversationId: Local.TeacherConversationId - - - kind: InvokeAzureAgent - id: student_agent - description: The student node - conversationId: "=Local.StudentConversationId" - agent: - name: {student_agent.name} - input: - messages: "=Local.LatestMessage" - output: - messages: Local.LatestMessage - - - kind: InvokeAzureAgent - id: teacher_agent - description: The teacher node - conversationId: "=Local.TeacherConversationId" - agent: - name: {teacher_agent.name} - input: - messages: "=Local.LatestMessage" - output: - messages: Local.LatestMessage - - - kind: SendActivity - id: send_teacher_reply - activity: "{{Last(Local.LatestMessage).Text}}" - - - kind: SetVariable - id: set_variable_turncount - variable: Local.TurnCount - value: "=Local.TurnCount + 1" - - - kind: ConditionGroup - id: completion_check - conditions: - - condition: '=!IsBlank(Find("[COMPLETE]", Upper(Last(Local.LatestMessage).Text)))' - id: check_done - actions: - - kind: EndConversation - id: end_workflow - - - condition: "=Local.TurnCount >= 4" - id: check_turn_count_exceeded - actions: - - kind: SendActivity - id: send_activity_tired - activity: "Let's try again later...I am tired." - - elseActions: - - kind: GotoAction - id: goto_student_agent - actionId: student_agent -""" - - workflow = await project_client.agents.create_version( - agent_name="student-teacher-workflow-async", - definition=WorkflowAgentDefinition(workflow=workflow_yaml), - ) - - print(f"Agent created (id: {workflow.id}, name: {workflow.name}, version: {workflow.version})") - - conversation = await openai_client.conversations.create() - print(f"Created conversation (id: {conversation.id})") - - stream = await openai_client.responses.create( - conversation=conversation.id, - extra_body={"agent_reference": {"name": workflow.name, "type": "agent_reference"}}, - input="1 + 1 = ?", - stream=True, - ) - - async for event in stream: - print(f"Event {event.sequence_number} type '{event.type}'", end="") - if ( - event.type in ("response.output_item.added", "response.output_item.done") - ) and event.item.type == "workflow_action": # pyright: ignore [reportAttributeAccessIssue] - print( - f": item action ID '{event.item.action_id}' is '{event.item.status}' (previous action ID: '{event.item.previous_action_id}')", # pyright: ignore [reportAttributeAccessIssue] - end="", - ) - elif event.type == "response.completed": - response = await openai_client.responses.retrieve(event.response.id) - print(f": Final Response: {response}", end="") - print("", flush=True) - - await openai_client.conversations.delete(conversation_id=conversation.id) - print("Conversation deleted") - - await project_client.agents.delete_version(agent_name=workflow.name, agent_version=workflow.version) - print("Workflow deleted") - - await project_client.agents.delete_version(agent_name=student_agent.name, agent_version=student_agent.version) - print("Student Agent deleted") - - await project_client.agents.delete_version(agent_name=teacher_agent.name, agent_version=teacher_agent.version) - print("Teacher Agent deleted") - - -if __name__ == "__main__": - asyncio.run(main()) diff --git a/sdk/ai/azure-ai-projects/samples/agents/sample_workflow_multi_agent_with_mcp_approval.py b/sdk/ai/azure-ai-projects/samples/agents/sample_workflow_multi_agent_with_mcp_approval.py deleted file mode 100644 index 2ef0109250c5..000000000000 --- a/sdk/ai/azure-ai-projects/samples/agents/sample_workflow_multi_agent_with_mcp_approval.py +++ /dev/null @@ -1,250 +0,0 @@ -# pylint: disable=line-too-long,useless-suppression -# ------------------------------------ -# Copyright (c) Microsoft Corporation. -# Licensed under the MIT License. -# ------------------------------------ - -""" -DESCRIPTION: - This sample demonstrates how to create a multi-agent workflow using a synchronous client - with a student agent (using MCP tools) answering questions and then a teacher - agent checking the answer. The workflow handles MCP approval requests as always. - - The student agent can access external resources via MCP tools if needed to answer - questions that require additional context or information. - -USAGE: - python sample_workflow_multi_agent_with_mcp_approval.py - - Before running the sample: - - pip install "azure-ai-projects>=2.0.0" python-dotenv aiohttp - - Set these environment variables with your own values: - 1) FOUNDRY_PROJECT_ENDPOINT - The Azure AI Project endpoint, as found in the Overview - page of your Microsoft Foundry portal. - 2) FOUNDRY_MODEL_NAME - The deployment name of the AI model, as found under the "Name" column in - the "Models + endpoints" tab in your Microsoft Foundry project. -""" - -import os -from dotenv import load_dotenv -from openai.types.responses.response_input_param import McpApprovalResponse, ResponseInputParam - -from azure.identity import DefaultAzureCredential -from azure.ai.projects import AIProjectClient -from azure.ai.projects.models import ( - PromptAgentDefinition, - WorkflowAgentDefinition, - MCPTool, -) - -load_dotenv() - -endpoint = os.environ["FOUNDRY_PROJECT_ENDPOINT"] - -with ( - DefaultAzureCredential() as credential, - AIProjectClient(endpoint=endpoint, credential=credential, allow_preview=True) as project_client, - project_client.get_openai_client() as openai_client, -): - # Define MCP tool for accessing external resources (optional - can be removed for simpler demo) - # Note: MCP tools in workflows may require special handling depending on the use case - mcp_tool = MCPTool( - server_label="api-specs", - server_url="https://gitmcp.io/Azure/azure-rest-api-specs", - require_approval="always", - ) - - # Create Teacher Agent - teacher_agent = project_client.agents.create_version( - agent_name="teacher-agent", - definition=PromptAgentDefinition( - model=os.environ["FOUNDRY_MODEL_NAME"], - instructions="""You are a teacher that create Foundry project question for student and check answer. - Verify student's answer from mcp tools. - If the answer is correct, you stop the conversation by saying [COMPLETE]. - If the answer is wrong, you ask student to fix it.""", - tools=[mcp_tool], - ), - ) - print(f"Agent created (id: {teacher_agent.id}, name: {teacher_agent.name}, version: {teacher_agent.version})") - - # Create Student Agent WITHOUT MCP tool initially to keep the sample simple - # To demonstrate MCP approval in workflows, the tool would need to be triggered by appropriate queries - student_agent = project_client.agents.create_version( - agent_name="student-agent", - definition=PromptAgentDefinition( - model=os.environ["FOUNDRY_MODEL_NAME"], - instructions="""You are a student who answers questions from the teacher. - When the teacher gives you a question, you answer it using mcp tool.""", - tools=[mcp_tool], - ), - ) - print(f"Agent created (id: {student_agent.id}, name: {student_agent.name}, version: {student_agent.version})") - - # Create Multi-Agent Workflow - workflow_yaml = f""" -kind: workflow -trigger: - kind: OnConversationStart - id: my_workflow - actions: - - kind: SetVariable - id: set_variable_input_task - variable: Local.LatestMessage - value: "=UserMessage(System.LastMessageText)" - - - kind: CreateConversation - id: create_student_conversation - conversationId: Local.StudentConversationId - - - kind: CreateConversation - id: create_teacher_conversation - conversationId: Local.TeacherConversationId - - - kind: InvokeAzureAgent - id: student_agent - description: The student node - conversationId: "=Local.StudentConversationId" - agent: - name: {student_agent.name} - input: - messages: "=Local.LatestMessage" - output: - messages: Local.LatestMessage - - - kind: InvokeAzureAgent - id: teacher_agent - description: The teacher node - conversationId: "=Local.TeacherConversationId" - agent: - name: {teacher_agent.name} - input: - messages: "=Local.LatestMessage" - output: - messages: Local.LatestMessage - - - kind: SendActivity - id: send_teacher_reply - activity: "{{Last(Local.LatestMessage).Text}}" - - - kind: SetVariable - id: set_variable_turncount - variable: Local.TurnCount - value: "=Local.TurnCount + 1" - - - kind: ConditionGroup - id: completion_check - conditions: - - condition: '=!IsBlank(Find("[COMPLETE]", Upper(Last(Local.LatestMessage).Text)))' - id: check_done - actions: - - kind: EndConversation - id: end_workflow - - - condition: "=Local.TurnCount >= 4" - id: check_turn_count_exceeded - actions: - - kind: SendActivity - id: send_activity_tired - activity: "Let's try again later...I am tired." - - elseActions: - - kind: GotoAction - id: goto_student_agent - actionId: student_agent -""" - - workflow = project_client.agents.create_version( - agent_name="student-teacher-workflow", - definition=WorkflowAgentDefinition(workflow=workflow_yaml), - ) - - print(f"Agent created (id: {workflow.id}, name: {workflow.name}, version: {workflow.version})") - - conversation = openai_client.conversations.create() - print(f"Created conversation (id: {conversation.id})") - - stream = openai_client.responses.create( - conversation=conversation.id, - extra_body={"agent_reference": {"name": workflow.name, "type": "agent_reference"}}, - input="Please summarize the Azure REST API specifications Readme", - stream=True, - ) - - # Track MCP approval requests during streaming - mcp_approval_requests = [] - response = None - - for event in stream: - print(f"Event {event.sequence_number} type '{event.type}'", end="") - if ( - event.type in ("response.output_item.added", "response.output_item.done") - ) and event.item.type == "workflow_action": # pyright: ignore [reportAttributeAccessIssue] - print( - f": item action ID '{event.item.action_id}' is '{event.item.status}' (previous action ID: '{event.item.previous_action_id}')", # pyright: ignore [reportAttributeAccessIssue] - end="", - ) - elif ( - event.type == "response.output_item.done" and event.item.type == "mcp_approval_request" - ): # pyright: ignore [reportAttributeAccessIssue] - # Collect MCP approval requests during streaming - print( - f": MCP approval request for server '{event.item.server_label}'", end="" - ) # pyright: ignore [reportAttributeAccessIssue] - mcp_approval_requests.append(event.item) # pyright: ignore [reportAttributeAccessIssue] - elif event.type == "response.output_item.added" and hasattr( - event, "item" - ): # pyright: ignore [reportAttributeAccessIssue] - # Print other item types - print(f": item type '{event.item.type}'", end="") # pyright: ignore [reportAttributeAccessIssue] - elif event.type == "response.completed": - response = openai_client.responses.retrieve(event.response.id) - print(f": Final Response: {response.output_text}", end="") - elif event.type == "response.failed": - response = openai_client.responses.retrieve(event.response.id) - print(f": Response failed - Error: {response.error}", end="") - print("", flush=True) - - print(f"\nStream completed. Response status: {response.status if response else 'No response'}") - print(f"MCP approval requests collected: {len(mcp_approval_requests)}") - - # Process any MCP approval requests that were collected - if mcp_approval_requests and response: - print(f"\nProcessing {len(mcp_approval_requests)} MCP approval request(s)...") - input_list: ResponseInputParam = [] - - for item in mcp_approval_requests: - if item.server_label == "api-specs" and item.id: - # Automatically approve the MCP request to allow the agent to proceed - print(f"Approving MCP request for server '{item.server_label}'") - input_list.append( - McpApprovalResponse( - type="mcp_approval_response", - approve=True, - approval_request_id=item.id, - ) - ) - - if input_list: - # Send the approval response back to continue the agent's work - print("\nContinuing workflow with MCP approvals...") - response = openai_client.responses.create( - input=input_list, - previous_response_id=response.id, - extra_body={"agent_reference": {"name": workflow.name, "type": "agent_reference"}}, - ) - print(f"Agent response after approval: {response.output_text}") - - openai_client.conversations.delete(conversation_id=conversation.id) - print("Conversation deleted") - - project_client.agents.delete_version(agent_name=workflow.name, agent_version=workflow.version) - print("Workflow deleted") - - project_client.agents.delete_version(agent_name=student_agent.name, agent_version=student_agent.version) - print("Student Agent deleted") - - project_client.agents.delete_version(agent_name=teacher_agent.name, agent_version=teacher_agent.version) - print("Teacher Agent deleted") diff --git a/sdk/ai/azure-ai-projects/samples/evaluations/sample_evaluations_builtin_with_traces.py b/sdk/ai/azure-ai-projects/samples/evaluations/sample_evaluations_builtin_with_traces.py index a5e88ab53301..7964127ffde2 100644 --- a/sdk/ai/azure-ai-projects/samples/evaluations/sample_evaluations_builtin_with_traces.py +++ b/sdk/ai/azure-ai-projects/samples/evaluations/sample_evaluations_builtin_with_traces.py @@ -47,7 +47,7 @@ from typing import Any, Dict, List, Optional from dotenv import load_dotenv from azure.identity import DefaultAzureCredential -from azure.monitor.query import LogsQueryClient, LogsQueryStatus +from azure.monitor.query import LogsQueryClient, LogsQueryResult from azure.ai.projects import AIProjectClient from azure.ai.projects.models import ( TestingCriterionAzureAIEvaluator, @@ -117,7 +117,7 @@ def get_trace_ids( print(f"Error executing query: {exc}") return [] - if response.status == LogsQueryStatus.SUCCESS: + if isinstance(response, LogsQueryResult): trace_ids: List[str] = [] for table in response.tables: for row in table.rows: diff --git a/sdk/ai/azure-ai-projects/samples/evaluations/sample_scheduled_agent_traces_evaluation_smart_filter.py b/sdk/ai/azure-ai-projects/samples/evaluations/sample_scheduled_agent_traces_evaluation_smart_filter.py index dc1a46e72825..0fca1ae84c9b 100644 --- a/sdk/ai/azure-ai-projects/samples/evaluations/sample_scheduled_agent_traces_evaluation_smart_filter.py +++ b/sdk/ai/azure-ai-projects/samples/evaluations/sample_scheduled_agent_traces_evaluation_smart_filter.py @@ -36,6 +36,7 @@ from azure.identity import DefaultAzureCredential from azure.ai.projects import AIProjectClient from azure.mgmt.authorization import AuthorizationManagementClient +from azure.mgmt.authorization.models import RoleAssignmentCreateParameters from azure.mgmt.resource.resources import ResourceManagementClient import uuid from azure.ai.projects.models import ( @@ -140,11 +141,11 @@ def assign_rbac(): # pylint: disable=too-many-statements role_assignment = auth_client.role_assignments.create( scope=scope, role_assignment_name=role_assignment_name, - parameters={ - "role_definition_id": f"{scope}/providers/Microsoft.Authorization/roleDefinitions/{foundry_user_role_id}", - "principal_id": principal_id, - "principal_type": "ServicePrincipal", - }, + parameters=RoleAssignmentCreateParameters( + role_definition_id=f"{scope}/providers/Microsoft.Authorization/roleDefinitions/{foundry_user_role_id}", + principal_id=principal_id, + principal_type="ServicePrincipal", + ), ) print("Successfully assigned 'Foundry User' role to project managed identity") diff --git a/sdk/ai/azure-ai-projects/samples/evaluations/sample_scheduled_evaluations.py b/sdk/ai/azure-ai-projects/samples/evaluations/sample_scheduled_evaluations.py index cbb22294f3d3..a1d1f848d6b5 100644 --- a/sdk/ai/azure-ai-projects/samples/evaluations/sample_scheduled_evaluations.py +++ b/sdk/ai/azure-ai-projects/samples/evaluations/sample_scheduled_evaluations.py @@ -37,6 +37,7 @@ from azure.identity import DefaultAzureCredential from azure.ai.projects import AIProjectClient from azure.mgmt.authorization import AuthorizationManagementClient +from azure.mgmt.authorization.models import RoleAssignmentCreateParameters from azure.mgmt.resource.resources import ResourceManagementClient import uuid from azure.ai.projects.models import ( @@ -156,11 +157,11 @@ def assign_rbac(): # pylint: disable=too-many-statements role_assignment = auth_client.role_assignments.create( scope=scope, role_assignment_name=role_assignment_name, - parameters={ - "role_definition_id": f"{scope}/providers/Microsoft.Authorization/roleDefinitions/{azure_ai_user_role_id}", - "principal_id": principal_id, - "principal_type": "ServicePrincipal", - }, + parameters=RoleAssignmentCreateParameters( + role_definition_id=f"{scope}/providers/Microsoft.Authorization/roleDefinitions/{azure_ai_user_role_id}", + principal_id=principal_id, + principal_type="ServicePrincipal", + ), ) print("Successfully assigned 'Azure AI User' role to project managed identity") diff --git a/sdk/ai/azure-ai-projects/tests/foundry_features_header/foundry_features_header_test_base.py b/sdk/ai/azure-ai-projects/tests/foundry_features_header/foundry_features_header_test_base.py index d34aab6783b8..8dabe19898d1 100644 --- a/sdk/ai/azure-ai-projects/tests/foundry_features_header/foundry_features_header_test_base.py +++ b/sdk/ai/azure-ai-projects/tests/foundry_features_header/foundry_features_header_test_base.py @@ -35,6 +35,7 @@ # If a new sub-client is added to .beta and is missing from this mapping, the test will # fail at collection time with a message asking you to add it here. EXPECTED_FOUNDRY_FEATURES: dict[str, str] = { + "agent_insight_monitors": "AgentInsights=V1Preview", "evaluation_taxonomies": "Evaluations=V1Preview", "evaluators": "Evaluations=V1Preview", "insights": "Insights=V1Preview", diff --git a/sdk/ai/azure-ai-projects/tsp-location.yaml b/sdk/ai/azure-ai-projects/tsp-location.yaml index 259cd043ef1f..5373022feee9 100644 --- a/sdk/ai/azure-ai-projects/tsp-location.yaml +++ b/sdk/ai/azure-ai-projects/tsp-location.yaml @@ -1,10 +1,12 @@ directory: specification/ai-foundry/data-plane/Foundry/src/sdk-python-js-azure-ai-projects -commit: 9a1ee382eb32ff2af52911bf3106d97d0a6ab226 +commit: de5663ab08e7c3b25a06f2597caceb6fb1bc9622 repo: Azure/azure-rest-api-specs additionalDirectories: - specification/ai-foundry/data-plane/Foundry/src/agents +- specification/ai-foundry/data-plane/Foundry/src/agent-insights - specification/ai-foundry/data-plane/Foundry/src/agents-optimization - specification/ai-foundry/data-plane/Foundry/src/agents-session-files +- specification/ai-foundry/data-plane/Foundry/src/agents-microsoft365 - specification/ai-foundry/data-plane/Foundry/src/common - specification/ai-foundry/data-plane/Foundry/src/connections - specification/ai-foundry/data-plane/Foundry/src/data_generation_jobs @@ -25,3 +27,4 @@ additionalDirectories: - specification/ai-foundry/data-plane/Foundry/src/skills - specification/ai-foundry/data-plane/Foundry/src/toolboxes - specification/ai-foundry/data-plane/Foundry/src/tools +- specification/ai-foundry/data-plane/Foundry/src/voice-agents