From a73731ec9abd0e90059c1bc13fd4db0240c21b2c Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Mon, 31 Mar 2025 21:15:13 +0000 Subject: [PATCH] CodeGen from PR 33586 in Azure/azure-rest-api-specs Merge 2c091c7ef551d56a3f28816c47aed3a5643e10b3 into fb20a8ac093b18494b6055c52ad09e81cba20b4c --- .../ai-projects-1dp/src/clientDefinitions.ts | 440 ++++++++++++ sdk/ai/ai-projects-1dp/src/index.ts | 15 + sdk/ai/ai-projects-1dp/src/isUnexpected.ts | 414 +++++++++++ sdk/ai/ai-projects-1dp/src/logger.ts | 5 + sdk/ai/ai-projects-1dp/src/models.ts | 206 ++++++ sdk/ai/ai-projects-1dp/src/outputModels.ts | 381 ++++++++++ sdk/ai/ai-projects-1dp/src/paginateHelper.ts | 294 ++++++++ sdk/ai/ai-projects-1dp/src/parameters.ts | 445 ++++++++++++ sdk/ai/ai-projects-1dp/src/projectsClient.ts | 80 +++ sdk/ai/ai-projects-1dp/src/responses.ts | 650 ++++++++++++++++++ .../test/public/sampleTest.spec.ts | 21 + .../test/public/utils/recordedClient.ts | 29 + sdk/ai/ai-projects-1dp/tsp-location.yaml | 4 + 13 files changed, 2984 insertions(+) create mode 100644 sdk/ai/ai-projects-1dp/src/clientDefinitions.ts create mode 100644 sdk/ai/ai-projects-1dp/src/index.ts create mode 100644 sdk/ai/ai-projects-1dp/src/isUnexpected.ts create mode 100644 sdk/ai/ai-projects-1dp/src/logger.ts create mode 100644 sdk/ai/ai-projects-1dp/src/models.ts create mode 100644 sdk/ai/ai-projects-1dp/src/outputModels.ts create mode 100644 sdk/ai/ai-projects-1dp/src/paginateHelper.ts create mode 100644 sdk/ai/ai-projects-1dp/src/parameters.ts create mode 100644 sdk/ai/ai-projects-1dp/src/projectsClient.ts create mode 100644 sdk/ai/ai-projects-1dp/src/responses.ts create mode 100644 sdk/ai/ai-projects-1dp/test/public/sampleTest.spec.ts create mode 100644 sdk/ai/ai-projects-1dp/test/public/utils/recordedClient.ts create mode 100644 sdk/ai/ai-projects-1dp/tsp-location.yaml diff --git a/sdk/ai/ai-projects-1dp/src/clientDefinitions.ts b/sdk/ai/ai-projects-1dp/src/clientDefinitions.ts new file mode 100644 index 000000000000..5674d521af72 --- /dev/null +++ b/sdk/ai/ai-projects-1dp/src/clientDefinitions.ts @@ -0,0 +1,440 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { + ConnectionsGetParameters, + ConnectionsListParameters, + EvaluationsGetParameters, + EvaluationsListParameters, + EvaluationsCreateRunParameters, + DatasetsListVersionsParameters, + DatasetsCreateParameters, + DatasetsListLatestParameters, + DatasetsGetVersionParameters, + DatasetsDeleteVersionParameters, + DatasetsCreateVersionParameters, + DatasetsStartPendingUploadVersionParameters, + DatasetsStartPendingUploadParameters, + IndexesListVersionsParameters, + IndexesCreateParameters, + IndexesListLatestParameters, + IndexesGetVersionParameters, + IndexesDeleteVersionParameters, + IndexesCreateVersionParameters, + DeploymentsGetParameters, + DeploymentsListParameters, + EvaluationResultsListVersionsParameters, + EvaluationResultsCreateParameters, + EvaluationResultsListLatestParameters, + EvaluationResultsGetVersionParameters, + EvaluationResultsDeleteVersionParameters, + EvaluationResultsCreateVersionParameters, + EvaluationResultsStartPendingUploadParameters, + RedTeamsGetParameters, + RedTeamsListParameters, + RedTeamsCreateRunParameters, +} from "./parameters.js"; +import type { + ConnectionsGet200Response, + ConnectionsGetDefaultResponse, + ConnectionsList200Response, + ConnectionsListDefaultResponse, + EvaluationsGet200Response, + EvaluationsGetDefaultResponse, + EvaluationsList200Response, + EvaluationsListDefaultResponse, + EvaluationsCreateRun200Response, + EvaluationsCreateRunDefaultResponse, + DatasetsListVersions200Response, + DatasetsListVersionsDefaultResponse, + DatasetsCreate200Response, + DatasetsCreateDefaultResponse, + DatasetsListLatest200Response, + DatasetsListLatestDefaultResponse, + DatasetsGetVersion200Response, + DatasetsGetVersionDefaultResponse, + DatasetsDeleteVersion204Response, + DatasetsDeleteVersionDefaultResponse, + DatasetsCreateVersion200Response, + DatasetsCreateVersion201Response, + DatasetsCreateVersionDefaultResponse, + DatasetsStartPendingUploadVersion200Response, + DatasetsStartPendingUploadVersionDefaultResponse, + DatasetsStartPendingUpload200Response, + DatasetsStartPendingUploadDefaultResponse, + IndexesListVersions200Response, + IndexesListVersionsDefaultResponse, + IndexesCreate200Response, + IndexesCreateDefaultResponse, + IndexesListLatest200Response, + IndexesListLatestDefaultResponse, + IndexesGetVersion200Response, + IndexesGetVersionDefaultResponse, + IndexesDeleteVersion204Response, + IndexesDeleteVersionDefaultResponse, + IndexesCreateVersion200Response, + IndexesCreateVersion201Response, + IndexesCreateVersionDefaultResponse, + DeploymentsGet200Response, + DeploymentsGetDefaultResponse, + DeploymentsList200Response, + DeploymentsListDefaultResponse, + EvaluationResultsListVersions200Response, + EvaluationResultsListVersionsDefaultResponse, + EvaluationResultsCreate200Response, + EvaluationResultsCreateDefaultResponse, + EvaluationResultsListLatest200Response, + EvaluationResultsListLatestDefaultResponse, + EvaluationResultsGetVersion200Response, + EvaluationResultsGetVersionDefaultResponse, + EvaluationResultsDeleteVersion204Response, + EvaluationResultsDeleteVersionDefaultResponse, + EvaluationResultsCreateVersion200Response, + EvaluationResultsCreateVersion201Response, + EvaluationResultsCreateVersionDefaultResponse, + EvaluationResultsStartPendingUpload200Response, + EvaluationResultsStartPendingUploadDefaultResponse, + RedTeamsGet200Response, + RedTeamsGetDefaultResponse, + RedTeamsList200Response, + RedTeamsListDefaultResponse, + RedTeamsCreateRun200Response, + RedTeamsCreateRunDefaultResponse, +} from "./responses.js"; +import type { Client, StreamableMethod } from "@azure-rest/core-client"; + +export interface ConnectionsGet { + /** Get a connection by name. */ + get( + options?: ConnectionsGetParameters, + ): StreamableMethod< + ConnectionsGet200Response | ConnectionsGetDefaultResponse + >; +} + +export interface ConnectionsList { + /** List all connections in the project */ + get( + options?: ConnectionsListParameters, + ): StreamableMethod< + ConnectionsList200Response | ConnectionsListDefaultResponse + >; +} + +export interface EvaluationsGet { + /** Get an evaluation run by name. */ + get( + options?: EvaluationsGetParameters, + ): StreamableMethod< + EvaluationsGet200Response | EvaluationsGetDefaultResponse + >; +} + +export interface EvaluationsList { + /** List evaluation runs */ + get( + options?: EvaluationsListParameters, + ): StreamableMethod< + EvaluationsList200Response | EvaluationsListDefaultResponse + >; +} + +export interface EvaluationsCreateRun { + /** Creates an evaluation run. */ + post( + options: EvaluationsCreateRunParameters, + ): StreamableMethod< + EvaluationsCreateRun200Response | EvaluationsCreateRunDefaultResponse + >; +} + +export interface DatasetsListVersions { + /** List all versions of the given DatasetVersion */ + get( + options?: DatasetsListVersionsParameters, + ): StreamableMethod< + DatasetsListVersions200Response | DatasetsListVersionsDefaultResponse + >; + /** Create a new DatasetVersion. The version id will be generated by the service. */ + post( + options: DatasetsCreateParameters, + ): StreamableMethod< + DatasetsCreate200Response | DatasetsCreateDefaultResponse + >; +} + +export interface DatasetsListLatest { + /** List the latest version of each DatasetVersion */ + get( + options?: DatasetsListLatestParameters, + ): StreamableMethod< + DatasetsListLatest200Response | DatasetsListLatestDefaultResponse + >; +} + +export interface DatasetsGetVersion { + /** Get the specific version of the DatasetVersion */ + get( + options?: DatasetsGetVersionParameters, + ): StreamableMethod< + DatasetsGetVersion200Response | DatasetsGetVersionDefaultResponse + >; + /** Delete the specific version of the DatasetVersion */ + delete( + options?: DatasetsDeleteVersionParameters, + ): StreamableMethod< + DatasetsDeleteVersion204Response | DatasetsDeleteVersionDefaultResponse + >; + /** Create a new or replace an existing DatasetVersion with the given version id */ + put( + options: DatasetsCreateVersionParameters, + ): StreamableMethod< + | DatasetsCreateVersion200Response + | DatasetsCreateVersion201Response + | DatasetsCreateVersionDefaultResponse + >; +} + +export interface DatasetsStartPendingUploadVersion { + /** Create or start a pending upload of a dataset for a specific version. */ + post( + options: DatasetsStartPendingUploadVersionParameters, + ): StreamableMethod< + | DatasetsStartPendingUploadVersion200Response + | DatasetsStartPendingUploadVersionDefaultResponse + >; +} + +export interface DatasetsStartPendingUpload { + /** Create or start a pending upload of a dataset. The version id will be generated by the service. */ + post( + options: DatasetsStartPendingUploadParameters, + ): StreamableMethod< + | DatasetsStartPendingUpload200Response + | DatasetsStartPendingUploadDefaultResponse + >; +} + +export interface IndexesListVersions { + /** List all versions of the given Index */ + get( + options?: IndexesListVersionsParameters, + ): StreamableMethod< + IndexesListVersions200Response | IndexesListVersionsDefaultResponse + >; + /** Create a new Index. The version id will be generated by the service. */ + post( + options: IndexesCreateParameters, + ): StreamableMethod; +} + +export interface IndexesListLatest { + /** List the latest version of each Index */ + get( + options?: IndexesListLatestParameters, + ): StreamableMethod< + IndexesListLatest200Response | IndexesListLatestDefaultResponse + >; +} + +export interface IndexesGetVersion { + /** Get the specific version of the Index */ + get( + options?: IndexesGetVersionParameters, + ): StreamableMethod< + IndexesGetVersion200Response | IndexesGetVersionDefaultResponse + >; + /** Delete the specific version of the Index */ + delete( + options?: IndexesDeleteVersionParameters, + ): StreamableMethod< + IndexesDeleteVersion204Response | IndexesDeleteVersionDefaultResponse + >; + /** Create a new or replace an existing Index with the given version id */ + put( + options: IndexesCreateVersionParameters, + ): StreamableMethod< + | IndexesCreateVersion200Response + | IndexesCreateVersion201Response + | IndexesCreateVersionDefaultResponse + >; +} + +export interface DeploymentsGet { + /** Get a deployed model. */ + get( + options?: DeploymentsGetParameters, + ): StreamableMethod< + DeploymentsGet200Response | DeploymentsGetDefaultResponse + >; +} + +export interface DeploymentsList { + /** List all deployed models in the project */ + get( + options?: DeploymentsListParameters, + ): StreamableMethod< + DeploymentsList200Response | DeploymentsListDefaultResponse + >; +} + +export interface EvaluationResultsListVersions { + /** List all versions of the given EvaluationResult */ + get( + options?: EvaluationResultsListVersionsParameters, + ): StreamableMethod< + | EvaluationResultsListVersions200Response + | EvaluationResultsListVersionsDefaultResponse + >; + /** Create a new EvaluationResult. The version id will be generated by the service. */ + post( + options: EvaluationResultsCreateParameters, + ): StreamableMethod< + EvaluationResultsCreate200Response | EvaluationResultsCreateDefaultResponse + >; +} + +export interface EvaluationResultsListLatest { + /** List the latest version of each EvaluationResult */ + get( + options?: EvaluationResultsListLatestParameters, + ): StreamableMethod< + | EvaluationResultsListLatest200Response + | EvaluationResultsListLatestDefaultResponse + >; +} + +export interface EvaluationResultsGetVersion { + /** Get the specific version of the EvaluationResult */ + get( + options?: EvaluationResultsGetVersionParameters, + ): StreamableMethod< + | EvaluationResultsGetVersion200Response + | EvaluationResultsGetVersionDefaultResponse + >; + /** Delete the specific version of the EvaluationResult */ + delete( + options?: EvaluationResultsDeleteVersionParameters, + ): StreamableMethod< + | EvaluationResultsDeleteVersion204Response + | EvaluationResultsDeleteVersionDefaultResponse + >; + /** Create a new or replace an existing EvaluationResult with the given version id */ + put( + options: EvaluationResultsCreateVersionParameters, + ): StreamableMethod< + | EvaluationResultsCreateVersion200Response + | EvaluationResultsCreateVersion201Response + | EvaluationResultsCreateVersionDefaultResponse + >; +} + +export interface EvaluationResultsStartPendingUpload { + /** Create or start a pending upload of a evaluation results for a specific version. */ + post( + options: EvaluationResultsStartPendingUploadParameters, + ): StreamableMethod< + | EvaluationResultsStartPendingUpload200Response + | EvaluationResultsStartPendingUploadDefaultResponse + >; +} + +export interface RedTeamsGet { + /** Get a redteam by name. */ + get( + options?: RedTeamsGetParameters, + ): StreamableMethod; +} + +export interface RedTeamsList { + /** List a redteam by name. */ + get( + options?: RedTeamsListParameters, + ): StreamableMethod; +} + +export interface RedTeamsCreateRun { + /** Creates a redteam run. */ + post( + options: RedTeamsCreateRunParameters, + ): StreamableMethod< + RedTeamsCreateRun200Response | RedTeamsCreateRunDefaultResponse + >; +} + +export interface Routes { + /** Resource for '/connections/\{name\}' has methods for the following verbs: get */ + (path: "/connections/{name}", name: string): ConnectionsGet; + /** Resource for '/connections' has methods for the following verbs: get */ + (path: "/connections"): ConnectionsList; + /** Resource for '/evaluations/runs/\{name\}' has methods for the following verbs: get */ + (path: "/evaluations/runs/{name}", name: string): EvaluationsGet; + /** Resource for '/evaluations/runs' has methods for the following verbs: get */ + (path: "/evaluations/runs"): EvaluationsList; + /** Resource for '/evaluations/runs:run' has methods for the following verbs: post */ + (path: "/evaluations/runs:run"): EvaluationsCreateRun; + /** Resource for '/datasets/\{name\}/versions' has methods for the following verbs: get, post */ + (path: "/datasets/{name}/versions", name: string): DatasetsListVersions; + /** Resource for '/datasets' has methods for the following verbs: get */ + (path: "/datasets"): DatasetsListLatest; + /** Resource for '/datasets/\{name\}/versions/\{version\}' has methods for the following verbs: get, delete, put */ + ( + path: "/datasets/{name}/versions/{version}", + name: string, + version: string, + ): DatasetsGetVersion; + /** Resource for '/datasets/\{name\}/versions/\{version\}/startPendingUploadVersion' has methods for the following verbs: post */ + ( + path: "/datasets/{name}/versions/{version}/startPendingUploadVersion", + name: string, + version: string, + ): DatasetsStartPendingUploadVersion; + /** Resource for '/datasets/\{name\}/startPendingUpload' has methods for the following verbs: post */ + ( + path: "/datasets/{name}/startPendingUpload", + name: string, + ): DatasetsStartPendingUpload; + /** Resource for '/indexes/\{name\}/versions' has methods for the following verbs: get, post */ + (path: "/indexes/{name}/versions", name: string): IndexesListVersions; + /** Resource for '/indexes' has methods for the following verbs: get */ + (path: "/indexes"): IndexesListLatest; + /** Resource for '/indexes/\{name\}/versions/\{version\}' has methods for the following verbs: get, delete, put */ + ( + path: "/indexes/{name}/versions/{version}", + name: string, + version: string, + ): IndexesGetVersion; + /** Resource for '/deployments/\{name\}' has methods for the following verbs: get */ + (path: "/deployments/{name}", name: string): DeploymentsGet; + /** Resource for '/deployments' has methods for the following verbs: get */ + (path: "/deployments"): DeploymentsList; + /** Resource for '/evaluationResults/\{name\}/versions' has methods for the following verbs: get, post */ + ( + path: "/evaluationResults/{name}/versions", + name: string, + ): EvaluationResultsListVersions; + /** Resource for '/evaluationResults' has methods for the following verbs: get */ + (path: "/evaluationResults"): EvaluationResultsListLatest; + /** Resource for '/evaluationResults/\{name\}/versions/\{version\}' has methods for the following verbs: get, delete, put */ + ( + path: "/evaluationResults/{name}/versions/{version}", + name: string, + version: string, + ): EvaluationResultsGetVersion; + /** Resource for '/evaluationResults/\{name\}/versions/\{version\}/startPendingUpload' has methods for the following verbs: post */ + ( + path: "/evaluationResults/{name}/versions/{version}/startPendingUpload", + name: string, + version: string, + ): EvaluationResultsStartPendingUpload; + /** Resource for '/redTeams/runs/\{name\}' has methods for the following verbs: get */ + (path: "/redTeams/runs/{name}", name: string): RedTeamsGet; + /** Resource for '/redTeams/runs' has methods for the following verbs: get */ + (path: "/redTeams/runs"): RedTeamsList; + /** Resource for '/redTeams/runs:run' has methods for the following verbs: post */ + (path: "/redTeams/runs:run"): RedTeamsCreateRun; +} + +export type ProjectsClient = Client & { + path: Routes; +}; diff --git a/sdk/ai/ai-projects-1dp/src/index.ts b/sdk/ai/ai-projects-1dp/src/index.ts new file mode 100644 index 000000000000..0afd734a7856 --- /dev/null +++ b/sdk/ai/ai-projects-1dp/src/index.ts @@ -0,0 +1,15 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import ProjectsClient from "./projectsClient.js"; + +export * from "./projectsClient.js"; +export * from "./parameters.js"; +export * from "./responses.js"; +export * from "./clientDefinitions.js"; +export * from "./isUnexpected.js"; +export * from "./models.js"; +export * from "./outputModels.js"; +export * from "./paginateHelper.js"; + +export default ProjectsClient; diff --git a/sdk/ai/ai-projects-1dp/src/isUnexpected.ts b/sdk/ai/ai-projects-1dp/src/isUnexpected.ts new file mode 100644 index 000000000000..94780e4bcfef --- /dev/null +++ b/sdk/ai/ai-projects-1dp/src/isUnexpected.ts @@ -0,0 +1,414 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { + ConnectionsGet200Response, + ConnectionsGetDefaultResponse, + ConnectionsList200Response, + ConnectionsListDefaultResponse, + EvaluationsGet200Response, + EvaluationsGetDefaultResponse, + EvaluationsList200Response, + EvaluationsListDefaultResponse, + EvaluationsCreateRun200Response, + EvaluationsCreateRunDefaultResponse, + DatasetsListVersions200Response, + DatasetsListVersionsDefaultResponse, + DatasetsCreate200Response, + DatasetsCreateDefaultResponse, + DatasetsListLatest200Response, + DatasetsListLatestDefaultResponse, + DatasetsGetVersion200Response, + DatasetsGetVersionDefaultResponse, + DatasetsDeleteVersion204Response, + DatasetsDeleteVersionDefaultResponse, + DatasetsCreateVersion200Response, + DatasetsCreateVersion201Response, + DatasetsCreateVersionDefaultResponse, + DatasetsStartPendingUploadVersion200Response, + DatasetsStartPendingUploadVersionDefaultResponse, + DatasetsStartPendingUpload200Response, + DatasetsStartPendingUploadDefaultResponse, + IndexesListVersions200Response, + IndexesListVersionsDefaultResponse, + IndexesCreate200Response, + IndexesCreateDefaultResponse, + IndexesListLatest200Response, + IndexesListLatestDefaultResponse, + IndexesGetVersion200Response, + IndexesGetVersionDefaultResponse, + IndexesDeleteVersion204Response, + IndexesDeleteVersionDefaultResponse, + IndexesCreateVersion200Response, + IndexesCreateVersion201Response, + IndexesCreateVersionDefaultResponse, + DeploymentsGet200Response, + DeploymentsGetDefaultResponse, + DeploymentsList200Response, + DeploymentsListDefaultResponse, + EvaluationResultsListVersions200Response, + EvaluationResultsListVersionsDefaultResponse, + EvaluationResultsCreate200Response, + EvaluationResultsCreateDefaultResponse, + EvaluationResultsListLatest200Response, + EvaluationResultsListLatestDefaultResponse, + EvaluationResultsGetVersion200Response, + EvaluationResultsGetVersionDefaultResponse, + EvaluationResultsDeleteVersion204Response, + EvaluationResultsDeleteVersionDefaultResponse, + EvaluationResultsCreateVersion200Response, + EvaluationResultsCreateVersion201Response, + EvaluationResultsCreateVersionDefaultResponse, + EvaluationResultsStartPendingUpload200Response, + EvaluationResultsStartPendingUploadDefaultResponse, + RedTeamsGet200Response, + RedTeamsGetDefaultResponse, + RedTeamsList200Response, + RedTeamsListDefaultResponse, + RedTeamsCreateRun200Response, + RedTeamsCreateRunDefaultResponse, +} from "./responses.js"; + +const responseMap: Record = { + "GET /connections/{name}": ["200"], + "GET /connections": ["200"], + "GET /evaluations/runs/{name}": ["200"], + "GET /evaluations/runs": ["200"], + "POST /evaluations/runs:run": ["200"], + "GET /datasets/{name}/versions": ["200"], + "POST /datasets/{name}/versions": ["200"], + "GET /datasets": ["200"], + "GET /datasets/{name}/versions/{version}": ["200"], + "DELETE /datasets/{name}/versions/{version}": ["204"], + "PUT /datasets/{name}/versions/{version}": ["200", "201"], + "POST /datasets/{name}/versions/{version}/startPendingUploadVersion": ["200"], + "POST /datasets/{name}/startPendingUpload": ["200"], + "GET /indexes/{name}/versions": ["200"], + "POST /indexes/{name}/versions": ["200"], + "GET /indexes": ["200"], + "GET /indexes/{name}/versions/{version}": ["200"], + "DELETE /indexes/{name}/versions/{version}": ["204"], + "PUT /indexes/{name}/versions/{version}": ["200", "201"], + "GET /deployments/{name}": ["200"], + "GET /deployments": ["200"], + "GET /evaluationResults/{name}/versions": ["200"], + "POST /evaluationResults/{name}/versions": ["200"], + "GET /evaluationResults": ["200"], + "GET /evaluationResults/{name}/versions/{version}": ["200"], + "DELETE /evaluationResults/{name}/versions/{version}": ["204"], + "PUT /evaluationResults/{name}/versions/{version}": ["200", "201"], + "POST /evaluationResults/{name}/versions/{version}/startPendingUpload": [ + "200", + ], + "GET /redTeams/runs/{name}": ["200"], + "GET /redTeams/runs": ["200"], + "POST /redTeams/runs:run": ["200"], +}; + +export function isUnexpected( + response: ConnectionsGet200Response | ConnectionsGetDefaultResponse, +): response is ConnectionsGetDefaultResponse; +export function isUnexpected( + response: ConnectionsList200Response | ConnectionsListDefaultResponse, +): response is ConnectionsListDefaultResponse; +export function isUnexpected( + response: EvaluationsGet200Response | EvaluationsGetDefaultResponse, +): response is EvaluationsGetDefaultResponse; +export function isUnexpected( + response: EvaluationsList200Response | EvaluationsListDefaultResponse, +): response is EvaluationsListDefaultResponse; +export function isUnexpected( + response: + | EvaluationsCreateRun200Response + | EvaluationsCreateRunDefaultResponse, +): response is EvaluationsCreateRunDefaultResponse; +export function isUnexpected( + response: + | DatasetsListVersions200Response + | DatasetsListVersionsDefaultResponse, +): response is DatasetsListVersionsDefaultResponse; +export function isUnexpected( + response: DatasetsCreate200Response | DatasetsCreateDefaultResponse, +): response is DatasetsCreateDefaultResponse; +export function isUnexpected( + response: DatasetsListLatest200Response | DatasetsListLatestDefaultResponse, +): response is DatasetsListLatestDefaultResponse; +export function isUnexpected( + response: DatasetsGetVersion200Response | DatasetsGetVersionDefaultResponse, +): response is DatasetsGetVersionDefaultResponse; +export function isUnexpected( + response: + | DatasetsDeleteVersion204Response + | DatasetsDeleteVersionDefaultResponse, +): response is DatasetsDeleteVersionDefaultResponse; +export function isUnexpected( + response: + | DatasetsCreateVersion200Response + | DatasetsCreateVersion201Response + | DatasetsCreateVersionDefaultResponse, +): response is DatasetsCreateVersionDefaultResponse; +export function isUnexpected( + response: + | DatasetsStartPendingUploadVersion200Response + | DatasetsStartPendingUploadVersionDefaultResponse, +): response is DatasetsStartPendingUploadVersionDefaultResponse; +export function isUnexpected( + response: + | DatasetsStartPendingUpload200Response + | DatasetsStartPendingUploadDefaultResponse, +): response is DatasetsStartPendingUploadDefaultResponse; +export function isUnexpected( + response: IndexesListVersions200Response | IndexesListVersionsDefaultResponse, +): response is IndexesListVersionsDefaultResponse; +export function isUnexpected( + response: IndexesCreate200Response | IndexesCreateDefaultResponse, +): response is IndexesCreateDefaultResponse; +export function isUnexpected( + response: IndexesListLatest200Response | IndexesListLatestDefaultResponse, +): response is IndexesListLatestDefaultResponse; +export function isUnexpected( + response: IndexesGetVersion200Response | IndexesGetVersionDefaultResponse, +): response is IndexesGetVersionDefaultResponse; +export function isUnexpected( + response: + | IndexesDeleteVersion204Response + | IndexesDeleteVersionDefaultResponse, +): response is IndexesDeleteVersionDefaultResponse; +export function isUnexpected( + response: + | IndexesCreateVersion200Response + | IndexesCreateVersion201Response + | IndexesCreateVersionDefaultResponse, +): response is IndexesCreateVersionDefaultResponse; +export function isUnexpected( + response: DeploymentsGet200Response | DeploymentsGetDefaultResponse, +): response is DeploymentsGetDefaultResponse; +export function isUnexpected( + response: DeploymentsList200Response | DeploymentsListDefaultResponse, +): response is DeploymentsListDefaultResponse; +export function isUnexpected( + response: + | EvaluationResultsListVersions200Response + | EvaluationResultsListVersionsDefaultResponse, +): response is EvaluationResultsListVersionsDefaultResponse; +export function isUnexpected( + response: + | EvaluationResultsCreate200Response + | EvaluationResultsCreateDefaultResponse, +): response is EvaluationResultsCreateDefaultResponse; +export function isUnexpected( + response: + | EvaluationResultsListLatest200Response + | EvaluationResultsListLatestDefaultResponse, +): response is EvaluationResultsListLatestDefaultResponse; +export function isUnexpected( + response: + | EvaluationResultsGetVersion200Response + | EvaluationResultsGetVersionDefaultResponse, +): response is EvaluationResultsGetVersionDefaultResponse; +export function isUnexpected( + response: + | EvaluationResultsDeleteVersion204Response + | EvaluationResultsDeleteVersionDefaultResponse, +): response is EvaluationResultsDeleteVersionDefaultResponse; +export function isUnexpected( + response: + | EvaluationResultsCreateVersion200Response + | EvaluationResultsCreateVersion201Response + | EvaluationResultsCreateVersionDefaultResponse, +): response is EvaluationResultsCreateVersionDefaultResponse; +export function isUnexpected( + response: + | EvaluationResultsStartPendingUpload200Response + | EvaluationResultsStartPendingUploadDefaultResponse, +): response is EvaluationResultsStartPendingUploadDefaultResponse; +export function isUnexpected( + response: RedTeamsGet200Response | RedTeamsGetDefaultResponse, +): response is RedTeamsGetDefaultResponse; +export function isUnexpected( + response: RedTeamsList200Response | RedTeamsListDefaultResponse, +): response is RedTeamsListDefaultResponse; +export function isUnexpected( + response: RedTeamsCreateRun200Response | RedTeamsCreateRunDefaultResponse, +): response is RedTeamsCreateRunDefaultResponse; +export function isUnexpected( + response: + | ConnectionsGet200Response + | ConnectionsGetDefaultResponse + | ConnectionsList200Response + | ConnectionsListDefaultResponse + | EvaluationsGet200Response + | EvaluationsGetDefaultResponse + | EvaluationsList200Response + | EvaluationsListDefaultResponse + | EvaluationsCreateRun200Response + | EvaluationsCreateRunDefaultResponse + | DatasetsListVersions200Response + | DatasetsListVersionsDefaultResponse + | DatasetsCreate200Response + | DatasetsCreateDefaultResponse + | DatasetsListLatest200Response + | DatasetsListLatestDefaultResponse + | DatasetsGetVersion200Response + | DatasetsGetVersionDefaultResponse + | DatasetsDeleteVersion204Response + | DatasetsDeleteVersionDefaultResponse + | DatasetsCreateVersion200Response + | DatasetsCreateVersion201Response + | DatasetsCreateVersionDefaultResponse + | DatasetsStartPendingUploadVersion200Response + | DatasetsStartPendingUploadVersionDefaultResponse + | DatasetsStartPendingUpload200Response + | DatasetsStartPendingUploadDefaultResponse + | IndexesListVersions200Response + | IndexesListVersionsDefaultResponse + | IndexesCreate200Response + | IndexesCreateDefaultResponse + | IndexesListLatest200Response + | IndexesListLatestDefaultResponse + | IndexesGetVersion200Response + | IndexesGetVersionDefaultResponse + | IndexesDeleteVersion204Response + | IndexesDeleteVersionDefaultResponse + | IndexesCreateVersion200Response + | IndexesCreateVersion201Response + | IndexesCreateVersionDefaultResponse + | DeploymentsGet200Response + | DeploymentsGetDefaultResponse + | DeploymentsList200Response + | DeploymentsListDefaultResponse + | EvaluationResultsListVersions200Response + | EvaluationResultsListVersionsDefaultResponse + | EvaluationResultsCreate200Response + | EvaluationResultsCreateDefaultResponse + | EvaluationResultsListLatest200Response + | EvaluationResultsListLatestDefaultResponse + | EvaluationResultsGetVersion200Response + | EvaluationResultsGetVersionDefaultResponse + | EvaluationResultsDeleteVersion204Response + | EvaluationResultsDeleteVersionDefaultResponse + | EvaluationResultsCreateVersion200Response + | EvaluationResultsCreateVersion201Response + | EvaluationResultsCreateVersionDefaultResponse + | EvaluationResultsStartPendingUpload200Response + | EvaluationResultsStartPendingUploadDefaultResponse + | RedTeamsGet200Response + | RedTeamsGetDefaultResponse + | RedTeamsList200Response + | RedTeamsListDefaultResponse + | RedTeamsCreateRun200Response + | RedTeamsCreateRunDefaultResponse, +): response is + | ConnectionsGetDefaultResponse + | ConnectionsListDefaultResponse + | EvaluationsGetDefaultResponse + | EvaluationsListDefaultResponse + | EvaluationsCreateRunDefaultResponse + | DatasetsListVersionsDefaultResponse + | DatasetsCreateDefaultResponse + | DatasetsListLatestDefaultResponse + | DatasetsGetVersionDefaultResponse + | DatasetsDeleteVersionDefaultResponse + | DatasetsCreateVersionDefaultResponse + | DatasetsStartPendingUploadVersionDefaultResponse + | DatasetsStartPendingUploadDefaultResponse + | IndexesListVersionsDefaultResponse + | IndexesCreateDefaultResponse + | IndexesListLatestDefaultResponse + | IndexesGetVersionDefaultResponse + | IndexesDeleteVersionDefaultResponse + | IndexesCreateVersionDefaultResponse + | DeploymentsGetDefaultResponse + | DeploymentsListDefaultResponse + | EvaluationResultsListVersionsDefaultResponse + | EvaluationResultsCreateDefaultResponse + | EvaluationResultsListLatestDefaultResponse + | EvaluationResultsGetVersionDefaultResponse + | EvaluationResultsDeleteVersionDefaultResponse + | EvaluationResultsCreateVersionDefaultResponse + | EvaluationResultsStartPendingUploadDefaultResponse + | RedTeamsGetDefaultResponse + | RedTeamsListDefaultResponse + | RedTeamsCreateRunDefaultResponse { + const lroOriginal = response.headers["x-ms-original-url"]; + const url = new URL(lroOriginal ?? response.request.url); + const method = response.request.method; + let pathDetails = responseMap[`${method} ${url.pathname}`]; + if (!pathDetails) { + pathDetails = getParametrizedPathSuccess(method, url.pathname); + } + return !pathDetails.includes(response.status); +} + +function getParametrizedPathSuccess(method: string, path: string): string[] { + const pathParts = path.split("/"); + + // Traverse list to match the longest candidate + // matchedLen: the length of candidate path + // matchedValue: the matched status code array + let matchedLen = -1, + matchedValue: string[] = []; + + // Iterate the responseMap to find a match + for (const [key, value] of Object.entries(responseMap)) { + // Extracting the path from the map key which is in format + // GET /path/foo + if (!key.startsWith(method)) { + continue; + } + const candidatePath = getPathFromMapKey(key); + // Get each part of the url path + const candidateParts = candidatePath.split("/"); + + // track if we have found a match to return the values found. + let found = true; + for ( + let i = candidateParts.length - 1, j = pathParts.length - 1; + i >= 1 && j >= 1; + i--, j-- + ) { + if ( + candidateParts[i]?.startsWith("{") && + candidateParts[i]?.indexOf("}") !== -1 + ) { + const start = candidateParts[i]!.indexOf("}") + 1, + end = candidateParts[i]?.length; + // If the current part of the candidate is a "template" part + // Try to use the suffix of pattern to match the path + // {guid} ==> $ + // {guid}:export ==> :export$ + const isMatched = new RegExp( + `${candidateParts[i]?.slice(start, end)}`, + ).test(pathParts[j] || ""); + + if (!isMatched) { + found = false; + break; + } + continue; + } + + // If the candidate part is not a template and + // the parts don't match mark the candidate as not found + // to move on with the next candidate path. + if (candidateParts[i] !== pathParts[j]) { + found = false; + break; + } + } + + // We finished evaluating the current candidate parts + // Update the matched value if and only if we found the longer pattern + if (found && candidatePath.length > matchedLen) { + matchedLen = candidatePath.length; + matchedValue = value; + } + } + + return matchedValue; +} + +function getPathFromMapKey(mapKey: string): string { + const pathStart = mapKey.indexOf("/"); + return mapKey.slice(pathStart); +} diff --git a/sdk/ai/ai-projects-1dp/src/logger.ts b/sdk/ai/ai-projects-1dp/src/logger.ts new file mode 100644 index 000000000000..26856543a80b --- /dev/null +++ b/sdk/ai/ai-projects-1dp/src/logger.ts @@ -0,0 +1,5 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { createClientLogger } from "@azure/logger"; +export const logger = createClientLogger("ai-projects-1dp"); diff --git a/sdk/ai/ai-projects-1dp/src/models.ts b/sdk/ai/ai-projects-1dp/src/models.ts new file mode 100644 index 000000000000..a5bba07d9c71 --- /dev/null +++ b/sdk/ai/ai-projects-1dp/src/models.ts @@ -0,0 +1,206 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +/** Evaluation Definition */ +export interface Evaluation { + /** Data for evaluation. */ + data: InputData; + /** Display Name for evaluation. It helps to find the evaluation easily in AI Foundry. It does not need to be unique. */ + displayName?: string; + /** Description of the evaluation. It can be used to store additional information about the evaluation and is mutable. */ + description?: string; + /** Evaluation's tags. Unlike properties, tags are fully mutable. */ + tags?: Record; + /** Evaluation's properties. Unlike tags, properties are add-only. Once added, a property cannot be removed. */ + properties?: Record; + /** Evaluators to be used for the evaluation. */ + evaluators: Record; +} + +/** Abstract data class. */ +export interface InputDataParent { + type: string; +} + +/** Dataset as source for evaluation. */ +export interface InputDataset extends InputDataParent { + type: "dataset"; + /** Evaluation input data */ + id: string; +} + +/** Evaluator Configuration */ +export interface EvaluatorConfiguration { + /** Identifier of the evaluator. */ + id: string; + /** Initialization parameters of the evaluator. */ + initParams?: Record; + /** Data parameters of the evaluator. */ + dataMapping?: Record; +} + +/** DatasetVersion Definition */ +export interface DatasetVersionParent { + /** [Required] Uri of the data. Example: https://go.microsoft.com/fwlink/?linkid=2202330 */ + datasetUri: string; + /** Asset stage */ + stage?: string; + /** The asset description text. */ + description?: string; + /** Tag dictionary. Tags can be added, removed, and updated. */ + tags?: Record; + type: DatasetType; +} + +/** FileDatasetVersion Definition */ +export interface FileDatasetVersion extends DatasetVersionParent { + /** Dataset type */ + type: "uri_file"; + /** Indicates OpenAI Purpose. FileDatasets created with this field will be compatible with OpenAI-specific features */ + openAIPurpose: string; +} + +/** FileDatasetVersion Definition */ +export interface FolderDatasetVersion extends DatasetVersionParent { + /** Dataset type */ + type: "uri_folder"; +} + +/** Represents a request for a pending upload. */ +export interface PendingUploadRequest { + /** If PendingUploadId is not provided, a random GUID will be used. */ + pendingUploadId?: string; + /** Name of Azure blob storage connection to use for generating temporary SAS token */ + connectionName?: string; + /** TemporaryBlobReference is the only supported type. */ + pendingUploadType: "TemporaryBlobReference"; +} + +/** Index resource Definition */ +export interface IndexParent { + /** Asset stage */ + stage?: string; + /** The asset description text. */ + description?: string; + /** Tag dictionary. Tags can be added, removed, and updated. */ + tags?: Record; + type: IndexType; +} + +/** Azure AI Search Index Definition */ +export interface AzureAISearchIndex extends IndexParent { + /** Type of index */ + type: "AzureSearch"; + /** Name of connection to Azure AI Search */ + connectionName: string; + /** Name of index in Azure AI Search resource to attach */ + indexName: string; +} + +/** Managed Azure AI Search Index Definition */ +export interface ManagedAzureAISearchIndex extends IndexParent { + /** Type of index */ + type: "ManagedAzureSearch"; + /** Vector store id of managed index */ + vectorStoreId: string; +} + +/** CosmosDB Vector Store Index Definition */ +export interface CosmosDBIndex extends IndexParent { + /** Type of index */ + type: "CosmosDBNoSqlVectorStore"; + /** Name of connection to CosmosDB */ + connectionName: string; + /** Name of the CosmosDB Database */ + databaseName: string; + /** Name of CosmosDB Container */ + containerName: string; + /** Embedding model configuration */ + embeddingConfiguration: EmbeddingConfiguration; +} + +/** Embedding configuration class */ +export interface EmbeddingConfiguration { + /** Deployment name of embedding model. It can point to a model deployment either in the parent AIServices or a connection. */ + modelDeploymentName: string; + /** Embedding field */ + embeddingField: string; +} + +/** Evaluation Result resource Definition */ +export interface EvaluationResult { + /** + * Type of Evaluation result + * + * Possible values: "Benchmark", "Evaluation", "Redteam", "Simulation" + */ + ResultType?: ResultType; + /** Model Name */ + ModelName?: string; + /** Model Version */ + ModelVersion?: string; + /** Model Asset ID */ + ModelAssetId?: string; + /** Dataset Family */ + DatasetFamily?: string; + /** Dataset Name */ + DatasetName?: string; + /** Metrics */ + Metrics?: Record; + /** Blob URI */ + BlobUri?: string; + /** Asset stage */ + stage?: string; + /** The asset description text. */ + description?: string; + /** Tag dictionary. Tags can be added, removed, and updated. */ + tags?: Record; +} + +/** Red team details. */ +export interface RedTeam { + /** Name of the red-team scan. */ + scanName: string; + /** Number of simulation rounds. */ + numTurns: number; + /** List of attack strategies or nested lists of attack strategies. */ + attackStrategy: AttackStrategy[]; + /** Simulation-only or Simulation + Evaluation. Default false, if true the scan outputs conversation not evaluation result. */ + simulationOnly: boolean; + /** List of risk categories to generate attack objectives for. */ + riskCategories: RiskCategory[]; + /** Application scenario for the red team operation, to generate scenario specific attacks. */ + applicationScenario?: string; + /** Red team's tags. Unlike properties, tags are fully mutable. */ + tags?: Record; + /** Red team's properties. Unlike tags, properties are add-only. Once added, a property cannot be removed. */ + properties?: Record; +} + +/** Abstract data class. */ +export type InputData = InputDataParent | InputDataset; +/** DatasetVersion Definition */ +export type DatasetVersion = + | DatasetVersionParent + | FileDatasetVersion + | FolderDatasetVersion; +/** Index resource Definition */ +export type Index = + | IndexParent + | AzureAISearchIndex + | ManagedAzureAISearchIndex + | CosmosDBIndex; +/** Alias for ConnectionType */ +export type ConnectionType = string; +/** Alias for ListViewType */ +export type ListViewType = string; +/** Alias for DatasetType */ +export type DatasetType = string; +/** Alias for IndexType */ +export type IndexType = string; +/** Alias for ResultType */ +export type ResultType = string; +/** Alias for AttackStrategy */ +export type AttackStrategy = string; +/** Alias for RiskCategory */ +export type RiskCategory = string; diff --git a/sdk/ai/ai-projects-1dp/src/outputModels.ts b/sdk/ai/ai-projects-1dp/src/outputModels.ts new file mode 100644 index 000000000000..f8d4d655c815 --- /dev/null +++ b/sdk/ai/ai-projects-1dp/src/outputModels.ts @@ -0,0 +1,381 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +/** Response from the listSecrets operation */ +export interface ConnectionOutput { + /** The name of the resource */ + readonly name: string; + /** + * Category of the connection + * + * Possible values: "AzureOpenAI", "AzureBlob", "CognitiveSearch", "CosmosDB", "ApiKey", "AppInsights", "CustomKeys" + */ + readonly type: ConnectionTypeOutput; + /** The connection URL to be used for this service */ + readonly target: string; + /** + * The authentication type used by the connection + * + * Possible values: "ApiKey", "AAD", "SAS", "CustomKeys", "None" + */ + readonly authType: AuthenticationTypeOutput; + /** Metadata of the connection */ + readonly metadata: Record; +} + +/** Paged collection of Connection items */ +export interface PagedConnectionOutput { + /** The Connection items on this page */ + value: Array; + /** The link to the next page of items */ + nextLink?: string; +} + +/** Evaluation Definition */ +export interface EvaluationOutput { + /** Identifier of the evaluation. */ + readonly id: string; + /** Data for evaluation. */ + data: InputDataOutput; + /** Display Name for evaluation. It helps to find the evaluation easily in AI Foundry. It does not need to be unique. */ + displayName?: string; + /** Description of the evaluation. It can be used to store additional information about the evaluation and is mutable. */ + description?: string; + /** Status of the evaluation. It is set by service and is read-only. */ + readonly status?: string; + /** Evaluation's tags. Unlike properties, tags are fully mutable. */ + tags?: Record; + /** Evaluation's properties. Unlike tags, properties are add-only. Once added, a property cannot be removed. */ + properties?: Record; + /** Evaluators to be used for the evaluation. */ + evaluators: Record; + /** Read-only result outputs. Example: { 'evaluationResultId': 'azureai://accounts/{AccountName}/projects/{myproject}/evaluationresults/{name}/{version}', 'logId': 'azureai://accounts/{AccountName}/projects/{myproject}/datasets/{dataset-name}/{dataset-version}' } */ + readonly outputs: Record; +} + +/** Abstract data class. */ +export interface InputDataOutputParent { + type: string; +} + +/** Dataset as source for evaluation. */ +export interface InputDatasetOutput extends InputDataOutputParent { + type: "dataset"; + /** Evaluation input data */ + id: string; +} + +/** Evaluator Configuration */ +export interface EvaluatorConfigurationOutput { + /** Identifier of the evaluator. */ + id: string; + /** Initialization parameters of the evaluator. */ + initParams?: Record; + /** Data parameters of the evaluator. */ + dataMapping?: Record; +} + +/** Paged collection of Evaluation items */ +export interface PagedEvaluationOutput { + /** The Evaluation items on this page */ + value: Array; + /** The link to the next page of items */ + nextLink?: string; +} + +/** Paged collection of DatasetVersion items */ +export interface PagedDatasetVersionOutput { + /** The DatasetVersion items on this page */ + value: Array; + /** The link to the next page of items */ + nextLink?: string; +} + +/** DatasetVersion Definition */ +export interface DatasetVersionOutputParent { + /** [Required] Uri of the data. Example: https://go.microsoft.com/fwlink/?linkid=2202330 */ + datasetUri: string; + /** Indicates if dataset is reference only or managed by dataset service. If true, the underlying data will be deleted when the dataset version is deleted */ + readonly isReference?: boolean; + /** Asset stage */ + stage?: string; + /** A unique identifier for the asset, assetId probably? */ + readonly id?: string; + /** The name of the resource */ + readonly name: string; + /** The version of the resource */ + readonly version: string; + /** The asset description text. */ + description?: string; + /** Tag dictionary. Tags can be added, removed, and updated. */ + tags?: Record; + type: DatasetTypeOutput; +} + +/** FileDatasetVersion Definition */ +export interface FileDatasetVersionOutput extends DatasetVersionOutputParent { + /** Dataset type */ + type: "uri_file"; + /** Indicates OpenAI Purpose. FileDatasets created with this field will be compatible with OpenAI-specific features */ + openAIPurpose: string; +} + +/** FileDatasetVersion Definition */ +export interface FolderDatasetVersionOutput extends DatasetVersionOutputParent { + /** Dataset type */ + type: "uri_folder"; +} + +/** Represents the response for a pending upload request */ +export interface PendingUploadResponseOutput { + /** Container-level read, write, list SAS. */ + blobReferenceForConsumption: BlobReferenceForConsumptionOutput; + /** ID for this upload request. */ + pendingUploadId: string; + /** Version of dataset to be created if user did not specify version when initially creating upload */ + datasetVersion?: string; + /** TemporaryBlobReference is the only supported type */ + pendingUploadType: "TemporaryBlobReference"; +} + +/** Represents a reference to a blob for consumption */ +export interface BlobReferenceForConsumptionOutput { + /** Blob URI path for client to upload data. Example: https://blob.windows.core.net/Container/Path */ + blobUri: string; + /** ARM ID of the storage account to use. */ + storageAccountArmId: string; + /** Credential info to access the storage account. */ + credential: SasCredentialOutput; +} + +/** SAS Credential definition */ +export interface SasCredentialOutput { + /** SAS uri */ + readonly sasUri: string; + /** Type of credential */ + readonly type: "SAS"; +} + +/** Paged collection of Index items */ +export interface PagedIndexOutput { + /** The Index items on this page */ + value: Array; + /** The link to the next page of items */ + nextLink?: string; +} + +/** Index resource Definition */ +export interface IndexOutputParent { + /** Asset stage */ + stage?: string; + /** A unique identifier for the asset, assetId probably? */ + readonly id?: string; + /** The name of the resource */ + readonly name: string; + /** The version of the resource */ + readonly version: string; + /** The asset description text. */ + description?: string; + /** Tag dictionary. Tags can be added, removed, and updated. */ + tags?: Record; + type: IndexTypeOutput; +} + +/** Azure AI Search Index Definition */ +export interface AzureAISearchIndexOutput extends IndexOutputParent { + /** Type of index */ + type: "AzureSearch"; + /** Name of connection to Azure AI Search */ + connectionName: string; + /** Name of index in Azure AI Search resource to attach */ + indexName: string; +} + +/** Managed Azure AI Search Index Definition */ +export interface ManagedAzureAISearchIndexOutput extends IndexOutputParent { + /** Type of index */ + type: "ManagedAzureSearch"; + /** Vector store id of managed index */ + vectorStoreId: string; +} + +/** CosmosDB Vector Store Index Definition */ +export interface CosmosDBIndexOutput extends IndexOutputParent { + /** Type of index */ + type: "CosmosDBNoSqlVectorStore"; + /** Name of connection to CosmosDB */ + connectionName: string; + /** Name of the CosmosDB Database */ + databaseName: string; + /** Name of CosmosDB Container */ + containerName: string; + /** Embedding model configuration */ + embeddingConfiguration: EmbeddingConfigurationOutput; +} + +/** Embedding configuration class */ +export interface EmbeddingConfigurationOutput { + /** Deployment name of embedding model. It can point to a model deployment either in the parent AIServices or a connection. */ + modelDeploymentName: string; + /** Embedding field */ + embeddingField: string; +} + +/** Model Deployment Definition */ +export interface DeploymentOutputParent { + /** Name of the deployment */ + readonly name: string; + type: DeploymentTypeOutput; +} + +/** Paged collection of Deployment items */ +export interface PagedDeploymentOutput { + /** The Deployment items on this page */ + value: Array; + /** The link to the next page of items */ + nextLink?: string; +} + +/** Model Deployment Definition */ +export interface ModelDeploymentOutput extends DeploymentOutputParent { + /** The type of the deployment */ + type: "ModelDeployment"; + /** Publisher-specific name of the deployed model */ + readonly modelName: string; + /** Publisher-specific version of the deployed model */ + readonly modelVersion: string; + /** Name of the deployed model's publisher */ + readonly modelPublisher: string; + /** Capabilities of deployed model */ + readonly capabilities: Record; + /** Sku of the model deployment */ + readonly sku: SkuOutput; + /** Name of the connection the deployment comes from */ + readonly connectionName?: string; +} + +/** Sku information */ +export interface SkuOutput { + /** Sku capacity */ + capacity: number; + /** Sku family */ + family: string; + /** Sku name */ + name: string; + /** Sku size */ + size: string; + /** Sku tier */ + tier: string; +} + +/** Paged collection of EvaluationResult items */ +export interface PagedEvaluationResultOutput { + /** The EvaluationResult items on this page */ + value: Array; + /** The link to the next page of items */ + nextLink?: string; +} + +/** Evaluation Result resource Definition */ +export interface EvaluationResultOutput { + /** + * Type of Evaluation result + * + * Possible values: "Benchmark", "Evaluation", "Redteam", "Simulation" + */ + ResultType?: ResultTypeOutput; + /** Model Name */ + ModelName?: string; + /** Model Version */ + ModelVersion?: string; + /** Model Asset ID */ + ModelAssetId?: string; + /** Dataset Family */ + DatasetFamily?: string; + /** Dataset Name */ + DatasetName?: string; + /** Metrics */ + Metrics?: Record; + /** Blob URI */ + BlobUri?: string; + /** Asset stage */ + stage?: string; + /** A unique identifier for the asset, assetId probably? */ + readonly id?: string; + /** The name of the resource */ + readonly name: string; + /** The version of the resource */ + readonly version: string; + /** The asset description text. */ + description?: string; + /** Tag dictionary. Tags can be added, removed, and updated. */ + tags?: Record; +} + +/** Red team details. */ +export interface RedTeamOutput { + /** Identifier of the red team. */ + readonly id: string; + /** Name of the red-team scan. */ + scanName: string; + /** Number of simulation rounds. */ + numTurns: number; + /** List of attack strategies or nested lists of attack strategies. */ + attackStrategy: AttackStrategyOutput[]; + /** Simulation-only or Simulation + Evaluation. Default false, if true the scan outputs conversation not evaluation result. */ + simulationOnly: boolean; + /** Read-only result outputs. Example: { 'redTeamResultId': 'azureai://accounts/{AccountName}/projects/{myproject}/evaluationresults/{name}/{version}', 'logId': 'azureai://accounts/{AccountName}/projects/{myproject}/datasets/{dataset-name}/{dataset-version}' } */ + readonly outputs: Record; + /** List of risk categories to generate attack objectives for. */ + riskCategories: RiskCategoryOutput[]; + /** Application scenario for the red team operation, to generate scenario specific attacks. */ + applicationScenario?: string; + /** Red team's tags. Unlike properties, tags are fully mutable. */ + tags?: Record; + /** Red team's properties. Unlike tags, properties are add-only. Once added, a property cannot be removed. */ + properties?: Record; + /** Status of the red-team. It is set by service and is read-only. */ + readonly status?: string; +} + +/** Paged collection of RedTeam items */ +export interface PagedRedTeamOutput { + /** The RedTeam items on this page */ + value: Array; + /** The link to the next page of items */ + nextLink?: string; +} + +/** Abstract data class. */ +export type InputDataOutput = InputDataOutputParent | InputDatasetOutput; +/** DatasetVersion Definition */ +export type DatasetVersionOutput = + | DatasetVersionOutputParent + | FileDatasetVersionOutput + | FolderDatasetVersionOutput; +/** Index resource Definition */ +export type IndexOutput = + | IndexOutputParent + | AzureAISearchIndexOutput + | ManagedAzureAISearchIndexOutput + | CosmosDBIndexOutput; +/** Model Deployment Definition */ +export type DeploymentOutput = DeploymentOutputParent | ModelDeploymentOutput; +/** Alias for ConnectionTypeOutput */ +export type ConnectionTypeOutput = string; +/** Alias for AuthenticationTypeOutput */ +export type AuthenticationTypeOutput = string; +/** Alias for DatasetTypeOutput */ +export type DatasetTypeOutput = string; +/** Alias for RepeatabilityResultOutput */ +export type RepeatabilityResultOutput = "accepted" | "rejected"; +/** Alias for IndexTypeOutput */ +export type IndexTypeOutput = string; +/** Alias for DeploymentTypeOutput */ +export type DeploymentTypeOutput = string; +/** Alias for ResultTypeOutput */ +export type ResultTypeOutput = string; +/** Alias for AttackStrategyOutput */ +export type AttackStrategyOutput = string; +/** Alias for RiskCategoryOutput */ +export type RiskCategoryOutput = string; diff --git a/sdk/ai/ai-projects-1dp/src/paginateHelper.ts b/sdk/ai/ai-projects-1dp/src/paginateHelper.ts new file mode 100644 index 000000000000..70694e2c93c6 --- /dev/null +++ b/sdk/ai/ai-projects-1dp/src/paginateHelper.ts @@ -0,0 +1,294 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { Client, PathUncheckedResponse } from "@azure-rest/core-client"; +import { createRestError } from "@azure-rest/core-client"; + +/** + * returns an async iterator that iterates over results. It also has a `byPage` + * method that returns pages of items at once. + * + * @param pagedResult - an object that specifies how to get pages. + * @returns a paged async iterator that iterates over results. + */ +function getPagedAsyncIterator< + TElement, + TPage = TElement[], + TPageSettings = PageSettings, + TLink = string, +>( + pagedResult: PagedResult, +): PagedAsyncIterableIterator { + const iter = getItemAsyncIterator( + pagedResult, + ); + return { + next() { + return iter.next(); + }, + [Symbol.asyncIterator]() { + return this; + }, + byPage: + pagedResult?.byPage ?? + (((settings?: PageSettings) => { + const { continuationToken } = settings ?? {}; + return getPageAsyncIterator(pagedResult, { + pageLink: continuationToken as unknown as TLink | undefined, + }); + }) as unknown as ( + settings?: TPageSettings, + ) => AsyncIterableIterator), + }; +} + +async function* getItemAsyncIterator( + pagedResult: PagedResult, +): AsyncIterableIterator { + const pages = getPageAsyncIterator(pagedResult); + const firstVal = await pages.next(); + // if the result does not have an array shape, i.e. TPage = TElement, then we return it as is + if (!Array.isArray(firstVal.value)) { + // can extract elements from this page + const { toElements } = pagedResult; + if (toElements) { + yield* toElements(firstVal.value) as TElement[]; + for await (const page of pages) { + yield* toElements(page) as TElement[]; + } + } else { + yield firstVal.value; + // `pages` is of type `AsyncIterableIterator` but TPage = TElement in this case + yield* pages as unknown as AsyncIterableIterator; + } + } else { + yield* firstVal.value; + for await (const page of pages) { + // pages is of type `AsyncIterableIterator` so `page` is of type `TPage`. In this branch, + // it must be the case that `TPage = TElement[]` + yield* page as unknown as TElement[]; + } + } +} + +async function* getPageAsyncIterator( + pagedResult: PagedResult, + options: { + pageLink?: TLink; + } = {}, +): AsyncIterableIterator { + const { pageLink } = options; + let response = await pagedResult.getPage( + pageLink ?? pagedResult.firstPageLink, + ); + if (!response) { + return; + } + yield response.page; + while (response.nextPageLink) { + response = await pagedResult.getPage(response.nextPageLink); + if (!response) { + return; + } + yield response.page; + } +} + +/** + * An interface that tracks the settings for paged iteration + */ +export interface PageSettings { + /** + * The token that keeps track of where to continue the iterator + */ + continuationToken?: string; +} + +/** + * An interface that allows async iterable iteration both to completion and by page. + */ +export interface PagedAsyncIterableIterator< + TElement, + TPage = TElement[], + TPageSettings = PageSettings, +> { + /** + * The next method, part of the iteration protocol + */ + next(): Promise>; + /** + * The connection to the async iterator, part of the iteration protocol + */ + [Symbol.asyncIterator](): PagedAsyncIterableIterator< + TElement, + TPage, + TPageSettings + >; + /** + * Return an AsyncIterableIterator that works a page at a time + */ + byPage: (settings?: TPageSettings) => AsyncIterableIterator; +} + +/** + * An interface that describes how to communicate with the service. + */ +interface PagedResult { + /** + * Link to the first page of results. + */ + firstPageLink: TLink; + /** + * A method that returns a page of results. + */ + getPage: ( + pageLink: TLink, + ) => Promise<{ page: TPage; nextPageLink?: TLink } | undefined>; + /** + * a function to implement the `byPage` method on the paged async iterator. + */ + byPage?: (settings?: TPageSettings) => AsyncIterableIterator; + + /** + * A function to extract elements from a page. + */ + toElements?: (page: TPage) => unknown[]; +} + +/** + * Helper type to extract the type of an array + */ +export type GetArrayType = T extends Array ? TData : never; + +/** + * The type of a custom function that defines how to get a page and a link to the next one if any. + */ +export type GetPage = (pageLink: string) => Promise<{ + page: TPage; + nextPageLink?: string; +}>; + +/** + * Options for the paging helper + */ +export interface PagingOptions { + /** + * Custom function to extract pagination details for crating the PagedAsyncIterableIterator + */ + customGetPage?: GetPage[]>; +} + +/** + * Helper type to infer the Type of the paged elements from the response type + * This type is generated based on the swagger information for x-ms-pageable + * specifically on the itemName property which indicates the property of the response + * where the page items are found. The default value is `value`. + * This type will allow us to provide strongly typed Iterator based on the response we get as second parameter + */ +export type PaginateReturn = TResult extends { + body: { value?: infer TPage }; +} + ? GetArrayType + : Array; + +/** + * Helper to paginate results from an initial response that follows the specification of Autorest `x-ms-pageable` extension + * @param client - Client to use for sending the next page requests + * @param initialResponse - Initial response containing the nextLink and current page of elements + * @param customGetPage - Optional - Function to define how to extract the page and next link to be used to paginate the results + * @returns - PagedAsyncIterableIterator to iterate the elements + */ +export function paginate( + client: Client, + initialResponse: TResponse, + options: PagingOptions = {}, +): PagedAsyncIterableIterator> { + // Extract element type from initial response + type TElement = PaginateReturn; + let firstRun = true; + const itemName = "value"; + const nextLinkName = "nextLink"; + const { customGetPage } = options; + const pagedResult: PagedResult = { + firstPageLink: "", + getPage: + typeof customGetPage === "function" + ? customGetPage + : async (pageLink: string) => { + const result = firstRun + ? initialResponse + : await client.pathUnchecked(pageLink).get(); + firstRun = false; + checkPagingRequest(result); + const nextLink = getNextLink(result.body, nextLinkName); + const values = getElements(result.body, itemName); + return { + page: values, + nextPageLink: nextLink, + }; + }, + }; + + return getPagedAsyncIterator(pagedResult); +} + +/** + * Gets for the value of nextLink in the body + */ +function getNextLink(body: unknown, nextLinkName?: string): string | undefined { + if (!nextLinkName) { + return undefined; + } + + const nextLink = (body as Record)[nextLinkName]; + + if (typeof nextLink !== "string" && typeof nextLink !== "undefined") { + throw new Error( + `Body Property ${nextLinkName} should be a string or undefined`, + ); + } + + return nextLink; +} + +/** + * Gets the elements of the current request in the body. + */ +function getElements(body: unknown, itemName: string): T[] { + const value = (body as Record)[itemName] as T[]; + + // value has to be an array according to the x-ms-pageable extension. + // The fact that this must be an array is used above to calculate the + // type of elements in the page in PaginateReturn + if (!Array.isArray(value)) { + throw new Error( + `Couldn't paginate response\n Body doesn't contain an array property with name: ${itemName}`, + ); + } + + return value ?? []; +} + +/** + * Checks if a request failed + */ +function checkPagingRequest(response: PathUncheckedResponse): void { + const Http2xxStatusCodes = [ + "200", + "201", + "202", + "203", + "204", + "205", + "206", + "207", + "208", + "226", + ]; + if (!Http2xxStatusCodes.includes(response.status)) { + throw createRestError( + `Pagination failed with unexpected statusCode ${response.status}`, + response, + ); + } +} diff --git a/sdk/ai/ai-projects-1dp/src/parameters.ts b/sdk/ai/ai-projects-1dp/src/parameters.ts new file mode 100644 index 000000000000..43bd91319a9f --- /dev/null +++ b/sdk/ai/ai-projects-1dp/src/parameters.ts @@ -0,0 +1,445 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { RawHttpHeadersInput } from "@azure/core-rest-pipeline"; +import type { RequestParameters } from "@azure-rest/core-client"; +import type { + ConnectionType, + Evaluation, + ListViewType, + DatasetVersion, + PendingUploadRequest, + Index, + EvaluationResult, + RedTeam, +} from "./models.js"; + +export interface ConnectionsGetHeaders { + /** An opaque, globally-unique, client-generated string identifier for the request. */ + "x-ms-client-request-id"?: string; +} + +export interface ConnectionsGetHeaderParam { + headers?: RawHttpHeadersInput & ConnectionsGetHeaders; +} + +export type ConnectionsGetParameters = ConnectionsGetHeaderParam & + RequestParameters; + +export interface ConnectionsListHeaders { + /** An opaque, globally-unique, client-generated string identifier for the request. */ + "x-ms-client-request-id"?: string; +} + +export interface ConnectionsListQueryParamProperties { + /** + * Specific type of connection to return in list + * + * Possible values: "AzureOpenAI", "AzureBlob", "CognitiveSearch", "CosmosDB", "ApiKey", "AppInsights", "CustomKeys" + */ + connectionType?: ConnectionType; + /** The number of result items to return. */ + top?: number; + /** The number of result items to skip. */ + skip?: number; + /** The maximum number of result items per page. */ + maxpagesize?: number; +} + +export interface ConnectionsListQueryParam { + queryParameters?: ConnectionsListQueryParamProperties; +} + +export interface ConnectionsListHeaderParam { + headers?: RawHttpHeadersInput & ConnectionsListHeaders; +} + +export type ConnectionsListParameters = ConnectionsListQueryParam & + ConnectionsListHeaderParam & + RequestParameters; + +export interface EvaluationsGetHeaders { + /** An opaque, globally-unique, client-generated string identifier for the request. */ + "x-ms-client-request-id"?: string; +} + +export interface EvaluationsGetHeaderParam { + headers?: RawHttpHeadersInput & EvaluationsGetHeaders; +} + +export type EvaluationsGetParameters = EvaluationsGetHeaderParam & + RequestParameters; + +export interface EvaluationsListHeaders { + /** An opaque, globally-unique, client-generated string identifier for the request. */ + "x-ms-client-request-id"?: string; +} + +export interface EvaluationsListQueryParamProperties { + /** The number of result items to return. */ + top?: number; + /** The number of result items to skip. */ + skip?: number; + /** The maximum number of result items per page. */ + maxpagesize?: number; +} + +export interface EvaluationsListQueryParam { + queryParameters?: EvaluationsListQueryParamProperties; +} + +export interface EvaluationsListHeaderParam { + headers?: RawHttpHeadersInput & EvaluationsListHeaders; +} + +export type EvaluationsListParameters = EvaluationsListQueryParam & + EvaluationsListHeaderParam & + RequestParameters; + +export interface EvaluationsCreateRunBodyParam { + /** Evaluation to be run */ + body: Evaluation; +} + +export type EvaluationsCreateRunParameters = EvaluationsCreateRunBodyParam & + RequestParameters; + +export interface DatasetsListVersionsQueryParamProperties { + /** Top count of results, top count cannot be greater than the page size. If topCount > page size, results with be default page size count will be returned */ + top?: number; + /** Continuation token for pagination. */ + skip?: string; + /** Comma-separated list of tag names (and optionally values). Example: tag1,tag2=value2 */ + tags?: string; + /** + * [ListViewType.ActiveOnly, ListViewType.ArchivedOnly, ListViewType.All] View type for including/excluding (for example) archived entities. + * + * Possible values: "ActiveOnly", "ArchivedOnly", "All" + */ + listViewType?: ListViewType; +} + +export interface DatasetsListVersionsQueryParam { + queryParameters?: DatasetsListVersionsQueryParamProperties; +} + +export type DatasetsListVersionsParameters = DatasetsListVersionsQueryParam & + RequestParameters; + +export interface DatasetsListLatestQueryParamProperties { + /** Top count of results, top count cannot be greater than the page size. If topCount > page size, results with be default page size count will be returned */ + top?: number; + /** Continuation token for pagination. */ + skip?: string; + /** Comma-separated list of tag names (and optionally values). Example: tag1,tag2=value2 */ + tags?: string; + /** + * [ListViewType.ActiveOnly, ListViewType.ArchivedOnly, ListViewType.All] View type for including/excluding (for example) archived entities. + * + * Possible values: "ActiveOnly", "ArchivedOnly", "All" + */ + listViewType?: ListViewType; +} + +export interface DatasetsListLatestQueryParam { + queryParameters?: DatasetsListLatestQueryParamProperties; +} + +export type DatasetsListLatestParameters = DatasetsListLatestQueryParam & + RequestParameters; +export type DatasetsGetVersionParameters = RequestParameters; +export type DatasetsDeleteVersionParameters = RequestParameters; + +export interface DatasetsCreateHeaders { + /** An opaque, globally-unique, client-generated string identifier for the request. */ + "Repeatability-Request-ID"?: string; + /** Specifies the date and time at which the request was first created. */ + "Repeatability-First-Sent"?: string; + /** An opaque, globally-unique, client-generated string identifier for the request. */ + "x-ms-client-request-id"?: string; +} + +export interface DatasetsCreateBodyParam { + /** The definition of the DatasetVersion to create */ + body: DatasetVersion; +} + +export interface DatasetsCreateHeaderParam { + headers?: RawHttpHeadersInput & DatasetsCreateHeaders; +} + +export type DatasetsCreateParameters = DatasetsCreateHeaderParam & + DatasetsCreateBodyParam & + RequestParameters; + +export interface DatasetsCreateVersionBodyParam { + /** The definition of the DatasetVersion to create */ + body: DatasetVersion; +} + +export type DatasetsCreateVersionParameters = DatasetsCreateVersionBodyParam & + RequestParameters; + +export interface DatasetsStartPendingUploadVersionBodyParam { + /** Parameters for the action */ + body: PendingUploadRequest; +} + +export type DatasetsStartPendingUploadVersionParameters = + DatasetsStartPendingUploadVersionBodyParam & RequestParameters; + +export interface DatasetsStartPendingUploadBodyParam { + /** Parameters for the action */ + body: PendingUploadRequest; +} + +export type DatasetsStartPendingUploadParameters = + DatasetsStartPendingUploadBodyParam & RequestParameters; + +export interface IndexesListVersionsQueryParamProperties { + /** Top count of results, top count cannot be greater than the page size. If topCount > page size, results with be default page size count will be returned */ + top?: number; + /** Continuation token for pagination. */ + skip?: string; + /** Comma-separated list of tag names (and optionally values). Example: tag1,tag2=value2 */ + tags?: string; + /** + * [ListViewType.ActiveOnly, ListViewType.ArchivedOnly, ListViewType.All] View type for including/excluding (for example) archived entities. + * + * Possible values: "ActiveOnly", "ArchivedOnly", "All" + */ + listViewType?: ListViewType; +} + +export interface IndexesListVersionsQueryParam { + queryParameters?: IndexesListVersionsQueryParamProperties; +} + +export type IndexesListVersionsParameters = IndexesListVersionsQueryParam & + RequestParameters; + +export interface IndexesListLatestQueryParamProperties { + /** Top count of results, top count cannot be greater than the page size. If topCount > page size, results with be default page size count will be returned */ + top?: number; + /** Continuation token for pagination. */ + skip?: string; + /** Comma-separated list of tag names (and optionally values). Example: tag1,tag2=value2 */ + tags?: string; + /** + * [ListViewType.ActiveOnly, ListViewType.ArchivedOnly, ListViewType.All] View type for including/excluding (for example) archived entities. + * + * Possible values: "ActiveOnly", "ArchivedOnly", "All" + */ + listViewType?: ListViewType; +} + +export interface IndexesListLatestQueryParam { + queryParameters?: IndexesListLatestQueryParamProperties; +} + +export type IndexesListLatestParameters = IndexesListLatestQueryParam & + RequestParameters; +export type IndexesGetVersionParameters = RequestParameters; +export type IndexesDeleteVersionParameters = RequestParameters; + +export interface IndexesCreateHeaders { + /** An opaque, globally-unique, client-generated string identifier for the request. */ + "Repeatability-Request-ID"?: string; + /** Specifies the date and time at which the request was first created. */ + "Repeatability-First-Sent"?: string; + /** An opaque, globally-unique, client-generated string identifier for the request. */ + "x-ms-client-request-id"?: string; +} + +export interface IndexesCreateBodyParam { + /** The definition of the Index to create */ + body: Index; +} + +export interface IndexesCreateHeaderParam { + headers?: RawHttpHeadersInput & IndexesCreateHeaders; +} + +export type IndexesCreateParameters = IndexesCreateHeaderParam & + IndexesCreateBodyParam & + RequestParameters; + +export interface IndexesCreateVersionBodyParam { + /** The definition of the Index to create */ + body: Index; +} + +export type IndexesCreateVersionParameters = IndexesCreateVersionBodyParam & + RequestParameters; + +export interface DeploymentsGetHeaders { + /** An opaque, globally-unique, client-generated string identifier for the request. */ + "x-ms-client-request-id"?: string; +} + +export interface DeploymentsGetHeaderParam { + headers?: RawHttpHeadersInput & DeploymentsGetHeaders; +} + +export type DeploymentsGetParameters = DeploymentsGetHeaderParam & + RequestParameters; + +export interface DeploymentsListHeaders { + /** An opaque, globally-unique, client-generated string identifier for the request. */ + "x-ms-client-request-id"?: string; +} + +export interface DeploymentsListQueryParamProperties { + /** Model publisher to filter models by */ + modelPublisher?: string; + /** Model name (the publisher specific name) to filter models by */ + modelName?: string; + /** The number of result items to return. */ + top?: number; + /** The number of result items to skip. */ + skip?: number; + /** The maximum number of result items per page. */ + maxpagesize?: number; +} + +export interface DeploymentsListQueryParam { + queryParameters?: DeploymentsListQueryParamProperties; +} + +export interface DeploymentsListHeaderParam { + headers?: RawHttpHeadersInput & DeploymentsListHeaders; +} + +export type DeploymentsListParameters = DeploymentsListQueryParam & + DeploymentsListHeaderParam & + RequestParameters; + +export interface EvaluationResultsListVersionsQueryParamProperties { + /** Top count of results, top count cannot be greater than the page size. If topCount > page size, results with be default page size count will be returned */ + top?: number; + /** Continuation token for pagination. */ + skip?: string; + /** Comma-separated list of tag names (and optionally values). Example: tag1,tag2=value2 */ + tags?: string; + /** + * [ListViewType.ActiveOnly, ListViewType.ArchivedOnly, ListViewType.All] View type for including/excluding (for example) archived entities. + * + * Possible values: "ActiveOnly", "ArchivedOnly", "All" + */ + listViewType?: ListViewType; +} + +export interface EvaluationResultsListVersionsQueryParam { + queryParameters?: EvaluationResultsListVersionsQueryParamProperties; +} + +export type EvaluationResultsListVersionsParameters = + EvaluationResultsListVersionsQueryParam & RequestParameters; + +export interface EvaluationResultsListLatestQueryParamProperties { + /** Top count of results, top count cannot be greater than the page size. If topCount > page size, results with be default page size count will be returned */ + top?: number; + /** Continuation token for pagination. */ + skip?: string; + /** Comma-separated list of tag names (and optionally values). Example: tag1,tag2=value2 */ + tags?: string; + /** + * [ListViewType.ActiveOnly, ListViewType.ArchivedOnly, ListViewType.All] View type for including/excluding (for example) archived entities. + * + * Possible values: "ActiveOnly", "ArchivedOnly", "All" + */ + listViewType?: ListViewType; +} + +export interface EvaluationResultsListLatestQueryParam { + queryParameters?: EvaluationResultsListLatestQueryParamProperties; +} + +export type EvaluationResultsListLatestParameters = + EvaluationResultsListLatestQueryParam & RequestParameters; +export type EvaluationResultsGetVersionParameters = RequestParameters; +export type EvaluationResultsDeleteVersionParameters = RequestParameters; + +export interface EvaluationResultsCreateHeaders { + /** An opaque, globally-unique, client-generated string identifier for the request. */ + "Repeatability-Request-ID"?: string; + /** Specifies the date and time at which the request was first created. */ + "Repeatability-First-Sent"?: string; + /** An opaque, globally-unique, client-generated string identifier for the request. */ + "x-ms-client-request-id"?: string; +} + +export interface EvaluationResultsCreateBodyParam { + /** The definition of the EvaluationResult to create */ + body: EvaluationResult; +} + +export interface EvaluationResultsCreateHeaderParam { + headers?: RawHttpHeadersInput & EvaluationResultsCreateHeaders; +} + +export type EvaluationResultsCreateParameters = + EvaluationResultsCreateHeaderParam & + EvaluationResultsCreateBodyParam & + RequestParameters; + +export interface EvaluationResultsCreateVersionBodyParam { + /** The definition of the EvaluationResult to create */ + body: EvaluationResult; +} + +export type EvaluationResultsCreateVersionParameters = + EvaluationResultsCreateVersionBodyParam & RequestParameters; + +export interface EvaluationResultsStartPendingUploadBodyParam { + /** Parameters for the action */ + body: PendingUploadRequest; +} + +export type EvaluationResultsStartPendingUploadParameters = + EvaluationResultsStartPendingUploadBodyParam & RequestParameters; + +export interface RedTeamsGetHeaders { + /** An opaque, globally-unique, client-generated string identifier for the request. */ + "x-ms-client-request-id"?: string; +} + +export interface RedTeamsGetHeaderParam { + headers?: RawHttpHeadersInput & RedTeamsGetHeaders; +} + +export type RedTeamsGetParameters = RedTeamsGetHeaderParam & RequestParameters; + +export interface RedTeamsListHeaders { + /** An opaque, globally-unique, client-generated string identifier for the request. */ + "x-ms-client-request-id"?: string; +} + +export interface RedTeamsListQueryParamProperties { + /** The number of result items to return. */ + top?: number; + /** The number of result items to skip. */ + skip?: number; + /** The maximum number of result items per page. */ + maxpagesize?: number; +} + +export interface RedTeamsListQueryParam { + queryParameters?: RedTeamsListQueryParamProperties; +} + +export interface RedTeamsListHeaderParam { + headers?: RawHttpHeadersInput & RedTeamsListHeaders; +} + +export type RedTeamsListParameters = RedTeamsListQueryParam & + RedTeamsListHeaderParam & + RequestParameters; + +export interface RedTeamsCreateRunBodyParam { + /** Redteam to be run */ + body: RedTeam; +} + +export type RedTeamsCreateRunParameters = RedTeamsCreateRunBodyParam & + RequestParameters; diff --git a/sdk/ai/ai-projects-1dp/src/projectsClient.ts b/sdk/ai/ai-projects-1dp/src/projectsClient.ts new file mode 100644 index 000000000000..dc63615dfbfe --- /dev/null +++ b/sdk/ai/ai-projects-1dp/src/projectsClient.ts @@ -0,0 +1,80 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { ClientOptions } from "@azure-rest/core-client"; +import { getClient } from "@azure-rest/core-client"; +import { logger } from "./logger.js"; +import type { + TokenCredential, + KeyCredential, + isKeyCredential, +} from "@azure/core-auth"; +import type { ProjectsClient } from "./clientDefinitions.js"; + +/** The optional parameters for the client */ +export interface ProjectsClientOptions extends ClientOptions { + /** The api version option of the client */ + apiVersion?: string; +} + +/** + * Initialize a new instance of `ProjectsClient` + * @param endpointParam - Project endpoint in the form of: https://.services.ai.azure.com/api/projects/ + * @param credentials - uniquely identify client credential + * @param options - the parameter for all optional parameters + */ +export default function createClient( + endpointParam: string, + credentials: TokenCredential | KeyCredential, + { apiVersion = "2025-05-15-preview", ...options }: ProjectsClientOptions = {}, +): ProjectsClient { + const endpointUrl = options.endpoint ?? options.baseUrl ?? `${endpointParam}`; + const userAgentInfo = `azsdk-js-ai-projects-1dp-rest/1.0.0-beta.1`; + const userAgentPrefix = + options.userAgentOptions && options.userAgentOptions.userAgentPrefix + ? `${options.userAgentOptions.userAgentPrefix} ${userAgentInfo}` + : `${userAgentInfo}`; + options = { + ...options, + userAgentOptions: { + userAgentPrefix, + }, + loggingOptions: { + logger: options.loggingOptions?.logger ?? logger.info, + }, + credentials: { + scopes: options.credentials?.scopes ?? [ + "https://cognitiveservices.azure.com/.default", + ], + }, + }; + const client = getClient(endpointUrl, credentials, options) as ProjectsClient; + + client.pipeline.removePolicy({ name: "ApiVersionPolicy" }); + client.pipeline.addPolicy({ + name: "ClientApiVersionPolicy", + sendRequest: (req, next) => { + // Use the apiVersion defined in request url directly + // Append one if there is no apiVersion and we have one at client options + const url = new URL(req.url); + if (!url.searchParams.get("api-version") && apiVersion) { + req.url = `${req.url}${ + Array.from(url.searchParams.keys()).length > 0 ? "&" : "?" + }api-version=${apiVersion}`; + } + + return next(req); + }, + }); + if (isKeyCredential(credentials)) { + client.pipeline.addPolicy({ + name: "customKeyCredentialPolicy", + async sendRequest(request, next) { + request.headers.set("Authorization", "Bearer " + credentials.key); + return next(request); + }, + }); + } + + return client; +} diff --git a/sdk/ai/ai-projects-1dp/src/responses.ts b/sdk/ai/ai-projects-1dp/src/responses.ts new file mode 100644 index 000000000000..65d4e1597d0f --- /dev/null +++ b/sdk/ai/ai-projects-1dp/src/responses.ts @@ -0,0 +1,650 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { RawHttpHeaders } from "@azure/core-rest-pipeline"; +import type { HttpResponse, ErrorResponse } from "@azure-rest/core-client"; +import type { + ConnectionOutput, + PagedConnectionOutput, + EvaluationOutput, + PagedEvaluationOutput, + PagedDatasetVersionOutput, + DatasetVersionOutput, + RepeatabilityResultOutput, + PendingUploadResponseOutput, + PagedIndexOutput, + IndexOutput, + DeploymentOutput, + PagedDeploymentOutput, + PagedEvaluationResultOutput, + EvaluationResultOutput, + RedTeamOutput, + PagedRedTeamOutput, +} from "./outputModels.js"; + +export interface ConnectionsGet200Headers { + /** An opaque, globally-unique, client-generated string identifier for the request. */ + "x-ms-client-request-id"?: string; +} + +/** The request has succeeded. */ +export interface ConnectionsGet200Response extends HttpResponse { + status: "200"; + body: ConnectionOutput; + headers: RawHttpHeaders & ConnectionsGet200Headers; +} + +export interface ConnectionsGetDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface ConnectionsGetDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & ConnectionsGetDefaultHeaders; +} + +export interface ConnectionsList200Headers { + /** An opaque, globally-unique, client-generated string identifier for the request. */ + "x-ms-client-request-id"?: string; +} + +/** The request has succeeded. */ +export interface ConnectionsList200Response extends HttpResponse { + status: "200"; + body: PagedConnectionOutput; + headers: RawHttpHeaders & ConnectionsList200Headers; +} + +export interface ConnectionsListDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface ConnectionsListDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & ConnectionsListDefaultHeaders; +} + +export interface EvaluationsGet200Headers { + /** An opaque, globally-unique, client-generated string identifier for the request. */ + "x-ms-client-request-id"?: string; +} + +/** The request has succeeded. */ +export interface EvaluationsGet200Response extends HttpResponse { + status: "200"; + body: EvaluationOutput; + headers: RawHttpHeaders & EvaluationsGet200Headers; +} + +export interface EvaluationsGetDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface EvaluationsGetDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & EvaluationsGetDefaultHeaders; +} + +export interface EvaluationsList200Headers { + /** An opaque, globally-unique, client-generated string identifier for the request. */ + "x-ms-client-request-id"?: string; +} + +/** The request has succeeded. */ +export interface EvaluationsList200Response extends HttpResponse { + status: "200"; + body: PagedEvaluationOutput; + headers: RawHttpHeaders & EvaluationsList200Headers; +} + +export interface EvaluationsListDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface EvaluationsListDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & EvaluationsListDefaultHeaders; +} + +/** The request has succeeded. */ +export interface EvaluationsCreateRun200Response extends HttpResponse { + status: "200"; + body: EvaluationOutput; +} + +export interface EvaluationsCreateRunDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface EvaluationsCreateRunDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & EvaluationsCreateRunDefaultHeaders; +} + +/** The request has succeeded. */ +export interface DatasetsListVersions200Response extends HttpResponse { + status: "200"; + body: PagedDatasetVersionOutput; +} + +export interface DatasetsListVersionsDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface DatasetsListVersionsDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & DatasetsListVersionsDefaultHeaders; +} + +/** The request has succeeded. */ +export interface DatasetsListLatest200Response extends HttpResponse { + status: "200"; + body: PagedDatasetVersionOutput; +} + +export interface DatasetsListLatestDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface DatasetsListLatestDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & DatasetsListLatestDefaultHeaders; +} + +/** The request has succeeded. */ +export interface DatasetsGetVersion200Response extends HttpResponse { + status: "200"; + body: DatasetVersionOutput; +} + +export interface DatasetsGetVersionDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface DatasetsGetVersionDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & DatasetsGetVersionDefaultHeaders; +} + +/** There is no content to send for this request, but the headers may be useful. */ +export interface DatasetsDeleteVersion204Response extends HttpResponse { + status: "204"; +} + +export interface DatasetsDeleteVersionDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface DatasetsDeleteVersionDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & DatasetsDeleteVersionDefaultHeaders; +} + +export interface DatasetsCreate200Headers { + /** Indicates whether the repeatable request was accepted or rejected. */ + "repeatability-result"?: RepeatabilityResultOutput; + /** An opaque, globally-unique, client-generated string identifier for the request. */ + "x-ms-client-request-id"?: string; +} + +/** The request has succeeded. */ +export interface DatasetsCreate200Response extends HttpResponse { + status: "200"; + body: DatasetVersionOutput; + headers: RawHttpHeaders & DatasetsCreate200Headers; +} + +export interface DatasetsCreateDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface DatasetsCreateDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & DatasetsCreateDefaultHeaders; +} + +/** The request has succeeded. */ +export interface DatasetsCreateVersion200Response extends HttpResponse { + status: "200"; + body: DatasetVersionOutput; +} + +/** The request has succeeded and a new resource has been created as a result. */ +export interface DatasetsCreateVersion201Response extends HttpResponse { + status: "201"; + body: DatasetVersionOutput; +} + +export interface DatasetsCreateVersionDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface DatasetsCreateVersionDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & DatasetsCreateVersionDefaultHeaders; +} + +/** The request has succeeded. */ +export interface DatasetsStartPendingUploadVersion200Response + extends HttpResponse { + status: "200"; + body: PendingUploadResponseOutput; +} + +export interface DatasetsStartPendingUploadVersionDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface DatasetsStartPendingUploadVersionDefaultResponse + extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & DatasetsStartPendingUploadVersionDefaultHeaders; +} + +/** The request has succeeded. */ +export interface DatasetsStartPendingUpload200Response extends HttpResponse { + status: "200"; + body: PendingUploadResponseOutput; +} + +export interface DatasetsStartPendingUploadDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface DatasetsStartPendingUploadDefaultResponse + extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & DatasetsStartPendingUploadDefaultHeaders; +} + +/** The request has succeeded. */ +export interface IndexesListVersions200Response extends HttpResponse { + status: "200"; + body: PagedIndexOutput; +} + +export interface IndexesListVersionsDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface IndexesListVersionsDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & IndexesListVersionsDefaultHeaders; +} + +/** The request has succeeded. */ +export interface IndexesListLatest200Response extends HttpResponse { + status: "200"; + body: PagedIndexOutput; +} + +export interface IndexesListLatestDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface IndexesListLatestDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & IndexesListLatestDefaultHeaders; +} + +/** The request has succeeded. */ +export interface IndexesGetVersion200Response extends HttpResponse { + status: "200"; + body: IndexOutput; +} + +export interface IndexesGetVersionDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface IndexesGetVersionDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & IndexesGetVersionDefaultHeaders; +} + +/** There is no content to send for this request, but the headers may be useful. */ +export interface IndexesDeleteVersion204Response extends HttpResponse { + status: "204"; +} + +export interface IndexesDeleteVersionDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface IndexesDeleteVersionDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & IndexesDeleteVersionDefaultHeaders; +} + +export interface IndexesCreate200Headers { + /** Indicates whether the repeatable request was accepted or rejected. */ + "repeatability-result"?: RepeatabilityResultOutput; + /** An opaque, globally-unique, client-generated string identifier for the request. */ + "x-ms-client-request-id"?: string; +} + +/** The request has succeeded. */ +export interface IndexesCreate200Response extends HttpResponse { + status: "200"; + body: IndexOutput; + headers: RawHttpHeaders & IndexesCreate200Headers; +} + +export interface IndexesCreateDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface IndexesCreateDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & IndexesCreateDefaultHeaders; +} + +/** The request has succeeded. */ +export interface IndexesCreateVersion200Response extends HttpResponse { + status: "200"; + body: IndexOutput; +} + +/** The request has succeeded and a new resource has been created as a result. */ +export interface IndexesCreateVersion201Response extends HttpResponse { + status: "201"; + body: IndexOutput; +} + +export interface IndexesCreateVersionDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface IndexesCreateVersionDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & IndexesCreateVersionDefaultHeaders; +} + +export interface DeploymentsGet200Headers { + /** An opaque, globally-unique, client-generated string identifier for the request. */ + "x-ms-client-request-id"?: string; +} + +/** The request has succeeded. */ +export interface DeploymentsGet200Response extends HttpResponse { + status: "200"; + body: DeploymentOutput; + headers: RawHttpHeaders & DeploymentsGet200Headers; +} + +export interface DeploymentsGetDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface DeploymentsGetDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & DeploymentsGetDefaultHeaders; +} + +export interface DeploymentsList200Headers { + /** An opaque, globally-unique, client-generated string identifier for the request. */ + "x-ms-client-request-id"?: string; +} + +/** The request has succeeded. */ +export interface DeploymentsList200Response extends HttpResponse { + status: "200"; + body: PagedDeploymentOutput; + headers: RawHttpHeaders & DeploymentsList200Headers; +} + +export interface DeploymentsListDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface DeploymentsListDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & DeploymentsListDefaultHeaders; +} + +/** The request has succeeded. */ +export interface EvaluationResultsListVersions200Response extends HttpResponse { + status: "200"; + body: PagedEvaluationResultOutput; +} + +export interface EvaluationResultsListVersionsDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface EvaluationResultsListVersionsDefaultResponse + extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & EvaluationResultsListVersionsDefaultHeaders; +} + +/** The request has succeeded. */ +export interface EvaluationResultsListLatest200Response extends HttpResponse { + status: "200"; + body: PagedEvaluationResultOutput; +} + +export interface EvaluationResultsListLatestDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface EvaluationResultsListLatestDefaultResponse + extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & EvaluationResultsListLatestDefaultHeaders; +} + +/** The request has succeeded. */ +export interface EvaluationResultsGetVersion200Response extends HttpResponse { + status: "200"; + body: EvaluationResultOutput; +} + +export interface EvaluationResultsGetVersionDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface EvaluationResultsGetVersionDefaultResponse + extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & EvaluationResultsGetVersionDefaultHeaders; +} + +/** There is no content to send for this request, but the headers may be useful. */ +export interface EvaluationResultsDeleteVersion204Response + extends HttpResponse { + status: "204"; +} + +export interface EvaluationResultsDeleteVersionDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface EvaluationResultsDeleteVersionDefaultResponse + extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & EvaluationResultsDeleteVersionDefaultHeaders; +} + +export interface EvaluationResultsCreate200Headers { + /** Indicates whether the repeatable request was accepted or rejected. */ + "repeatability-result"?: RepeatabilityResultOutput; + /** An opaque, globally-unique, client-generated string identifier for the request. */ + "x-ms-client-request-id"?: string; +} + +/** The request has succeeded. */ +export interface EvaluationResultsCreate200Response extends HttpResponse { + status: "200"; + body: EvaluationResultOutput; + headers: RawHttpHeaders & EvaluationResultsCreate200Headers; +} + +export interface EvaluationResultsCreateDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface EvaluationResultsCreateDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & EvaluationResultsCreateDefaultHeaders; +} + +/** The request has succeeded. */ +export interface EvaluationResultsCreateVersion200Response + extends HttpResponse { + status: "200"; + body: EvaluationResultOutput; +} + +/** The request has succeeded and a new resource has been created as a result. */ +export interface EvaluationResultsCreateVersion201Response + extends HttpResponse { + status: "201"; + body: EvaluationResultOutput; +} + +export interface EvaluationResultsCreateVersionDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface EvaluationResultsCreateVersionDefaultResponse + extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & EvaluationResultsCreateVersionDefaultHeaders; +} + +/** The request has succeeded. */ +export interface EvaluationResultsStartPendingUpload200Response + extends HttpResponse { + status: "200"; + body: PendingUploadResponseOutput; +} + +export interface EvaluationResultsStartPendingUploadDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface EvaluationResultsStartPendingUploadDefaultResponse + extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & EvaluationResultsStartPendingUploadDefaultHeaders; +} + +export interface RedTeamsGet200Headers { + /** An opaque, globally-unique, client-generated string identifier for the request. */ + "x-ms-client-request-id"?: string; +} + +/** The request has succeeded. */ +export interface RedTeamsGet200Response extends HttpResponse { + status: "200"; + body: RedTeamOutput; + headers: RawHttpHeaders & RedTeamsGet200Headers; +} + +export interface RedTeamsGetDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface RedTeamsGetDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & RedTeamsGetDefaultHeaders; +} + +export interface RedTeamsList200Headers { + /** An opaque, globally-unique, client-generated string identifier for the request. */ + "x-ms-client-request-id"?: string; +} + +/** The request has succeeded. */ +export interface RedTeamsList200Response extends HttpResponse { + status: "200"; + body: PagedRedTeamOutput; + headers: RawHttpHeaders & RedTeamsList200Headers; +} + +export interface RedTeamsListDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface RedTeamsListDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & RedTeamsListDefaultHeaders; +} + +/** The request has succeeded. */ +export interface RedTeamsCreateRun200Response extends HttpResponse { + status: "200"; + body: RedTeamOutput; +} + +export interface RedTeamsCreateRunDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface RedTeamsCreateRunDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & RedTeamsCreateRunDefaultHeaders; +} diff --git a/sdk/ai/ai-projects-1dp/test/public/sampleTest.spec.ts b/sdk/ai/ai-projects-1dp/test/public/sampleTest.spec.ts new file mode 100644 index 000000000000..d4919ac91ac5 --- /dev/null +++ b/sdk/ai/ai-projects-1dp/test/public/sampleTest.spec.ts @@ -0,0 +1,21 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { createRecorder } from "./utils/recordedClient.js"; +import { assert, beforeEach, afterEach, it, describe } from "vitest"; + +describe("My test", () => { + // let recorder: Recorder; + + beforeEach(async function () { + // recorder = await createRecorder(this); + }); + + afterEach(async function () { + // await recorder.stop(); + }); + + it("sample test", async function () { + assert.equal(1, 1); + }); +}); diff --git a/sdk/ai/ai-projects-1dp/test/public/utils/recordedClient.ts b/sdk/ai/ai-projects-1dp/test/public/utils/recordedClient.ts new file mode 100644 index 000000000000..6e425fdcfdf9 --- /dev/null +++ b/sdk/ai/ai-projects-1dp/test/public/utils/recordedClient.ts @@ -0,0 +1,29 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import { + Recorder, + RecorderStartOptions, + VitestTestContext, +} from "@azure-tools/test-recorder"; + +const replaceableVariables: Record = { + SUBSCRIPTION_ID: "azure_subscription_id", +}; + +const recorderEnvSetup: RecorderStartOptions = { + envSetupForPlayback: replaceableVariables, +}; + +/** + * creates the recorder and reads the environment variables from the `.env` file. + * Should be called first in the test suite to make sure environment variables are + * read before they are being used. + */ +export async function createRecorder( + context: VitestTestContext, +): Promise { + const recorder = new Recorder(context); + await recorder.start(recorderEnvSetup); + return recorder; +} diff --git a/sdk/ai/ai-projects-1dp/tsp-location.yaml b/sdk/ai/ai-projects-1dp/tsp-location.yaml new file mode 100644 index 000000000000..40b9d035d873 --- /dev/null +++ b/sdk/ai/ai-projects-1dp/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/ai/Azure.AI.Projects +commit: 1f45de6f98f795353a3770e917f59e1706462aad +repo: /mnt/vss/_work/1/s/azure-rest-api-specs +additionalDirectories: