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..8b7aa3977968 --- /dev/null +++ b/sdk/ai/ai-projects-1dp/src/clientDefinitions.ts @@ -0,0 +1,370 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { + ConnectionsGetParameters, + ConnectionsGetWithCredentialsParameters, + ConnectionsListParameters, + ConnectionsListWithCredentialsParameters, + EvaluationsGetParameters, + EvaluationsListParameters, + EvaluationsCreateRunParameters, + EvaluationsCreateAgentEvaluationParameters, + DatasetsListVersionsParameters, + DatasetsListLatestParameters, + DatasetsGetVersionParameters, + DatasetsDeleteVersionParameters, + DatasetsCreateOrUpdateVersionParameters, + DatasetsStartPendingUploadVersionParameters, + DatasetsGetCredentialsParameters, + IndexesListVersionsParameters, + IndexesListLatestParameters, + IndexesGetVersionParameters, + IndexesDeleteVersionParameters, + IndexesCreateOrUpdateVersionParameters, + DeploymentsGetParameters, + DeploymentsListParameters, + RedTeamsGetParameters, + RedTeamsListParameters, + RedTeamsCreateRunParameters, +} from "./parameters.js"; +import type { + ConnectionsGet200Response, + ConnectionsGetDefaultResponse, + ConnectionsGetWithCredentials200Response, + ConnectionsGetWithCredentialsDefaultResponse, + ConnectionsList200Response, + ConnectionsListDefaultResponse, + ConnectionsListWithCredentials200Response, + ConnectionsListWithCredentialsDefaultResponse, + EvaluationsGet200Response, + EvaluationsGetDefaultResponse, + EvaluationsList200Response, + EvaluationsListDefaultResponse, + EvaluationsCreateRun201Response, + EvaluationsCreateRunDefaultResponse, + EvaluationsCreateAgentEvaluation201Response, + EvaluationsCreateAgentEvaluationDefaultResponse, + DatasetsListVersions200Response, + DatasetsListVersionsDefaultResponse, + DatasetsListLatest200Response, + DatasetsListLatestDefaultResponse, + DatasetsGetVersion200Response, + DatasetsGetVersionDefaultResponse, + DatasetsDeleteVersion204Response, + DatasetsDeleteVersionDefaultResponse, + DatasetsCreateOrUpdateVersion200Response, + DatasetsCreateOrUpdateVersion201Response, + DatasetsCreateOrUpdateVersionDefaultResponse, + DatasetsStartPendingUploadVersion200Response, + DatasetsStartPendingUploadVersionDefaultResponse, + DatasetsGetCredentials200Response, + DatasetsGetCredentialsDefaultResponse, + IndexesListVersions200Response, + IndexesListVersionsDefaultResponse, + IndexesListLatest200Response, + IndexesListLatestDefaultResponse, + IndexesGetVersion200Response, + IndexesGetVersionDefaultResponse, + IndexesDeleteVersion204Response, + IndexesDeleteVersionDefaultResponse, + IndexesCreateOrUpdateVersion200Response, + IndexesCreateOrUpdateVersion201Response, + IndexesCreateOrUpdateVersionDefaultResponse, + DeploymentsGet200Response, + DeploymentsGetDefaultResponse, + DeploymentsList200Response, + DeploymentsListDefaultResponse, + RedTeamsGet200Response, + RedTeamsGetDefaultResponse, + RedTeamsList200Response, + RedTeamsListDefaultResponse, + RedTeamsCreateRun201Response, + RedTeamsCreateRunDefaultResponse, +} from "./responses.js"; +import type { Client, StreamableMethod } from "@azure-rest/core-client"; + +export interface ConnectionsGet { + /** Get a connection by name, without populating connection credentials */ + get( + options?: ConnectionsGetParameters, + ): StreamableMethod< + ConnectionsGet200Response | ConnectionsGetDefaultResponse + >; +} + +export interface ConnectionsGetWithCredentials { + /** Get a connection by name, with its connection credentials */ + post( + options?: ConnectionsGetWithCredentialsParameters, + ): StreamableMethod< + | ConnectionsGetWithCredentials200Response + | ConnectionsGetWithCredentialsDefaultResponse + >; +} + +export interface ConnectionsList { + /** List all connections in the project, without populating connection credentials */ + get( + options?: ConnectionsListParameters, + ): StreamableMethod< + ConnectionsList200Response | ConnectionsListDefaultResponse + >; +} + +export interface ConnectionsListWithCredentials { + /** List all connections in the project, with their connection credentials */ + post( + options?: ConnectionsListWithCredentialsParameters, + ): StreamableMethod< + | ConnectionsListWithCredentials200Response + | ConnectionsListWithCredentialsDefaultResponse + >; +} + +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< + EvaluationsCreateRun201Response | EvaluationsCreateRunDefaultResponse + >; +} + +export interface EvaluationsCreateAgentEvaluation { + /** Creates an agent evaluation run. */ + post( + options: EvaluationsCreateAgentEvaluationParameters, + ): StreamableMethod< + | EvaluationsCreateAgentEvaluation201Response + | EvaluationsCreateAgentEvaluationDefaultResponse + >; +} + +export interface DatasetsListVersions { + /** List all versions of the given DatasetVersion */ + get( + options?: DatasetsListVersionsParameters, + ): StreamableMethod< + DatasetsListVersions200Response | DatasetsListVersionsDefaultResponse + >; +} + +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 update an existing DatasetVersion with the given version id */ + patch( + options: DatasetsCreateOrUpdateVersionParameters, + ): StreamableMethod< + | DatasetsCreateOrUpdateVersion200Response + | DatasetsCreateOrUpdateVersion201Response + | DatasetsCreateOrUpdateVersionDefaultResponse + >; +} + +export interface DatasetsStartPendingUploadVersion { + /** Start a new or get an existing pending upload of a dataset for a specific version. */ + post( + options: DatasetsStartPendingUploadVersionParameters, + ): StreamableMethod< + | DatasetsStartPendingUploadVersion200Response + | DatasetsStartPendingUploadVersionDefaultResponse + >; +} + +export interface DatasetsGetCredentials { + /** Get download sas for dataset version. */ + post( + options: DatasetsGetCredentialsParameters, + ): StreamableMethod< + DatasetsGetCredentials200Response | DatasetsGetCredentialsDefaultResponse + >; +} + +export interface IndexesListVersions { + /** List all versions of the given Index */ + get( + options?: IndexesListVersionsParameters, + ): StreamableMethod< + IndexesListVersions200Response | IndexesListVersionsDefaultResponse + >; +} + +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 update an existing Index with the given version id */ + patch( + options: IndexesCreateOrUpdateVersionParameters, + ): StreamableMethod< + | IndexesCreateOrUpdateVersion200Response + | IndexesCreateOrUpdateVersion201Response + | IndexesCreateOrUpdateVersionDefaultResponse + >; +} + +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 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< + RedTeamsCreateRun201Response | RedTeamsCreateRunDefaultResponse + >; +} + +export interface Routes { + /** Resource for '/connections/\{name\}' has methods for the following verbs: get */ + (path: "/connections/{name}", name: string): ConnectionsGet; + /** Resource for '/connections/\{name\}/withCredentials' has methods for the following verbs: post */ + ( + path: "/connections/{name}/withCredentials", + name: string, + ): ConnectionsGetWithCredentials; + /** Resource for '/connections' has methods for the following verbs: get */ + (path: "/connections"): ConnectionsList; + /** Resource for '/connections/withCredentials' has methods for the following verbs: post */ + (path: "/connections/withCredentials"): ConnectionsListWithCredentials; + /** 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 '/evaluations/runs:runAgent' has methods for the following verbs: post */ + (path: "/evaluations/runs:runAgent"): EvaluationsCreateAgentEvaluation; + /** Resource for '/datasets/\{name\}/versions' has methods for the following verbs: get */ + (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, patch */ + ( + path: "/datasets/{name}/versions/{version}", + name: string, + version: string, + ): DatasetsGetVersion; + /** Resource for '/datasets/\{name\}/versions/\{version\}/startPendingUpload' has methods for the following verbs: post */ + ( + path: "/datasets/{name}/versions/{version}/startPendingUpload", + name: string, + version: string, + ): DatasetsStartPendingUploadVersion; + /** Resource for '/datasets/\{name\}/versions/\{version\}/credentials' has methods for the following verbs: post */ + ( + path: "/datasets/{name}/versions/{version}/credentials", + name: string, + version: string, + ): DatasetsGetCredentials; + /** Resource for '/indexes/\{name\}/versions' has methods for the following verbs: get */ + (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, patch */ + ( + 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 '/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..a8dac2c024e4 --- /dev/null +++ b/sdk/ai/ai-projects-1dp/src/isUnexpected.ts @@ -0,0 +1,347 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +import type { + ConnectionsGet200Response, + ConnectionsGetDefaultResponse, + ConnectionsGetWithCredentials200Response, + ConnectionsGetWithCredentialsDefaultResponse, + ConnectionsList200Response, + ConnectionsListDefaultResponse, + ConnectionsListWithCredentials200Response, + ConnectionsListWithCredentialsDefaultResponse, + EvaluationsGet200Response, + EvaluationsGetDefaultResponse, + EvaluationsList200Response, + EvaluationsListDefaultResponse, + EvaluationsCreateRun201Response, + EvaluationsCreateRunDefaultResponse, + EvaluationsCreateAgentEvaluation201Response, + EvaluationsCreateAgentEvaluationDefaultResponse, + DatasetsListVersions200Response, + DatasetsListVersionsDefaultResponse, + DatasetsListLatest200Response, + DatasetsListLatestDefaultResponse, + DatasetsGetVersion200Response, + DatasetsGetVersionDefaultResponse, + DatasetsDeleteVersion204Response, + DatasetsDeleteVersionDefaultResponse, + DatasetsCreateOrUpdateVersion200Response, + DatasetsCreateOrUpdateVersion201Response, + DatasetsCreateOrUpdateVersionDefaultResponse, + DatasetsStartPendingUploadVersion200Response, + DatasetsStartPendingUploadVersionDefaultResponse, + DatasetsGetCredentials200Response, + DatasetsGetCredentialsDefaultResponse, + IndexesListVersions200Response, + IndexesListVersionsDefaultResponse, + IndexesListLatest200Response, + IndexesListLatestDefaultResponse, + IndexesGetVersion200Response, + IndexesGetVersionDefaultResponse, + IndexesDeleteVersion204Response, + IndexesDeleteVersionDefaultResponse, + IndexesCreateOrUpdateVersion200Response, + IndexesCreateOrUpdateVersion201Response, + IndexesCreateOrUpdateVersionDefaultResponse, + DeploymentsGet200Response, + DeploymentsGetDefaultResponse, + DeploymentsList200Response, + DeploymentsListDefaultResponse, + RedTeamsGet200Response, + RedTeamsGetDefaultResponse, + RedTeamsList200Response, + RedTeamsListDefaultResponse, + RedTeamsCreateRun201Response, + RedTeamsCreateRunDefaultResponse, +} from "./responses.js"; + +const responseMap: Record = { + "GET /connections/{name}": ["200"], + "POST /connections/{name}/withCredentials": ["200"], + "GET /connections": ["200"], + "POST /connections/withCredentials": ["200"], + "GET /evaluations/runs/{name}": ["200"], + "GET /evaluations/runs": ["200"], + "POST /evaluations/runs:run": ["201"], + "POST /evaluations/runs:runAgent": ["201"], + "GET /datasets/{name}/versions": ["200"], + "GET /datasets": ["200"], + "GET /datasets/{name}/versions/{version}": ["200"], + "DELETE /datasets/{name}/versions/{version}": ["204"], + "PATCH /datasets/{name}/versions/{version}": ["200", "201"], + "POST /datasets/{name}/versions/{version}/startPendingUpload": ["200"], + "POST /datasets/{name}/versions/{version}/credentials": ["200"], + "GET /indexes/{name}/versions": ["200"], + "GET /indexes": ["200"], + "GET /indexes/{name}/versions/{version}": ["200"], + "DELETE /indexes/{name}/versions/{version}": ["204"], + "PATCH /indexes/{name}/versions/{version}": ["200", "201"], + "GET /deployments/{name}": ["200"], + "GET /deployments": ["200"], + "GET /redTeams/runs/{name}": ["200"], + "GET /redTeams/runs": ["200"], + "POST /redTeams/runs:run": ["201"], +}; + +export function isUnexpected( + response: ConnectionsGet200Response | ConnectionsGetDefaultResponse, +): response is ConnectionsGetDefaultResponse; +export function isUnexpected( + response: + | ConnectionsGetWithCredentials200Response + | ConnectionsGetWithCredentialsDefaultResponse, +): response is ConnectionsGetWithCredentialsDefaultResponse; +export function isUnexpected( + response: ConnectionsList200Response | ConnectionsListDefaultResponse, +): response is ConnectionsListDefaultResponse; +export function isUnexpected( + response: + | ConnectionsListWithCredentials200Response + | ConnectionsListWithCredentialsDefaultResponse, +): response is ConnectionsListWithCredentialsDefaultResponse; +export function isUnexpected( + response: EvaluationsGet200Response | EvaluationsGetDefaultResponse, +): response is EvaluationsGetDefaultResponse; +export function isUnexpected( + response: EvaluationsList200Response | EvaluationsListDefaultResponse, +): response is EvaluationsListDefaultResponse; +export function isUnexpected( + response: + | EvaluationsCreateRun201Response + | EvaluationsCreateRunDefaultResponse, +): response is EvaluationsCreateRunDefaultResponse; +export function isUnexpected( + response: + | EvaluationsCreateAgentEvaluation201Response + | EvaluationsCreateAgentEvaluationDefaultResponse, +): response is EvaluationsCreateAgentEvaluationDefaultResponse; +export function isUnexpected( + response: + | DatasetsListVersions200Response + | DatasetsListVersionsDefaultResponse, +): response is DatasetsListVersionsDefaultResponse; +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: + | DatasetsCreateOrUpdateVersion200Response + | DatasetsCreateOrUpdateVersion201Response + | DatasetsCreateOrUpdateVersionDefaultResponse, +): response is DatasetsCreateOrUpdateVersionDefaultResponse; +export function isUnexpected( + response: + | DatasetsStartPendingUploadVersion200Response + | DatasetsStartPendingUploadVersionDefaultResponse, +): response is DatasetsStartPendingUploadVersionDefaultResponse; +export function isUnexpected( + response: + | DatasetsGetCredentials200Response + | DatasetsGetCredentialsDefaultResponse, +): response is DatasetsGetCredentialsDefaultResponse; +export function isUnexpected( + response: IndexesListVersions200Response | IndexesListVersionsDefaultResponse, +): response is IndexesListVersionsDefaultResponse; +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: + | IndexesCreateOrUpdateVersion200Response + | IndexesCreateOrUpdateVersion201Response + | IndexesCreateOrUpdateVersionDefaultResponse, +): response is IndexesCreateOrUpdateVersionDefaultResponse; +export function isUnexpected( + response: DeploymentsGet200Response | DeploymentsGetDefaultResponse, +): response is DeploymentsGetDefaultResponse; +export function isUnexpected( + response: DeploymentsList200Response | DeploymentsListDefaultResponse, +): response is DeploymentsListDefaultResponse; +export function isUnexpected( + response: RedTeamsGet200Response | RedTeamsGetDefaultResponse, +): response is RedTeamsGetDefaultResponse; +export function isUnexpected( + response: RedTeamsList200Response | RedTeamsListDefaultResponse, +): response is RedTeamsListDefaultResponse; +export function isUnexpected( + response: RedTeamsCreateRun201Response | RedTeamsCreateRunDefaultResponse, +): response is RedTeamsCreateRunDefaultResponse; +export function isUnexpected( + response: + | ConnectionsGet200Response + | ConnectionsGetDefaultResponse + | ConnectionsGetWithCredentials200Response + | ConnectionsGetWithCredentialsDefaultResponse + | ConnectionsList200Response + | ConnectionsListDefaultResponse + | ConnectionsListWithCredentials200Response + | ConnectionsListWithCredentialsDefaultResponse + | EvaluationsGet200Response + | EvaluationsGetDefaultResponse + | EvaluationsList200Response + | EvaluationsListDefaultResponse + | EvaluationsCreateRun201Response + | EvaluationsCreateRunDefaultResponse + | EvaluationsCreateAgentEvaluation201Response + | EvaluationsCreateAgentEvaluationDefaultResponse + | DatasetsListVersions200Response + | DatasetsListVersionsDefaultResponse + | DatasetsListLatest200Response + | DatasetsListLatestDefaultResponse + | DatasetsGetVersion200Response + | DatasetsGetVersionDefaultResponse + | DatasetsDeleteVersion204Response + | DatasetsDeleteVersionDefaultResponse + | DatasetsCreateOrUpdateVersion200Response + | DatasetsCreateOrUpdateVersion201Response + | DatasetsCreateOrUpdateVersionDefaultResponse + | DatasetsStartPendingUploadVersion200Response + | DatasetsStartPendingUploadVersionDefaultResponse + | DatasetsGetCredentials200Response + | DatasetsGetCredentialsDefaultResponse + | IndexesListVersions200Response + | IndexesListVersionsDefaultResponse + | IndexesListLatest200Response + | IndexesListLatestDefaultResponse + | IndexesGetVersion200Response + | IndexesGetVersionDefaultResponse + | IndexesDeleteVersion204Response + | IndexesDeleteVersionDefaultResponse + | IndexesCreateOrUpdateVersion200Response + | IndexesCreateOrUpdateVersion201Response + | IndexesCreateOrUpdateVersionDefaultResponse + | DeploymentsGet200Response + | DeploymentsGetDefaultResponse + | DeploymentsList200Response + | DeploymentsListDefaultResponse + | RedTeamsGet200Response + | RedTeamsGetDefaultResponse + | RedTeamsList200Response + | RedTeamsListDefaultResponse + | RedTeamsCreateRun201Response + | RedTeamsCreateRunDefaultResponse, +): response is + | ConnectionsGetDefaultResponse + | ConnectionsGetWithCredentialsDefaultResponse + | ConnectionsListDefaultResponse + | ConnectionsListWithCredentialsDefaultResponse + | EvaluationsGetDefaultResponse + | EvaluationsListDefaultResponse + | EvaluationsCreateRunDefaultResponse + | EvaluationsCreateAgentEvaluationDefaultResponse + | DatasetsListVersionsDefaultResponse + | DatasetsListLatestDefaultResponse + | DatasetsGetVersionDefaultResponse + | DatasetsDeleteVersionDefaultResponse + | DatasetsCreateOrUpdateVersionDefaultResponse + | DatasetsStartPendingUploadVersionDefaultResponse + | DatasetsGetCredentialsDefaultResponse + | IndexesListVersionsDefaultResponse + | IndexesListLatestDefaultResponse + | IndexesGetVersionDefaultResponse + | IndexesDeleteVersionDefaultResponse + | IndexesCreateOrUpdateVersionDefaultResponse + | DeploymentsGetDefaultResponse + | DeploymentsListDefaultResponse + | 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..aac13adbbf9e --- /dev/null +++ b/sdk/ai/ai-projects-1dp/src/models.ts @@ -0,0 +1,221 @@ +// 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; +} + +/** Evaluation request for agent run. */ +export interface AgentEvaluationRequest { + /** Identifier of the agent run. */ + runId: string; + /** Identifier of the agent thread. This field is mandatory currently, but it will be optional in the future. */ + threadId?: string; + /** Evaluators to be used for the evaluation. */ + evaluators: Record; + /** Sampling configuration for the evaluation. */ + samplingConfiguration?: AgentEvaluationSamplingConfiguration; + /** Redaction configuration for the evaluation. */ + redactionConfiguration?: AgentEvaluationRedactionConfiguration; + /** Optional and temporary way to pass the AppInsights connection string to the evaluator. When this string is not null, the evaluation results will be logged to Azure AppInsights. */ + appInsightsConnectionString?: string; +} + +/** Definition for sampling strategy. */ +export interface AgentEvaluationSamplingConfiguration { + /** Name of the sampling strategy. */ + name: string; + /** Percentage of sampling per hour (0-100). */ + samplingPercent: number; + /** Maximum request rate per hour (0 to 1000). */ + maxRequestRate: number; +} + +/** The redaction configuration will allow the user to control what is redacted. */ +export interface AgentEvaluationRedactionConfiguration { + /** Redact score properties. If not specified, the default is to redact in production. */ + redactScoreProperties?: boolean; +} + +/** 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; +} + +/** 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. */ + attackStrategies: 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; + /** Target configuration for the red-team run. */ + targetConfig: TargetConfig; +} + +/** Abstract class for target configuration. */ +export interface TargetConfigParent { + type: string; +} + +/** Azure OpenAI model configuration. The API version would be selected by the service for querying the model. */ +export interface AzureOpenAIModelConfiguration extends TargetConfigParent { + /** Deployment name for AOAI model. Example: gpt-4o if in AIServices or connection based `connection_name/deployment_name` (i.e. `my-aoai-connection/gpt-4o`. */ + modelDeploymentName: string; +} + +/** 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; +/** Abstract class for target configuration. */ +export type TargetConfig = TargetConfigParent | AzureOpenAIModelConfiguration; +/** 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 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..77534789ecbe --- /dev/null +++ b/sdk/ai/ai-projects-1dp/src/outputModels.ts @@ -0,0 +1,440 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT License. + +/** Response from the list and get connections operations */ +export interface ConnectionOutput { + /** The name of the resource */ + readonly name: string; + /** + * Category of the connection + * + * Possible values: "AzureOpenAI", "AzureBlob", "AzureStorageAccount", "CognitiveSearch", "CosmosDB", "ApiKey", "AppConfig", "AppInsights", "CustomKeys" + */ + readonly type: ConnectionTypeOutput; + /** The connection URL to be used for this service */ + readonly target: string; + /** Whether the connection is tagged as the default connection of its type */ + readonly isDefault: boolean; + /** The credentials used by the connection */ + readonly credentials: BaseCredentialsOutput; + /** Metadata of the connection */ + readonly metadata: Record; +} + +/** A base class for connection credentials */ +export interface BaseCredentialsOutputParent { + authType: CredentialTypeOutput; +} + +/** API Key Credential definition */ +export interface ApiKeyCredentialsOutput extends BaseCredentialsOutputParent { + /** The credentail type */ + readonly authType: "ApiKey"; + /** API Key */ + readonly apiKey?: string; +} + +/** Entra ID credential definition */ +export interface EntraIDCredentialsOutput extends BaseCredentialsOutputParent { + /** The credential type */ + readonly authType: "AAD"; +} + +/** Custom credential defintion */ +export interface CustomCredentialOutput extends BaseCredentialsOutputParent { + /** The credential type */ + readonly authType: "CustomKeys"; +} + +/** Shared Access Signature (SAS) credential definition */ +export interface SASCredentialsOutput extends BaseCredentialsOutputParent { + /** The credential type */ + readonly authType: "SAS"; + /** SAS token */ + readonly sasToken?: string; +} + +/** Credentials that do not require authentication */ +export interface NoAuthenticationCredentialsOutput + extends BaseCredentialsOutputParent { + /** The credential type */ + readonly authType: "None"; +} + +/** 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; +} + +/** Paged collection of Connection items */ +export interface ConnectionPagedOutput { + /** 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; +} + +/** 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; +} + +/** Evaluation response for agent evaluation run. */ +export interface AgentEvaluationOutput { + /** Identifier of the agent evaluation run. */ + id: string; + /** Status of the agent evaluation. Options: Running, Completed, Failed. */ + status: string; + /** The agent evaluation result. */ + result?: Array; +} + +/** Result for the agent evaluation evaluator run. */ +export interface AgentEvaluationResultOutput { + /** Evaluator's name. This is the name of the evaluator that was used to evaluate the agent's completion. */ + evaluator: string; + /** Score of the given evaluator. No restriction on range. */ + score: number; + /** Status of the evaluator result. Options: Running, Completed, Failed, NotApplicable. */ + status: string; + /** Reasoning for the evaluation result. */ + reason?: string; + /** Version of the evaluator that was used to evaluate the agent's completion. */ + version?: string; + /** The unique identifier of the thread. */ + threadId?: string; + /** The unique identifier of the run. */ + runId: string; + /** A string explaining why there was an error, if applicable. */ + error?: string; + /** Additional properties relevant to the evaluator. These will differ between evaluators. */ + additionalDetails?: Record; +} + +/** 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"; +} + +/** Represents a reference to a blob for consumption */ +export interface AssetCredentialResponseOutput { + /** Credential info to access the storage account. */ + blobReferenceForConsumption: BlobReferenceForConsumptionOutput; +} + +/** 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; +} + +/** 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. */ + attackStrategies: AttackStrategyOutput[]; + /** 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: 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; + /** Target configuration for the red-team run. */ + targetConfig: TargetConfigOutput; +} + +/** Abstract class for target configuration. */ +export interface TargetConfigOutputParent { + type: string; +} + +/** Azure OpenAI model configuration. The API version would be selected by the service for querying the model. */ +export interface AzureOpenAIModelConfigurationOutput + extends TargetConfigOutputParent { + readonly type: "AzureOpenAIModel"; + /** Deployment name for AOAI model. Example: gpt-4o if in AIServices or connection based `connection_name/deployment_name` (i.e. `my-aoai-connection/gpt-4o`. */ + modelDeploymentName: 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; +} + +/** A base class for connection credentials */ +export type BaseCredentialsOutput = + | BaseCredentialsOutputParent + | ApiKeyCredentialsOutput + | EntraIDCredentialsOutput + | CustomCredentialOutput + | SASCredentialsOutput + | NoAuthenticationCredentialsOutput; +/** 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; +/** Abstract class for target configuration. */ +export type TargetConfigOutput = + | TargetConfigOutputParent + | AzureOpenAIModelConfigurationOutput; +/** Alias for ConnectionTypeOutput */ +export type ConnectionTypeOutput = string; +/** Alias for CredentialTypeOutput */ +export type CredentialTypeOutput = string; +/** Alias for DatasetTypeOutput */ +export type DatasetTypeOutput = string; +/** Alias for IndexTypeOutput */ +export type IndexTypeOutput = string; +/** Alias for DeploymentTypeOutput */ +export type DeploymentTypeOutput = 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..86739c8fe042 --- /dev/null +++ b/sdk/ai/ai-projects-1dp/src/parameters.ts @@ -0,0 +1,373 @@ +// 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, + AgentEvaluationRequest, + ListViewType, + DatasetVersion, + PendingUploadRequest, + Index, + 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 ConnectionsGetWithCredentialsHeaders { + /** An opaque, globally-unique, client-generated string identifier for the request. */ + "x-ms-client-request-id"?: string; +} + +export interface ConnectionsGetWithCredentialsHeaderParam { + headers?: RawHttpHeadersInput & ConnectionsGetWithCredentialsHeaders; +} + +export type ConnectionsGetWithCredentialsParameters = + ConnectionsGetWithCredentialsHeaderParam & RequestParameters; + +export interface ConnectionsListHeaders { + /** An opaque, globally-unique, client-generated string identifier for the request. */ + "x-ms-client-request-id"?: string; +} + +export interface ConnectionsListQueryParamProperties { + /** + * List connections of this specific type + * + * Possible values: "AzureOpenAI", "AzureBlob", "AzureStorageAccount", "CognitiveSearch", "CosmosDB", "ApiKey", "AppConfig", "AppInsights", "CustomKeys" + */ + connectionType?: ConnectionType; + /** List connections that are default connections */ + defaultConnection?: boolean; + /** 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 ConnectionsListWithCredentialsHeaders { + /** An opaque, globally-unique, client-generated string identifier for the request. */ + "x-ms-client-request-id"?: string; +} + +export interface ConnectionsListWithCredentialsQueryParamProperties { + /** + * List connections of this specific type + * + * Possible values: "AzureOpenAI", "AzureBlob", "AzureStorageAccount", "CognitiveSearch", "CosmosDB", "ApiKey", "AppConfig", "AppInsights", "CustomKeys" + */ + connectionType?: ConnectionType; + /** List connections that are default connections */ + defaultConnection?: boolean; + /** 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 ConnectionsListWithCredentialsQueryParam { + queryParameters?: ConnectionsListWithCredentialsQueryParamProperties; +} + +export interface ConnectionsListWithCredentialsHeaderParam { + headers?: RawHttpHeadersInput & ConnectionsListWithCredentialsHeaders; +} + +export type ConnectionsListWithCredentialsParameters = + ConnectionsListWithCredentialsQueryParam & + ConnectionsListWithCredentialsHeaderParam & + 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 EvaluationsCreateAgentEvaluationBodyParam { + /** Agent evaluation to be run */ + body: AgentEvaluationRequest; +} + +export type EvaluationsCreateAgentEvaluationParameters = + EvaluationsCreateAgentEvaluationBodyParam & 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 DatasetsCreateOrUpdateVersionBodyParam { + /** The definition of the DatasetVersion to create or update */ + body: DatasetVersion; +} + +export type DatasetsCreateOrUpdateVersionParameters = + DatasetsCreateOrUpdateVersionBodyParam & RequestParameters; + +export interface DatasetsStartPendingUploadVersionBodyParam { + /** Parameters for the action */ + body: PendingUploadRequest; +} + +export type DatasetsStartPendingUploadVersionParameters = + DatasetsStartPendingUploadVersionBodyParam & RequestParameters; + +export interface DatasetsGetCredentialsBodyParam { + /** Parameters for the action */ + body: Record; +} + +export type DatasetsGetCredentialsParameters = DatasetsGetCredentialsBodyParam & + 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 IndexesCreateOrUpdateVersionBodyParam { + /** The definition of the Index to create or update */ + body: Index; +} + +export type IndexesCreateOrUpdateVersionParameters = + IndexesCreateOrUpdateVersionBodyParam & 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 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..a399f8cdf3b7 --- /dev/null +++ b/sdk/ai/ai-projects-1dp/src/projectsClient.ts @@ -0,0 +1,70 @@ +// 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 } 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 "https://.services.ai.azure.com/api/projects/_project" + * if your Foundry Hub has only one Project, or to use the default Project in your Hub. Or in the form + * "https://.services.ai.azure.com/api/projects/" if you want to explicitly + * specify the Foundry Project name. + * @param credentials - uniquely identify client credential + * @param options - the parameter for all optional parameters + */ +export default function createClient( + endpointParam: string, + credentials: TokenCredential, + { 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); + }, + }); + + 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..e36fdc3c6756 --- /dev/null +++ b/sdk/ai/ai-projects-1dp/src/responses.ts @@ -0,0 +1,569 @@ +// 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, + ConnectionPagedOutput, + EvaluationOutput, + PagedEvaluationOutput, + AgentEvaluationOutput, + PagedDatasetVersionOutput, + DatasetTypeOutput, + PendingUploadResponseOutput, + AssetCredentialResponseOutput, + PagedIndexOutput, + IndexTypeOutput, + DeploymentOutput, + PagedDeploymentOutput, + 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 ConnectionsGetWithCredentials200Headers { + /** An opaque, globally-unique, client-generated string identifier for the request. */ + "x-ms-client-request-id"?: string; +} + +/** The request has succeeded. */ +export interface ConnectionsGetWithCredentials200Response extends HttpResponse { + status: "200"; + body: ConnectionOutput; + headers: RawHttpHeaders & ConnectionsGetWithCredentials200Headers; +} + +export interface ConnectionsGetWithCredentialsDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface ConnectionsGetWithCredentialsDefaultResponse + extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & ConnectionsGetWithCredentialsDefaultHeaders; +} + +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 ConnectionsListWithCredentials200Headers { + /** An opaque, globally-unique, client-generated string identifier for the request. */ + "x-ms-client-request-id"?: string; +} + +/** The request has succeeded. */ +export interface ConnectionsListWithCredentials200Response + extends HttpResponse { + status: "200"; + body: ConnectionPagedOutput; + headers: RawHttpHeaders & ConnectionsListWithCredentials200Headers; +} + +export interface ConnectionsListWithCredentialsDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface ConnectionsListWithCredentialsDefaultResponse + extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & ConnectionsListWithCredentialsDefaultHeaders; +} + +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 and a new resource has been created as a result. */ +export interface EvaluationsCreateRun201Response extends HttpResponse { + status: "201"; + 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 and a new resource has been created as a result. */ +export interface EvaluationsCreateAgentEvaluation201Response + extends HttpResponse { + status: "201"; + body: AgentEvaluationOutput; +} + +export interface EvaluationsCreateAgentEvaluationDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface EvaluationsCreateAgentEvaluationDefaultResponse + extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & EvaluationsCreateAgentEvaluationDefaultHeaders; +} + +/** 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: { + datasetUri: string; + type: DatasetTypeOutput; + isReference?: boolean; + stage?: string; + id?: string; + name: string; + version: string; + }; +} + +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; +} + +/** The request has succeeded. */ +export interface DatasetsCreateOrUpdateVersion200Response extends HttpResponse { + status: "200"; + body: { + datasetUri: string; + type: DatasetTypeOutput; + isReference?: boolean; + stage?: string; + id?: string; + name: string; + version: string; + }; +} + +/** The request has succeeded and a new resource has been created as a result. */ +export interface DatasetsCreateOrUpdateVersion201Response extends HttpResponse { + status: "201"; + body: { + datasetUri: string; + type: DatasetTypeOutput; + isReference?: boolean; + stage?: string; + id?: string; + name: string; + version: string; + }; +} + +export interface DatasetsCreateOrUpdateVersionDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface DatasetsCreateOrUpdateVersionDefaultResponse + extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & DatasetsCreateOrUpdateVersionDefaultHeaders; +} + +/** 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 DatasetsGetCredentials200Response extends HttpResponse { + status: "200"; + body: AssetCredentialResponseOutput; +} + +export interface DatasetsGetCredentialsDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface DatasetsGetCredentialsDefaultResponse extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & DatasetsGetCredentialsDefaultHeaders; +} + +/** 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: { + type: IndexTypeOutput; + stage?: string; + id?: string; + name: string; + version: string; + }; +} + +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; +} + +/** The request has succeeded. */ +export interface IndexesCreateOrUpdateVersion200Response extends HttpResponse { + status: "200"; + body: { + type: IndexTypeOutput; + stage?: string; + id?: string; + name: string; + version: string; + }; +} + +/** The request has succeeded and a new resource has been created as a result. */ +export interface IndexesCreateOrUpdateVersion201Response extends HttpResponse { + status: "201"; + body: { + type: IndexTypeOutput; + stage?: string; + id?: string; + name: string; + version: string; + }; +} + +export interface IndexesCreateOrUpdateVersionDefaultHeaders { + /** String error code indicating what went wrong. */ + "x-ms-error-code"?: string; +} + +export interface IndexesCreateOrUpdateVersionDefaultResponse + extends HttpResponse { + status: string; + body: ErrorResponse; + headers: RawHttpHeaders & IndexesCreateOrUpdateVersionDefaultHeaders; +} + +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; +} + +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 and a new resource has been created as a result. */ +export interface RedTeamsCreateRun201Response extends HttpResponse { + status: "201"; + 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..bf356d31098f --- /dev/null +++ b/sdk/ai/ai-projects-1dp/tsp-location.yaml @@ -0,0 +1,4 @@ +directory: specification/ai/Azure.AI.Projects +commit: c31e7bfdb3a7c99577bd597ce6b7bad5644bafe8 +repo: /mnt/vss/_work/1/s/azure-rest-api-specs +additionalDirectories: