diff --git a/packages/ai-core/src/application-api.ts b/packages/ai-core/src/application-api.ts index 4c4a5363..780f324d 100644 --- a/packages/ai-core/src/application-api.ts +++ b/packages/ai-core/src/application-api.ts @@ -24,60 +24,76 @@ export const ApplicationApi = { * Return all Argo CD application data objects. * * @param queryParameters - Object containing the following keys: $top, $skip, $count. + * @param headerParameters - Object containing the following keys: Authorization. * @returns The request builder, use the `execute()` method to trigger the request. */ - kubesubmitV4ApplicationsGetAll: (queryParameters?: { - $top?: number; - $skip?: number; - $count?: boolean; - }) => + kubesubmitV4ApplicationsGetAll: ( + queryParameters?: { $top?: number; $skip?: number; $count?: boolean }, + headerParameters?: { Authorization?: string } + ) => new OpenApiRequestBuilder( 'get', '/admin/applications', { - queryParameters + queryParameters, + headerParameters } ), /** * Create an ArgoCD application to synchronise a repository. * * @param body - Request body. + * @param headerParameters - Object containing the following keys: Authorization. * @returns The request builder, use the `execute()` method to trigger the request. */ - kubesubmitV4ApplicationsCreate: (body: Body) => + kubesubmitV4ApplicationsCreate: ( + body: Body, + headerParameters?: { Authorization?: string } + ) => new OpenApiRequestBuilder( 'post', '/admin/applications', { - body + body, + headerParameters } ), /** * Returns the ArgoCD application health and sync status. * * @param applicationName - Name of the ArgoCD application + * @param headerParameters - Object containing the following keys: Authorization. * @returns The request builder, use the `execute()` method to trigger the request. */ - kubesubmitV4ApplicationsGetStatus: (applicationName: string) => + kubesubmitV4ApplicationsGetStatus: ( + applicationName: string, + headerParameters?: { Authorization?: string } + ) => new OpenApiRequestBuilder( 'get', '/admin/applications/{applicationName}/status', { - pathParameters: { applicationName } + pathParameters: { applicationName }, + headerParameters } ), /** * Retrieve the ArgoCD application details. * * @param applicationName - Name of the ArgoCD application + * @param headerParameters - Object containing the following keys: Authorization. * @returns The request builder, use the `execute()` method to trigger the request. */ - kubesubmitV4ApplicationsGet: (applicationName: string) => + kubesubmitV4ApplicationsGet: ( + applicationName: string, + headerParameters?: { Authorization?: string } + ) => new OpenApiRequestBuilder( 'get', '/admin/applications/{applicationName}', { - pathParameters: { applicationName } + pathParameters: { applicationName }, + headerParameters } ), /** @@ -85,45 +101,58 @@ export const ApplicationApi = { * * @param applicationName - Name of the ArgoCD application * @param body - Request body. + * @param headerParameters - Object containing the following keys: Authorization. * @returns The request builder, use the `execute()` method to trigger the request. */ kubesubmitV4ApplicationsUpdate: ( applicationName: string, - body: ArgoCDApplicationBaseData + body: ArgoCDApplicationBaseData, + headerParameters?: { Authorization?: string } ) => new OpenApiRequestBuilder( 'patch', '/admin/applications/{applicationName}', { pathParameters: { applicationName }, - body + body, + headerParameters } ), /** * Delete an ArgoCD application * @param applicationName - Name of the ArgoCD application + * @param headerParameters - Object containing the following keys: Authorization. * @returns The request builder, use the `execute()` method to trigger the request. */ - kubesubmitV4ApplicationsDelete: (applicationName: string) => + kubesubmitV4ApplicationsDelete: ( + applicationName: string, + headerParameters?: { Authorization?: string } + ) => new OpenApiRequestBuilder( 'delete', '/admin/applications/{applicationName}', { - pathParameters: { applicationName } + pathParameters: { applicationName }, + headerParameters } ), /** * Schedules a refresh of the specified application that will be picked up by ArgoCD asynchronously * * @param applicationName - Name of the ArgoCD application + * @param headerParameters - Object containing the following keys: Authorization. * @returns The request builder, use the `execute()` method to trigger the request. */ - kubesubmitV4ApplicationsRefresh: (applicationName: string) => + kubesubmitV4ApplicationsRefresh: ( + applicationName: string, + headerParameters?: { Authorization?: string } + ) => new OpenApiRequestBuilder( 'post', '/admin/applications/{applicationName}/refresh', { - pathParameters: { applicationName } + pathParameters: { applicationName }, + headerParameters } ) }; diff --git a/packages/ai-core/src/artifact-api.test.ts b/packages/ai-core/src/artifact-api.test.ts new file mode 100644 index 00000000..22943ddc --- /dev/null +++ b/packages/ai-core/src/artifact-api.test.ts @@ -0,0 +1,86 @@ +import nock from 'nock'; +import { HttpDestination } from '@sap-cloud-sdk/connectivity'; +import { + ArtifactApi, + ArtifactCreationResponse, + ArtifactList, + ArtifactPostData +} from './index.js'; + +describe('artifact', () => { + const destination: HttpDestination = { + url: 'https://ai.example.com' + }; + + afterEach(() => { + nock.cleanAll(); + }); + + it('parses a successful response for get request', async () => { + const expectedResponse: ArtifactList = { + count: 1, + resources: [ + { + createdAt: '2024-07-08T13:36:41Z', + description: 'dataset for training test', + id: '0a1b2c3d', + kind: 'dataset', + modifiedAt: '2024-07-08T13:36:41Z', + name: 'training-test-data', + scenarioId: 'foundation-models', + url: 'ai://default/spam/data' + } + ] + }; + + nock(destination.url, { + reqheaders: { + 'AI-Resource-Group': 'default' + } + }) + .get('/lm/artifacts') + .reply(200, expectedResponse, { + 'Content-Type': 'application/json' + }); + + const result: ArtifactList = await ArtifactApi.artifactQuery( + {}, + { 'AI-Resource-Group': 'default' } + ).execute(destination); + + expect(result).toEqual(expectedResponse); + }); + + it('parses a successful response for post request', async () => { + const expectedResponse: ArtifactCreationResponse = { + id: '3d2c1b0a', + message: 'Artifact acknowledged', + url: 'ai://default/spam/data' + }; + + nock(destination.url, { + reqheaders: { + 'AI-Resource-Group': 'default' + } + }) + .post('/lm/artifacts') + .reply(200, expectedResponse, { + 'Content-Type': 'application/json' + }); + + const artifactPostData: ArtifactPostData = { + description: 'dataset for training test', + kind: 'dataset', + name: 'training-test-data', + scenarioId: 'foundation-models', + url: 'ai://default/spam/data' + }; + + const result: ArtifactCreationResponse = await ArtifactApi.artifactCreate( + artifactPostData, + { 'AI-Resource-Group': 'default' } + ).execute(destination); + + expect(result).toEqual(expectedResponse); + }); +}); diff --git a/packages/ai-core/src/artifact-api.ts b/packages/ai-core/src/artifact-api.ts index 1cd8e9db..76a4cb16 100644 --- a/packages/ai-core/src/artifact-api.ts +++ b/packages/ai-core/src/artifact-api.ts @@ -23,49 +23,62 @@ export const ArtifactApi = { * Search by substring of artifact name or description, if required. * * @param queryParameters - Object containing the following keys: scenarioId, executionId, name, kind, artifactLabelSelector, $top, $skip, $search, searchCaseInsensitive, $expand. + * @param headerParameters - Object containing the following keys: AI-Resource-Group. * @returns The request builder, use the `execute()` method to trigger the request. */ - artifactQuery: (queryParameters?: { - scenarioId?: string; - executionId?: string; - name?: Name_1; - kind?: 'model' | 'dataset' | 'resultset' | 'other'; - artifactLabelSelector?: string[]; - $top?: number; - $skip?: number; - $search?: string; - searchCaseInsensitive?: boolean; - $expand?: 'scenario'; - }) => + artifactQuery: ( + queryParameters: { + scenarioId?: string; + executionId?: string; + name?: Name_1; + kind?: 'model' | 'dataset' | 'resultset' | 'other'; + artifactLabelSelector?: string[]; + $top?: number; + $skip?: number; + $search?: string; + searchCaseInsensitive?: boolean; + $expand?: 'scenario'; + }, + headerParameters: { 'AI-Resource-Group': string } + ) => new OpenApiRequestBuilder('get', '/lm/artifacts', { - queryParameters + queryParameters, + headerParameters }), /** * Register an artifact for use in a configuration, for example a model or a dataset. * @param body - Request body. + * @param headerParameters - Object containing the following keys: AI-Resource-Group. * @returns The request builder, use the `execute()` method to trigger the request. */ - artifactCreate: (body: ArtifactPostData) => + artifactCreate: ( + body: ArtifactPostData, + headerParameters: { 'AI-Resource-Group': string } + ) => new OpenApiRequestBuilder( 'post', '/lm/artifacts', { - body + body, + headerParameters } ), /** * Retrieve details for artifact with artifactId. * @param artifactId - Artifact identifier * @param queryParameters - Object containing the following keys: $expand. + * @param headerParameters - Object containing the following keys: AI-Resource-Group. * @returns The request builder, use the `execute()` method to trigger the request. */ artifactGet: ( artifactId: string, - queryParameters?: { $expand?: 'scenario' } + queryParameters: { $expand?: 'scenario' }, + headerParameters: { 'AI-Resource-Group': string } ) => new OpenApiRequestBuilder('get', '/lm/artifacts/{artifactId}', { pathParameters: { artifactId }, - queryParameters + queryParameters, + headerParameters }), /** * Retrieve the number of available artifacts that match the specified filter criteria. @@ -73,18 +86,23 @@ export const ArtifactApi = { * Search by substring of artifact name or description is also possible. * * @param queryParameters - Object containing the following keys: scenarioId, executionId, name, kind, $search, searchCaseInsensitive, artifactLabelSelector. + * @param headerParameters - Object containing the following keys: AI-Resource-Group. * @returns The request builder, use the `execute()` method to trigger the request. */ - artifactCount: (queryParameters?: { - scenarioId?: string; - executionId?: string; - name?: Name_1; - kind?: 'model' | 'dataset' | 'resultset' | 'other'; - $search?: string; - searchCaseInsensitive?: boolean; - artifactLabelSelector?: string[]; - }) => + artifactCount: ( + queryParameters: { + scenarioId?: string; + executionId?: string; + name?: Name_1; + kind?: 'model' | 'dataset' | 'resultset' | 'other'; + $search?: string; + searchCaseInsensitive?: boolean; + artifactLabelSelector?: string[]; + }, + headerParameters: { 'AI-Resource-Group': string } + ) => new OpenApiRequestBuilder('get', '/lm/artifacts/$count', { - queryParameters + queryParameters, + headerParameters }) }; diff --git a/packages/ai-core/src/configuration-api.test.ts b/packages/ai-core/src/configuration-api.test.ts new file mode 100644 index 00000000..0731f1b7 --- /dev/null +++ b/packages/ai-core/src/configuration-api.test.ts @@ -0,0 +1,97 @@ +import nock from 'nock'; +import { HttpDestination } from '@sap-cloud-sdk/connectivity'; +import { + ConfigurationApi, + ConfigurationBaseData, + ConfigurationCreationResponse, + ConfigurationList +} from './index.js'; + +describe('configuration', () => { + const destination: HttpDestination = { + url: 'https://ai.example.com' + }; + + afterEach(() => { + nock.cleanAll(); + }); + + it('parses a successful response for get request', async () => { + const expectedResponse: ConfigurationList = { + count: 1, + resources: [ + { + createdAt: '2024-04-17T15:19:45Z', + executableId: 'azure-openai', + id: '0a1b2c3d', + inputArtifactBindings: [], + name: 'gpt-4-32k', + parameterBindings: [ + { + key: 'modelName', + value: 'gpt-4-32k' + }, + { + key: 'modelVersion', + value: 'latest' + } + ], + scenarioId: 'foundation-models' + } + ] + }; + + nock(destination.url, { + reqheaders: { + 'AI-Resource-Group': 'default' + } + }) + .get('/lm/configurations') + .reply(200, expectedResponse, { + 'Content-Type': 'application/json' + }); + + const result: ConfigurationList = await ConfigurationApi.configurationQuery( + {}, + { 'AI-Resource-Group': 'default' } + ).execute(destination); + + expect(result).toEqual(expectedResponse); + }); + + it('parses a successful response for post request', async () => { + const expectedResponse: ConfigurationCreationResponse = { + id: '3d2c1b0a', + message: 'Configuration created' + }; + + nock(destination.url, { + reqheaders: { + 'AI-Resource-Group': 'default' + } + }) + .post('/lm/configurations') + .reply(200, expectedResponse, { + 'Content-Type': 'application/json' + }); + + const configurationPostData: ConfigurationBaseData = { + name: 'training-test-config', + executableId: 'azure-openai', + scenarioId: 'foundation-models', + inputArtifactBindings: [ + { + artifactId: '0a1b2c3d', + key: 'spam-data' + } + ] + }; + + const result: ConfigurationCreationResponse = + await ConfigurationApi.configurationCreate(configurationPostData, { + 'AI-Resource-Group': 'default' + }).execute(destination); + + expect(result).toEqual(expectedResponse); + }); +}); diff --git a/packages/ai-core/src/configuration-api.ts b/packages/ai-core/src/configuration-api.ts index 96ef1960..b3223fda 100644 --- a/packages/ai-core/src/configuration-api.ts +++ b/packages/ai-core/src/configuration-api.ts @@ -20,51 +20,64 @@ export const ConfigurationApi = { * Search for configurations containing the search string as substring in the configuration name. * * @param queryParameters - Object containing the following keys: scenarioId, $top, $skip, executableIds, $search, searchCaseInsensitive, $expand. + * @param headerParameters - Object containing the following keys: AI-Resource-Group. * @returns The request builder, use the `execute()` method to trigger the request. */ - configurationQuery: (queryParameters?: { - scenarioId?: string; - $top?: number; - $skip?: number; - executableIds?: string[]; - $search?: string; - searchCaseInsensitive?: boolean; - $expand?: 'scenario'; - }) => + configurationQuery: ( + queryParameters: { + scenarioId?: string; + $top?: number; + $skip?: number; + executableIds?: string[]; + $search?: string; + searchCaseInsensitive?: boolean; + $expand?: 'scenario'; + }, + headerParameters: { 'AI-Resource-Group': string } + ) => new OpenApiRequestBuilder('get', '/lm/configurations', { - queryParameters + queryParameters, + headerParameters }), /** * Create a new configuration linked to a specific scenario and executable for use in an execution * or deployment. * * @param body - Request body. + * @param headerParameters - Object containing the following keys: AI-Resource-Group. * @returns The request builder, use the `execute()` method to trigger the request. */ - configurationCreate: (body: ConfigurationBaseData) => + configurationCreate: ( + body: ConfigurationBaseData, + headerParameters: { 'AI-Resource-Group': string } + ) => new OpenApiRequestBuilder( 'post', '/lm/configurations', { - body + body, + headerParameters } ), /** * Retrieve details for configuration with configurationId. * @param configurationId - Configuration identifier * @param queryParameters - Object containing the following keys: $expand. + * @param headerParameters - Object containing the following keys: AI-Resource-Group. * @returns The request builder, use the `execute()` method to trigger the request. */ configurationGet: ( configurationId: string, - queryParameters?: { $expand?: 'scenario' } + queryParameters: { $expand?: 'scenario' }, + headerParameters: { 'AI-Resource-Group': string } ) => new OpenApiRequestBuilder( 'get', '/lm/configurations/{configurationId}', { pathParameters: { configurationId }, - queryParameters + queryParameters, + headerParameters } ), /** @@ -72,15 +85,20 @@ export const ConfigurationApi = { * Filter criteria include a scenarioId or executableIdsList. Search by substring of configuration name is also possible. * * @param queryParameters - Object containing the following keys: scenarioId, $search, searchCaseInsensitive, executableIds. + * @param headerParameters - Object containing the following keys: AI-Resource-Group. * @returns The request builder, use the `execute()` method to trigger the request. */ - configurationCount: (queryParameters?: { - scenarioId?: string; - $search?: string; - searchCaseInsensitive?: boolean; - executableIds?: string[]; - }) => + configurationCount: ( + queryParameters: { + scenarioId?: string; + $search?: string; + searchCaseInsensitive?: boolean; + executableIds?: string[]; + }, + headerParameters: { 'AI-Resource-Group': string } + ) => new OpenApiRequestBuilder('get', '/lm/configurations/$count', { - queryParameters + queryParameters, + headerParameters }) }; diff --git a/packages/ai-core/src/deployment-api.test.ts b/packages/ai-core/src/deployment-api.test.ts new file mode 100644 index 00000000..a8860993 --- /dev/null +++ b/packages/ai-core/src/deployment-api.test.ts @@ -0,0 +1,167 @@ +import nock from 'nock'; +import { HttpDestination } from '@sap-cloud-sdk/connectivity'; +import { + DeploymentCreationRequest, + DeploymentCreationResponse, + DeploymentDeletionResponse, + DeploymentList, + DeploymentModificationRequest, + DeploymentApi, + DeploymentModificationResponse, + DeploymentTargetStatus +} from './index.js'; + +describe('deployment', () => { + const destination: HttpDestination = { + url: 'https://ai.example.com' + }; + + afterEach(() => { + nock.cleanAll(); + }); + + it('parses a successful response for get request', async () => { + const expectedResponse: DeploymentList = { + count: 1, + resources: [ + { + configurationId: '3d2c1b0a', + configurationName: 'gpt-4-32k', + createdAt: '2024-04-17T15:19:53Z', + deploymentUrl: + 'https://ai.example.com/inference/deployments/0a1b2c3d', + details: { + resources: { + backend_details: { + model: { + name: 'gpt-4-32k', + version: 'latest' + } + } + }, + scaling: { + backend_details: {} + } + }, + id: '0a1b2c3d', + lastOperation: 'CREATE', + latestRunningConfigurationId: '3d2c1b0a', + modifiedAt: '2024-05-07T13:05:45Z', + scenarioId: 'foundation-models', + startTime: '2024-04-17T15:21:15Z', + status: 'RUNNING', + submissionTime: '2024-04-17T15:20:11Z', + targetStatus: 'RUNNING' + } + ] + }; + + nock(destination.url, { + reqheaders: { + 'AI-Resource-Group': 'default' + } + }) + .get('/lm/deployments') + .reply(200, expectedResponse, { + 'Content-Type': 'application/json' + }); + + const result: DeploymentList = await DeploymentApi.deploymentQuery( + {}, + { 'AI-Resource-Group': 'default' } + ).execute(destination); + + expect(result).toEqual(expectedResponse); + }); + + it('parses a successful response for post request', async () => { + const expectedResponse: DeploymentCreationResponse = { + deploymentUrl: '', + id: '4e5f6g7h', + message: 'Deployment scheduled', + status: 'UNKNOWN' + }; + + nock(destination.url, { + reqheaders: { + 'AI-Resource-Group': 'default' + } + }) + .post('/lm/deployments') + .reply(200, expectedResponse, { + 'Content-Type': 'application/json' + }); + + const deploymentPostData: DeploymentCreationRequest = { + configurationId: '3d2c1b0a' + }; + + const result: DeploymentCreationResponse = + await DeploymentApi.deploymentCreate(deploymentPostData, { + 'AI-Resource-Group': 'default' + }).execute(destination); + + expect(result).toEqual(expectedResponse); + }); + + it('parses a successful response for patch request', async () => { + const deploymentId = '4e5f6g7h'; + const expectedRequestBody = { + targetStatus: 'STOPPED' + }; + const expectedResponse: DeploymentModificationResponse = { + id: '4e5f6g7h', + message: 'Deployment modification scheduled' + }; + nock(destination.url, { + reqheaders: { + 'AI-Resource-Group': 'default' + } + }) + .patch(`/lm/deployments/${deploymentId}`, body => { + expect(body).toEqual(expectedRequestBody); + expect(body).not.toHaveProperty('scenarioId'); + return true; + }) + .reply(200, expectedResponse, { + 'Content-Type': 'application/json' + }); + + const deploymentPatchData: DeploymentModificationRequest = { + targetStatus: 'STOPPED' as DeploymentTargetStatus + }; + + const result: DeploymentModificationResponse = + await DeploymentApi.deploymentModify(deploymentId, deploymentPatchData, { + 'AI-Resource-Group': 'default' + }).execute(destination); + + expect(result).toEqual(expectedResponse); + }); + + it('parses a successful response for delete request', async () => { + const deploymentId = '4e5f6g7h'; + const expectedResponse: DeploymentDeletionResponse = { + id: '4e5f6g7h', + message: 'Deletion scheduled', + targetStatus: 'DELETED' + }; + + nock(destination.url, { + reqheaders: { + 'AI-Resource-Group': 'default' + } + }) + .delete(`/lm/deployments/${deploymentId}`) + .reply(200, expectedResponse, { + 'Content-Type': 'application/json' + }); + + const result: DeploymentDeletionResponse = + await DeploymentApi.deploymentDelete(deploymentId, { + 'AI-Resource-Group': 'default' + }).execute(destination); + + expect(result).toEqual(expectedResponse); + }); +}); diff --git a/packages/ai-core/src/deployment-api.ts b/packages/ai-core/src/deployment-api.ts index 038cfc53..24bbad86 100644 --- a/packages/ai-core/src/deployment-api.ts +++ b/packages/ai-core/src/deployment-api.ts @@ -23,14 +23,19 @@ export const DeploymentApi = { /** * Create deployment. Deprecated, use POST /deployments instead * @param configurationId - Configuration identifier + * @param headerParameters - Object containing the following keys: AI-Resource-Group. * @returns The request builder, use the `execute()` method to trigger the request. */ - deploymentCreateDeprecated: (configurationId: string) => + deploymentCreateDeprecated: ( + configurationId: string, + headerParameters: { 'AI-Resource-Group': string } + ) => new OpenApiRequestBuilder( 'post', '/lm/configurations/{configurationId}/deployments', { - pathParameters: { configurationId } + pathParameters: { configurationId }, + headerParameters } ), /** @@ -40,100 +45,126 @@ export const DeploymentApi = { * With select parameter it is possible to select only status. * * @param queryParameters - Object containing the following keys: executableIds, configurationId, scenarioId, status, $top, $skip, $select. + * @param headerParameters - Object containing the following keys: AI-Resource-Group. * @returns The request builder, use the `execute()` method to trigger the request. */ - deploymentQuery: (queryParameters?: { - executableIds?: string[]; - configurationId?: string; - scenarioId?: string; - status?: - | 'PENDING' - | 'RUNNING' - | 'COMPLETED' - | 'DEAD' - | 'STOPPING' - | 'STOPPED' - | 'UNKNOWN'; - $top?: number; - $skip?: number; - $select?: 'status'; - }) => + deploymentQuery: ( + queryParameters: { + executableIds?: string[]; + configurationId?: string; + scenarioId?: string; + status?: + | 'PENDING' + | 'RUNNING' + | 'COMPLETED' + | 'DEAD' + | 'STOPPING' + | 'STOPPED' + | 'UNKNOWN'; + $top?: number; + $skip?: number; + $select?: 'status'; + }, + headerParameters: { 'AI-Resource-Group': string } + ) => new OpenApiRequestBuilder('get', '/lm/deployments', { - queryParameters + queryParameters, + headerParameters }), /** * Create a deployment using the configuration specified by configurationId. * @param body - Request body. + * @param headerParameters - Object containing the following keys: AI-Resource-Group. * @returns The request builder, use the `execute()` method to trigger the request. */ - deploymentCreate: (body: DeploymentCreationRequest) => + deploymentCreate: ( + body: DeploymentCreationRequest, + headerParameters: { 'AI-Resource-Group': string } + ) => new OpenApiRequestBuilder( 'post', '/lm/deployments', { - body + body, + headerParameters } ), /** * Update status of multiple deployments. stop or delete multiple deployments. * @param body - Request body. + * @param headerParameters - Object containing the following keys: AI-Resource-Group. * @returns The request builder, use the `execute()` method to trigger the request. */ - deploymentBatchModify: (body: any) => + deploymentBatchModify: ( + body: any, + headerParameters: { 'AI-Resource-Group': string } + ) => new OpenApiRequestBuilder( 'patch', '/lm/deployments', { - body + body, + headerParameters } ), /** * Retrieve details for execution with deploymentId. * @param deploymentId - Deployment identifier * @param queryParameters - Object containing the following keys: $select. + * @param headerParameters - Object containing the following keys: AI-Resource-Group. * @returns The request builder, use the `execute()` method to trigger the request. */ deploymentGet: ( deploymentId: string, - queryParameters?: { $select?: 'status' } + queryParameters: { $select?: 'status' }, + headerParameters: { 'AI-Resource-Group': string } ) => new OpenApiRequestBuilder( 'get', '/lm/deployments/{deploymentId}', { pathParameters: { deploymentId }, - queryParameters + queryParameters, + headerParameters } ), /** * Update target status of a deployment to stop a deployment or change the configuration to be used by the deployment. A change of configuration is only allowed for RUNNING and PENDING deployments. * @param deploymentId - Deployment identifier * @param body - Request body. + * @param headerParameters - Object containing the following keys: AI-Resource-Group. * @returns The request builder, use the `execute()` method to trigger the request. */ deploymentModify: ( deploymentId: string, - body: DeploymentModificationRequest + body: DeploymentModificationRequest, + headerParameters: { 'AI-Resource-Group': string } ) => new OpenApiRequestBuilder( 'patch', '/lm/deployments/{deploymentId}', { pathParameters: { deploymentId }, - body + body, + headerParameters } ), /** * Mark deployment with deploymentId as deleted. * @param deploymentId - Deployment identifier + * @param headerParameters - Object containing the following keys: AI-Resource-Group. * @returns The request builder, use the `execute()` method to trigger the request. */ - deploymentDelete: (deploymentId: string) => + deploymentDelete: ( + deploymentId: string, + headerParameters: { 'AI-Resource-Group': string } + ) => new OpenApiRequestBuilder( 'delete', '/lm/deployments/{deploymentId}', { - pathParameters: { deploymentId } + pathParameters: { deploymentId }, + headerParameters } ), /** @@ -141,28 +172,34 @@ export const DeploymentApi = { * scenarioId, configurationId, executableIdsList or by deployment status. * * @param queryParameters - Object containing the following keys: executableIds, configurationId, scenarioId, status. + * @param headerParameters - Object containing the following keys: AI-Resource-Group. * @returns The request builder, use the `execute()` method to trigger the request. */ - deploymentCount: (queryParameters?: { - executableIds?: string[]; - configurationId?: string; - scenarioId?: string; - status?: - | 'PENDING' - | 'RUNNING' - | 'COMPLETED' - | 'DEAD' - | 'STOPPING' - | 'STOPPED' - | 'UNKNOWN'; - }) => + deploymentCount: ( + queryParameters: { + executableIds?: string[]; + configurationId?: string; + scenarioId?: string; + status?: + | 'PENDING' + | 'RUNNING' + | 'COMPLETED' + | 'DEAD' + | 'STOPPING' + | 'STOPPED' + | 'UNKNOWN'; + }, + headerParameters: { 'AI-Resource-Group': string } + ) => new OpenApiRequestBuilder('get', '/lm/deployments/$count', { - queryParameters + queryParameters, + headerParameters }), /** * Retrieve logs of a deployment for getting insight into the deployment results or failures. * @param deploymentId - Deployment identifier * @param queryParameters - Object containing the following keys: $top, start, end, $order. + * @param headerParameters - Object containing the following keys: Authorization. * @returns The request builder, use the `execute()` method to trigger the request. */ kubesubmitV4DeploymentsGetLogs: ( @@ -172,14 +209,16 @@ export const DeploymentApi = { start?: string; end?: string; $order?: 'asc' | 'desc'; - } + }, + headerParameters?: { Authorization?: string } ) => new OpenApiRequestBuilder( 'get', '/lm/deployments/{deploymentId}/logs', { pathParameters: { deploymentId }, - queryParameters + queryParameters, + headerParameters } ) }; diff --git a/packages/ai-core/src/docker-registry-secret-api.ts b/packages/ai-core/src/docker-registry-secret-api.ts index 6fd18759..28355f78 100644 --- a/packages/ai-core/src/docker-registry-secret-api.ts +++ b/packages/ai-core/src/docker-registry-secret-api.ts @@ -21,14 +21,19 @@ export const DockerRegistrySecretApi = { * Retrieve the stored secret metadata which matches the parameter dockerRegistryName. The base64 encoded field for the stored secret is not returned. * * @param dockerRegistryName - Name of the docker Registry store for the secret. + * @param headerParameters - Object containing the following keys: Authorization. * @returns The request builder, use the `execute()` method to trigger the request. */ - kubesubmitV4DockerRegistrySecretsGet: (dockerRegistryName: string) => + kubesubmitV4DockerRegistrySecretsGet: ( + dockerRegistryName: string, + headerParameters?: { Authorization?: string } + ) => new OpenApiRequestBuilder( 'get', '/admin/dockerRegistrySecrets/{dockerRegistryName}', { - pathParameters: { dockerRegistryName } + pathParameters: { dockerRegistryName }, + headerParameters } ), /** @@ -36,63 +41,77 @@ export const DockerRegistrySecretApi = { * * @param dockerRegistryName - Name of the docker Registry store for the secret. * @param body - Request body. + * @param headerParameters - Object containing the following keys: Authorization. * @returns The request builder, use the `execute()` method to trigger the request. */ kubesubmitV4DockerRegistrySecretsPatch: ( dockerRegistryName: string, - body: any + body: any, + headerParameters?: { Authorization?: string } ) => new OpenApiRequestBuilder( 'patch', '/admin/dockerRegistrySecrets/{dockerRegistryName}', { pathParameters: { dockerRegistryName }, - body + body, + headerParameters } ), /** * Delete a secret with the name of dockerRegistryName if it exists. * @param dockerRegistryName - Name of the docker Registry store for the secret. + * @param headerParameters - Object containing the following keys: Authorization. * @returns The request builder, use the `execute()` method to trigger the request. */ - kubesubmitV4DockerRegistrySecretsDelete: (dockerRegistryName: string) => + kubesubmitV4DockerRegistrySecretsDelete: ( + dockerRegistryName: string, + headerParameters?: { Authorization?: string } + ) => new OpenApiRequestBuilder( 'delete', '/admin/dockerRegistrySecrets/{dockerRegistryName}', { - pathParameters: { dockerRegistryName } + pathParameters: { dockerRegistryName }, + headerParameters } ), /** * Retrieve a list of metadata of the stored secrets * * @param queryParameters - Object containing the following keys: $top, $skip, $count. + * @param headerParameters - Object containing the following keys: Authorization. * @returns The request builder, use the `execute()` method to trigger the request. */ - kubesubmitV4DockerRegistrySecretsQuery: (queryParameters?: { - $top?: number; - $skip?: number; - $count?: boolean; - }) => + kubesubmitV4DockerRegistrySecretsQuery: ( + queryParameters?: { $top?: number; $skip?: number; $count?: boolean }, + headerParameters?: { Authorization?: string } + ) => new OpenApiRequestBuilder( 'get', '/admin/dockerRegistrySecrets', { - queryParameters + queryParameters, + headerParameters } ), /** * Create a secret based on the configuration in the request body. * * @param body - Request body. + * @param headerParameters - Object containing the following keys: Authorization. * @returns The request builder, use the `execute()` method to trigger the request. */ - kubesubmitV4DockerRegistrySecretsCreate: (body: Body1) => + kubesubmitV4DockerRegistrySecretsCreate: ( + body: Body1, + headerParameters?: { Authorization?: string } + ) => new OpenApiRequestBuilder( 'post', '/admin/dockerRegistrySecrets', { - body + body, + headerParameters } ) }; diff --git a/packages/ai-core/src/executable-api.ts b/packages/ai-core/src/executable-api.ts index 4efd1916..513b301f 100644 --- a/packages/ai-core/src/executable-api.ts +++ b/packages/ai-core/src/executable-api.ts @@ -15,18 +15,21 @@ export const ExecutableApi = { * * @param scenarioId - Scenario identifier * @param queryParameters - Object containing the following keys: versionId. + * @param headerParameters - Object containing the following keys: AI-Resource-Group. * @returns The request builder, use the `execute()` method to trigger the request. */ executableQuery: ( scenarioId: string, - queryParameters?: { versionId?: string } + queryParameters: { versionId?: string }, + headerParameters: { 'AI-Resource-Group': string } ) => new OpenApiRequestBuilder( 'get', '/lm/scenarios/{scenarioId}/executables', { pathParameters: { scenarioId }, - queryParameters + queryParameters, + headerParameters } ), /** @@ -35,14 +38,20 @@ export const ExecutableApi = { * * @param scenarioId - Scenario identifier * @param executableId - Executable identifier + * @param headerParameters - Object containing the following keys: AI-Resource-Group. * @returns The request builder, use the `execute()` method to trigger the request. */ - executableGet: (scenarioId: string, executableId: string) => + executableGet: ( + scenarioId: string, + executableId: string, + headerParameters: { 'AI-Resource-Group': string } + ) => new OpenApiRequestBuilder( 'get', '/lm/scenarios/{scenarioId}/executables/{executableId}', { - pathParameters: { scenarioId, executableId } + pathParameters: { scenarioId, executableId }, + headerParameters } ) }; diff --git a/packages/ai-core/src/execution-api.test.ts b/packages/ai-core/src/execution-api.test.ts new file mode 100644 index 00000000..07914ef6 --- /dev/null +++ b/packages/ai-core/src/execution-api.test.ts @@ -0,0 +1,97 @@ +import nock from 'nock'; +import { HttpDestination } from '@sap-cloud-sdk/connectivity'; +import { + EnactmentCreationRequest, + ExecutionApi, + ExecutionCreationResponse, + ExecutionList +} from './index.js'; + +describe('execution', () => { + const destination: HttpDestination = { + url: 'https://ai.example.com' + }; + + afterEach(() => { + nock.cleanAll(); + }); + + it('parses a successful response for get request', async () => { + const expectedResponse: ExecutionList = { + count: 1, + resources: [ + { + completionTime: '2023-08-05T14:10:16Z', + configurationId: '3d2c1b0a', + configurationName: 'spam-detection-execution-config-0', + createdAt: '2023-08-05T14:07:52Z', + executableId: 'wt-spam-detection', + id: '0a1b2c3d', + modifiedAt: '2023-08-05T14:10:54Z', + outputArtifacts: [ + { + createdAt: '2023-08-05T14:10:05Z', + description: '', + executionId: '0a1b2c3d', + id: '4e5f6g7h', + kind: 'model', + modifiedAt: '2023-08-05T14:10:05Z', + name: 'classifier-model-output', + scenarioId: 'scenario-spam-detection', + url: 'ai://default/0a1b2c3d/classifier-model-output' + } + ], + scenarioId: 'scenario-spam-detection', + startTime: '2023-08-05T14:09:21Z', + status: 'COMPLETED', + submissionTime: '2023-08-05T14:09:21Z', + targetStatus: 'COMPLETED' + } + ] + }; + nock(destination.url, { + reqheaders: { + 'AI-Resource-Group': 'default' + } + }) + .get('/lm/executions') + .reply(200, expectedResponse, { + 'Content-Type': 'application/json' + }); + + const result: ExecutionList = await ExecutionApi.executionQuery( + {}, + { 'AI-Resource-Group': 'default' } + ).execute(destination); + + expect(result).toEqual(expectedResponse); + }); + + it('parses a successful response for post request', async () => { + const expectedResponse: ExecutionCreationResponse = { + id: '8i9j0k1l', + message: 'Execution acknowledged', + url: 'ai://default/8i9j0k1l' + }; + nock(destination.url, { + reqheaders: { + 'AI-Resource-Group': 'default' + } + }) + .post('/lm/executions') + .reply(200, expectedResponse, { + 'Content-Type': 'application/json' + }); + + const executionPostData: EnactmentCreationRequest = { + configurationId: '8i9j0k1l' + }; + + const result: ExecutionCreationResponse = + await ExecutionApi.executionCreate(executionPostData, { + 'AI-Resource-Group': 'default' + }).execute(destination); + + expect(result).toEqual(expectedResponse); + }); +}); diff --git a/packages/ai-core/src/execution-api.ts b/packages/ai-core/src/execution-api.ts index 12320d4b..835236e1 100644 --- a/packages/ai-core/src/execution-api.ts +++ b/packages/ai-core/src/execution-api.ts @@ -23,14 +23,19 @@ export const ExecutionApi = { /** * Trigger execution. Deprecated. Use POST /executions instead * @param configurationId - Configuration identifier + * @param headerParameters - Object containing the following keys: AI-Resource-Group. * @returns The request builder, use the `execute()` method to trigger the request. */ - executionCreateDeprecated: (configurationId: string) => + executionCreateDeprecated: ( + configurationId: string, + headerParameters: { 'AI-Resource-Group': string } + ) => new OpenApiRequestBuilder( 'post', '/lm/configurations/{configurationId}/executions', { - pathParameters: { configurationId } + pathParameters: { configurationId }, + headerParameters } ), /** @@ -40,98 +45,127 @@ export const ExecutionApi = { * With select parameter it is possible to select only status. * * @param queryParameters - Object containing the following keys: executableIds, configurationId, scenarioId, executionScheduleId, status, $top, $skip, $select. + * @param headerParameters - Object containing the following keys: AI-Resource-Group. * @returns The request builder, use the `execute()` method to trigger the request. */ - executionQuery: (queryParameters?: { - executableIds?: string[]; - configurationId?: string; - scenarioId?: string; - executionScheduleId?: string; - status?: - | 'PENDING' - | 'RUNNING' - | 'COMPLETED' - | 'DEAD' - | 'STOPPING' - | 'STOPPED' - | 'UNKNOWN'; - $top?: number; - $skip?: number; - $select?: 'status'; - }) => + executionQuery: ( + queryParameters: { + executableIds?: string[]; + configurationId?: string; + scenarioId?: string; + executionScheduleId?: string; + status?: + | 'PENDING' + | 'RUNNING' + | 'COMPLETED' + | 'DEAD' + | 'STOPPING' + | 'STOPPED' + | 'UNKNOWN'; + $top?: number; + $skip?: number; + $select?: 'status'; + }, + headerParameters: { 'AI-Resource-Group': string } + ) => new OpenApiRequestBuilder('get', '/lm/executions', { - queryParameters + queryParameters, + headerParameters }), /** * Create an execution using the configuration specified by configurationId. * @param body - Request body. + * @param headerParameters - Object containing the following keys: AI-Resource-Group. * @returns The request builder, use the `execute()` method to trigger the request. */ - executionCreate: (body: EnactmentCreationRequest) => + executionCreate: ( + body: EnactmentCreationRequest, + headerParameters: { 'AI-Resource-Group': string } + ) => new OpenApiRequestBuilder( 'post', '/lm/executions', { - body + body, + headerParameters } ), /** * Patch multiple executions' status to stopped or deleted. * @param body - Request body. + * @param headerParameters - Object containing the following keys: AI-Resource-Group. * @returns The request builder, use the `execute()` method to trigger the request. */ - executionBatchModify: (body: any) => + executionBatchModify: ( + body: any, + headerParameters: { 'AI-Resource-Group': string } + ) => new OpenApiRequestBuilder( 'patch', '/lm/executions', { - body + body, + headerParameters } ), /** * Retrieve details for execution with executionId. * @param executionId - Execution identifier * @param queryParameters - Object containing the following keys: $select. + * @param headerParameters - Object containing the following keys: AI-Resource-Group. * @returns The request builder, use the `execute()` method to trigger the request. */ executionGet: ( executionId: string, - queryParameters?: { $select?: 'status' } + queryParameters: { $select?: 'status' }, + headerParameters: { 'AI-Resource-Group': string } ) => new OpenApiRequestBuilder( 'get', '/lm/executions/{executionId}', { pathParameters: { executionId }, - queryParameters + queryParameters, + headerParameters } ), /** * Update target status of the execution to stop an execution. * @param executionId - Execution identifier * @param body - Request body. + * @param headerParameters - Object containing the following keys: AI-Resource-Group. * @returns The request builder, use the `execute()` method to trigger the request. */ - executionModify: (executionId: string, body: ExecutionModificationRequest) => + executionModify: ( + executionId: string, + body: ExecutionModificationRequest, + headerParameters: { 'AI-Resource-Group': string } + ) => new OpenApiRequestBuilder( 'patch', '/lm/executions/{executionId}', { pathParameters: { executionId }, - body + body, + headerParameters } ), /** * Mark the execution with executionId as deleted. * @param executionId - Execution identifier + * @param headerParameters - Object containing the following keys: AI-Resource-Group. * @returns The request builder, use the `execute()` method to trigger the request. */ - executionDelete: (executionId: string) => + executionDelete: ( + executionId: string, + headerParameters: { 'AI-Resource-Group': string } + ) => new OpenApiRequestBuilder( 'delete', '/lm/executions/{executionId}', { - pathParameters: { executionId } + pathParameters: { executionId }, + headerParameters } ), /** @@ -139,29 +173,35 @@ export const ExecutionApi = { * scenarioId, configurationId, executableIdsList or by execution status. * * @param queryParameters - Object containing the following keys: executableIds, configurationId, scenarioId, executionScheduleId, status. + * @param headerParameters - Object containing the following keys: AI-Resource-Group. * @returns The request builder, use the `execute()` method to trigger the request. */ - executionCount: (queryParameters?: { - executableIds?: string[]; - configurationId?: string; - scenarioId?: string; - executionScheduleId?: string; - status?: - | 'PENDING' - | 'RUNNING' - | 'COMPLETED' - | 'DEAD' - | 'STOPPING' - | 'STOPPED' - | 'UNKNOWN'; - }) => + executionCount: ( + queryParameters: { + executableIds?: string[]; + configurationId?: string; + scenarioId?: string; + executionScheduleId?: string; + status?: + | 'PENDING' + | 'RUNNING' + | 'COMPLETED' + | 'DEAD' + | 'STOPPING' + | 'STOPPED' + | 'UNKNOWN'; + }, + headerParameters: { 'AI-Resource-Group': string } + ) => new OpenApiRequestBuilder('get', '/lm/executions/$count', { - queryParameters + queryParameters, + headerParameters }), /** * Retrieve logs of an execution for getting insight into the execution results or failures. * @param executionId - Execution identifier * @param queryParameters - Object containing the following keys: $top, start, end, $order. + * @param headerParameters - Object containing the following keys: Authorization. * @returns The request builder, use the `execute()` method to trigger the request. */ kubesubmitV4ExecutionsGetLogs: ( @@ -171,14 +211,16 @@ export const ExecutionApi = { start?: string; end?: string; $order?: 'asc' | 'desc'; - } + }, + headerParameters?: { Authorization?: string } ) => new OpenApiRequestBuilder( 'get', '/lm/executions/{executionId}/logs', { pathParameters: { executionId }, - queryParameters + queryParameters, + headerParameters } ) }; diff --git a/packages/ai-core/src/execution-schedule-api.ts b/packages/ai-core/src/execution-schedule-api.ts index 6244647e..9563d827 100644 --- a/packages/ai-core/src/execution-schedule-api.ts +++ b/packages/ai-core/src/execution-schedule-api.ts @@ -24,76 +24,99 @@ export const ExecutionScheduleApi = { * With top/skip parameters it is possible to paginate the result list. * * @param queryParameters - Object containing the following keys: configurationId, status, $top, $skip. + * @param headerParameters - Object containing the following keys: AI-Resource-Group. * @returns The request builder, use the `execute()` method to trigger the request. */ - executionScheduleQuery: (queryParameters?: { - configurationId?: string; - status?: 'ACTIVE' | 'INACTIVE'; - $top?: number; - $skip?: number; - }) => + executionScheduleQuery: ( + queryParameters: { + configurationId?: string; + status?: 'ACTIVE' | 'INACTIVE'; + $top?: number; + $skip?: number; + }, + headerParameters: { 'AI-Resource-Group': string } + ) => new OpenApiRequestBuilder( 'get', '/lm/executionSchedules', { - queryParameters + queryParameters, + headerParameters } ), /** * Create an execution schedule using the configuration specified by configurationId, and schedule. * @param body - Request body. + * @param headerParameters - Object containing the following keys: AI-Resource-Group. * @returns The request builder, use the `execute()` method to trigger the request. */ - executionScheduleCreate: (body: ExecutionScheduleCreationData) => + executionScheduleCreate: ( + body: ExecutionScheduleCreationData, + headerParameters: { 'AI-Resource-Group': string } + ) => new OpenApiRequestBuilder( 'post', '/lm/executionSchedules', { - body + body, + headerParameters } ), /** * Retrieve details for execution schedule with executionScheduleId. * @param executionScheduleId - Execution Schedule identifier + * @param headerParameters - Object containing the following keys: AI-Resource-Group. * @returns The request builder, use the `execute()` method to trigger the request. */ - executionScheduleGet: (executionScheduleId: string) => + executionScheduleGet: ( + executionScheduleId: string, + headerParameters: { 'AI-Resource-Group': string } + ) => new OpenApiRequestBuilder( 'get', '/lm/executionSchedules/{executionScheduleId}', { - pathParameters: { executionScheduleId } + pathParameters: { executionScheduleId }, + headerParameters } ), /** * Update details of an execution schedule * @param executionScheduleId - Execution Schedule identifier * @param body - Request body. + * @param headerParameters - Object containing the following keys: AI-Resource-Group. * @returns The request builder, use the `execute()` method to trigger the request. */ executionScheduleModify: ( executionScheduleId: string, - body: ExecutionScheduleModificationRequest + body: ExecutionScheduleModificationRequest, + headerParameters: { 'AI-Resource-Group': string } ) => new OpenApiRequestBuilder( 'patch', '/lm/executionSchedules/{executionScheduleId}', { pathParameters: { executionScheduleId }, - body + body, + headerParameters } ), /** * Delete the execution schedule with executionScheduleId. * @param executionScheduleId - Execution Schedule identifier + * @param headerParameters - Object containing the following keys: AI-Resource-Group. * @returns The request builder, use the `execute()` method to trigger the request. */ - executionScheduleDelete: (executionScheduleId: string) => + executionScheduleDelete: ( + executionScheduleId: string, + headerParameters: { 'AI-Resource-Group': string } + ) => new OpenApiRequestBuilder( 'delete', '/lm/executionSchedules/{executionScheduleId}', { - pathParameters: { executionScheduleId } + pathParameters: { executionScheduleId }, + headerParameters } ), /** @@ -101,13 +124,18 @@ export const ExecutionScheduleApi = { * configurationId or executionScheduleStatus. * * @param queryParameters - Object containing the following keys: configurationId, status. + * @param headerParameters - Object containing the following keys: AI-Resource-Group. * @returns The request builder, use the `execute()` method to trigger the request. */ - executionScheduleCount: (queryParameters?: { - configurationId?: string; - status?: 'ACTIVE' | 'INACTIVE'; - }) => + executionScheduleCount: ( + queryParameters: { + configurationId?: string; + status?: 'ACTIVE' | 'INACTIVE'; + }, + headerParameters: { 'AI-Resource-Group': string } + ) => new OpenApiRequestBuilder('get', '/lm/executionSchedules/$count', { - queryParameters + queryParameters, + headerParameters }) }; diff --git a/packages/ai-core/src/file-api.ts b/packages/ai-core/src/file-api.ts index ba1620ea..91a41718 100644 --- a/packages/ai-core/src/file-api.ts +++ b/packages/ai-core/src/file-api.ts @@ -13,11 +13,16 @@ export const FileApi = { /** * Endpoint for downloading file. The path must point to an individual file. * @param path - path relative to the object store root URL in the secret + * @param headerParameters - Object containing the following keys: AI-Resource-Group. * @returns The request builder, use the `execute()` method to trigger the request. */ - fileDownload: (path: string) => + fileDownload: ( + path: string, + headerParameters?: { 'AI-Resource-Group'?: string } + ) => new OpenApiRequestBuilder('get', '/lm/dataset/files/{path}', { - pathParameters: { path } + pathParameters: { path }, + headerParameters }), /** * Endpoint for uploading file. The maximum file size depends on the actual implementation @@ -40,12 +45,14 @@ export const FileApi = { * @param path - path relative to the object store root URL in the secret * @param body - Body of the file upload request * @param queryParameters - Object containing the following keys: overwrite. + * @param headerParameters - Object containing the following keys: AI-Resource-Group. * @returns The request builder, use the `execute()` method to trigger the request. */ fileUpload: ( path: string, body: any | undefined, - queryParameters?: { overwrite?: boolean } + queryParameters?: { overwrite?: boolean }, + headerParameters?: { 'AI-Resource-Group'?: string } ) => new OpenApiRequestBuilder( 'put', @@ -53,16 +60,22 @@ export const FileApi = { { pathParameters: { path }, body, - queryParameters + queryParameters, + headerParameters } ), /** * Delete the file specified by the path parameter. * @param path - path relative to the object store root URL in the secret + * @param headerParameters - Object containing the following keys: AI-Resource-Group. * @returns The request builder, use the `execute()` method to trigger the request. */ - fileDelete: (path: string) => + fileDelete: ( + path: string, + headerParameters?: { 'AI-Resource-Group'?: string } + ) => new OpenApiRequestBuilder('delete', '/lm/dataset/files/{path}', { - pathParameters: { path } + pathParameters: { path }, + headerParameters }) }; diff --git a/packages/ai-core/src/metrics-api.ts b/packages/ai-core/src/metrics-api.ts index db47dbb2..ca4a923a 100644 --- a/packages/ai-core/src/metrics-api.ts +++ b/packages/ai-core/src/metrics-api.ts @@ -22,33 +22,48 @@ export const MetricsApi = { * Use up to 10 execution IDs in a query parameter. * * @param queryParameters - Object containing the following keys: $filter, executionIds, $select. + * @param headerParameters - Object containing the following keys: AI-Resource-Group. * @returns The request builder, use the `execute()` method to trigger the request. */ - metricsFind: (queryParameters?: { - $filter?: string; - executionIds?: StringArray; - $select?: MetricSelectorPermissibleValues; - }) => + metricsFind: ( + queryParameters: { + $filter?: string; + executionIds?: StringArray; + $select?: MetricSelectorPermissibleValues; + }, + headerParameters: { 'AI-Resource-Group': string } + ) => new OpenApiRequestBuilder('get', '/lm/metrics', { - queryParameters + queryParameters, + headerParameters }), /** * Update or create metrics, tags, or labels associated with an execution. * * @param body - Request body. + * @param headerParameters - Object containing the following keys: AI-Resource-Group. * @returns The request builder, use the `execute()` method to trigger the request. */ - metricsPatch: (body: any) => + metricsPatch: ( + body: any, + headerParameters: { 'AI-Resource-Group': string } + ) => new OpenApiRequestBuilder('patch', '/lm/metrics', { - body + body, + headerParameters }), /** * Delete metrics, tags, or labels associated with an execution. * @param queryParameters - Object containing the following keys: executionId. + * @param headerParameters - Object containing the following keys: AI-Resource-Group. * @returns The request builder, use the `execute()` method to trigger the request. */ - metricsDelete: (queryParameters: { executionId: ExecutionId2 }) => + metricsDelete: ( + queryParameters: { executionId: ExecutionId2 }, + headerParameters: { 'AI-Resource-Group': string } + ) => new OpenApiRequestBuilder('delete', '/lm/metrics', { - queryParameters + queryParameters, + headerParameters }) }; diff --git a/packages/ai-core/src/object-store-secret-api.ts b/packages/ai-core/src/object-store-secret-api.ts index c57be207..61f9788f 100644 --- a/packages/ai-core/src/object-store-secret-api.ts +++ b/packages/ai-core/src/object-store-secret-api.ts @@ -22,34 +22,38 @@ export const ObjectStoreSecretApi = { * Retrieve a list of metadata of the stored secrets. * * @param queryParameters - Object containing the following keys: $top, $skip, $count. + * @param headerParameters - Object containing the following keys: Authorization, AI-Resource-Group. * @returns The request builder, use the `execute()` method to trigger the request. */ - kubesubmitV4ObjectStoreSecretsQuery: (queryParameters?: { - $top?: number; - $skip?: number; - $count?: boolean; - }) => + kubesubmitV4ObjectStoreSecretsQuery: ( + queryParameters?: { $top?: number; $skip?: number; $count?: boolean }, + headerParameters?: { Authorization?: string; 'AI-Resource-Group'?: string } + ) => new OpenApiRequestBuilder( 'get', '/admin/objectStoreSecrets', { - queryParameters + queryParameters, + headerParameters } ), /** * Create a secret based on the configuration in the request body * * @param body - Request body. + * @param headerParameters - Object containing the following keys: Authorization, AI-Resource-Group. * @returns The request builder, use the `execute()` method to trigger the request. */ kubesubmitV4ObjectStoreSecretsCreate: ( - body: ObjectStoreSecretWithSensitiveDataRequestForPostCall + body: ObjectStoreSecretWithSensitiveDataRequestForPostCall, + headerParameters?: { Authorization?: string; 'AI-Resource-Group'?: string } ) => new OpenApiRequestBuilder( 'post', '/admin/objectStoreSecrets', { - body + body, + headerParameters } ), /** @@ -58,14 +62,19 @@ export const ObjectStoreSecretApi = { * The base64 encoded field for the stored secret is not returned. * * @param objectStoreName - Name of the object store for the secret. + * @param headerParameters - Object containing the following keys: Authorization, AI-Resource-Group. * @returns The request builder, use the `execute()` method to trigger the request. */ - kubesubmitV4ObjectStoreSecretsGet: (objectStoreName: string) => + kubesubmitV4ObjectStoreSecretsGet: ( + objectStoreName: string, + headerParameters?: { Authorization?: string; 'AI-Resource-Group'?: string } + ) => new OpenApiRequestBuilder( 'get', '/admin/objectStoreSecrets/{objectStoreName}', { - pathParameters: { objectStoreName } + pathParameters: { objectStoreName }, + headerParameters } ), /** @@ -73,31 +82,39 @@ export const ObjectStoreSecretApi = { * * @param objectStoreName - Name of the object store for the secret. * @param body - Request body. + * @param headerParameters - Object containing the following keys: Authorization, AI-Resource-Group. * @returns The request builder, use the `execute()` method to trigger the request. */ kubesubmitV4ObjectStoreSecretsPatch: ( objectStoreName: string, - body: ObjectStoreSecretWithSensitiveDataRequest + body: ObjectStoreSecretWithSensitiveDataRequest, + headerParameters?: { Authorization?: string; 'AI-Resource-Group'?: string } ) => new OpenApiRequestBuilder( 'patch', '/admin/objectStoreSecrets/{objectStoreName}', { pathParameters: { objectStoreName }, - body + body, + headerParameters } ), /** * Delete a secret with the name of objectStoreName if it exists. * @param objectStoreName - Name of the object store for the secret. + * @param headerParameters - Object containing the following keys: Authorization, AI-Resource-Group. * @returns The request builder, use the `execute()` method to trigger the request. */ - kubesubmitV4ObjectStoreSecretsDelete: (objectStoreName: string) => + kubesubmitV4ObjectStoreSecretsDelete: ( + objectStoreName: string, + headerParameters?: { Authorization?: string; 'AI-Resource-Group'?: string } + ) => new OpenApiRequestBuilder( 'delete', '/admin/objectStoreSecrets/{objectStoreName}', { - pathParameters: { objectStoreName } + pathParameters: { objectStoreName }, + headerParameters } ) }; diff --git a/packages/ai-core/src/repository-api.ts b/packages/ai-core/src/repository-api.ts index d3a8d524..f0bdbc93 100644 --- a/packages/ai-core/src/repository-api.ts +++ b/packages/ai-core/src/repository-api.ts @@ -21,44 +21,55 @@ export const RepositoryApi = { /** * Retrieve a list of all GitOps repositories for a tenant. * @param queryParameters - Object containing the following keys: $top, $skip, $count. + * @param headerParameters - Object containing the following keys: Authorization. * @returns The request builder, use the `execute()` method to trigger the request. */ - kubesubmitV4RepositoriesGetAll: (queryParameters?: { - $top?: number; - $skip?: number; - $count?: boolean; - }) => + kubesubmitV4RepositoriesGetAll: ( + queryParameters?: { $top?: number; $skip?: number; $count?: boolean }, + headerParameters?: { Authorization?: string } + ) => new OpenApiRequestBuilder( 'get', '/admin/repositories', { - queryParameters + queryParameters, + headerParameters } ), /** * On-board a new GitOps repository as specified in the content payload * @param body - Request body. + * @param headerParameters - Object containing the following keys: Authorization. * @returns The request builder, use the `execute()` method to trigger the request. */ - kubesubmitV4RepositoriesCreate: (body: ArgoCDRepositoryData) => + kubesubmitV4RepositoriesCreate: ( + body: ArgoCDRepositoryData, + headerParameters?: { Authorization?: string } + ) => new OpenApiRequestBuilder( 'post', '/admin/repositories', { - body + body, + headerParameters } ), /** * Retrieve the access details for a repository if it exists. * @param repositoryName - Name of the repository + * @param headerParameters - Object containing the following keys: Authorization. * @returns The request builder, use the `execute()` method to trigger the request. */ - kubesubmitV4RepositoriesGet: (repositoryName: string) => + kubesubmitV4RepositoriesGet: ( + repositoryName: string, + headerParameters?: { Authorization?: string } + ) => new OpenApiRequestBuilder( 'get', '/admin/repositories/{repositoryName}', { - pathParameters: { repositoryName } + pathParameters: { repositoryName }, + headerParameters } ), /** @@ -66,31 +77,39 @@ export const RepositoryApi = { * * @param repositoryName - Name of the repository * @param body - Request body. + * @param headerParameters - Object containing the following keys: Authorization. * @returns The request builder, use the `execute()` method to trigger the request. */ kubesubmitV4RepositoriesUpdate: ( repositoryName: string, - body: ArgoCDRepositoryCredentials + body: ArgoCDRepositoryCredentials, + headerParameters?: { Authorization?: string } ) => new OpenApiRequestBuilder( 'patch', '/admin/repositories/{repositoryName}', { pathParameters: { repositoryName }, - body + body, + headerParameters } ), /** * Remove a repository from GitOps. * @param repositoryName - Name of the repository + * @param headerParameters - Object containing the following keys: Authorization. * @returns The request builder, use the `execute()` method to trigger the request. */ - kubesubmitV4RepositoriesDelete: (repositoryName: string) => + kubesubmitV4RepositoriesDelete: ( + repositoryName: string, + headerParameters?: { Authorization?: string } + ) => new OpenApiRequestBuilder( 'delete', '/admin/repositories/{repositoryName}', { - pathParameters: { repositoryName } + pathParameters: { repositoryName }, + headerParameters } ) }; diff --git a/packages/ai-core/src/resource-api.ts b/packages/ai-core/src/resource-api.ts index 62876cf3..39445fe1 100644 --- a/packages/ai-core/src/resource-api.ts +++ b/packages/ai-core/src/resource-api.ts @@ -16,24 +16,33 @@ import type { export const ResourceApi = { /** * Lists all hot spare nodes, used nodes and total nodes corresponding to tenant. + * @param headerParameters - Object containing the following keys: Authorization. * @returns The request builder, use the `execute()` method to trigger the request. */ - kubesubmitV4ResourcesGet: () => + kubesubmitV4ResourcesGet: (headerParameters?: { Authorization?: string }) => new OpenApiRequestBuilder( 'get', - '/admin/resources/nodes' + '/admin/resources/nodes', + { + headerParameters + } ), /** * Set hot spare nodes corresponding to tenant at main tenant level. * @param body - Request body. + * @param headerParameters - Object containing the following keys: Authorization. * @returns The request builder, use the `execute()` method to trigger the request. */ - kubesubmitV4ResourcesPatch: (body: ResourcePatchBody) => + kubesubmitV4ResourcesPatch: ( + body: ResourcePatchBody, + headerParameters?: { Authorization?: string } + ) => new OpenApiRequestBuilder( 'patch', '/admin/resources/nodes', { - body + body, + headerParameters } ) }; diff --git a/packages/ai-core/src/resource-group-api.ts b/packages/ai-core/src/resource-group-api.ts index 4f233c52..7f235723 100644 --- a/packages/ai-core/src/resource-group-api.ts +++ b/packages/ai-core/src/resource-group-api.ts @@ -21,48 +21,63 @@ export const ResourceGroupApi = { * Retrieve a list of resource groups for a given tenant. * * @param queryParameters - Object containing the following keys: $top, $skip, $count, continueToken, labelSelector. + * @param headerParameters - Object containing the following keys: Authorization, Prefer. * @returns The request builder, use the `execute()` method to trigger the request. */ - kubesubmitV4ResourcegroupsGetAll: (queryParameters?: { - $top?: number; - $skip?: number; - $count?: boolean; - continueToken?: string; - labelSelector?: string[]; - }) => + kubesubmitV4ResourcegroupsGetAll: ( + queryParameters?: { + $top?: number; + $skip?: number; + $count?: boolean; + continueToken?: string; + labelSelector?: string[]; + }, + headerParameters?: { Authorization?: string; Prefer?: string } + ) => new OpenApiRequestBuilder( 'get', '/admin/resourceGroups', { - queryParameters + queryParameters, + headerParameters } ), /** * Create resource group to a given main tenant. The length of resource group id must be between 3 and 253. * * @param body - Request body. + * @param headerParameters - Object containing the following keys: Authorization. * @returns The request builder, use the `execute()` method to trigger the request. */ - kubesubmitV4ResourcegroupsCreate: (body: ResourceGroupsPostRequest) => + kubesubmitV4ResourcegroupsCreate: ( + body: ResourceGroupsPostRequest, + headerParameters?: { Authorization?: string } + ) => new OpenApiRequestBuilder( 'post', '/admin/resourceGroups', { - body + body, + headerParameters } ), /** * Get a resource group of a given main tenant. * * @param resourceGroupId - Resource group identifier + * @param headerParameters - Object containing the following keys: Authorization. * @returns The request builder, use the `execute()` method to trigger the request. */ - kubesubmitV4ResourcegroupsGet: (resourceGroupId: string) => + kubesubmitV4ResourcegroupsGet: ( + resourceGroupId: string, + headerParameters?: { Authorization?: string } + ) => new OpenApiRequestBuilder( 'get', '/admin/resourceGroups/{resourceGroupId}', { - pathParameters: { resourceGroupId } + pathParameters: { resourceGroupId }, + headerParameters } ), /** @@ -70,32 +85,40 @@ export const ResourceGroupApi = { * * @param resourceGroupId - Resource group identifier * @param body - Request body. + * @param headerParameters - Object containing the following keys: Authorization. * @returns The request builder, use the `execute()` method to trigger the request. */ kubesubmitV4ResourcegroupsPatch: ( resourceGroupId: string, - body: ResourceGroupPatchRequest + body: ResourceGroupPatchRequest, + headerParameters?: { Authorization?: string } ) => new OpenApiRequestBuilder( 'patch', '/admin/resourceGroups/{resourceGroupId}', { pathParameters: { resourceGroupId }, - body + body, + headerParameters } ), /** * Delete a resource group of a given main tenant. * * @param resourceGroupId - Resource group identifier + * @param headerParameters - Object containing the following keys: Authorization. * @returns The request builder, use the `execute()` method to trigger the request. */ - kubesubmitV4ResourcegroupsDelete: (resourceGroupId: string) => + kubesubmitV4ResourcegroupsDelete: ( + resourceGroupId: string, + headerParameters?: { Authorization?: string } + ) => new OpenApiRequestBuilder( 'delete', '/admin/resourceGroups/{resourceGroupId}', { - pathParameters: { resourceGroupId } + pathParameters: { resourceGroupId }, + headerParameters } ) }; diff --git a/packages/ai-core/src/resource-quota-api.ts b/packages/ai-core/src/resource-quota-api.ts index 211014dd..85eb2659 100644 --- a/packages/ai-core/src/resource-quota-api.ts +++ b/packages/ai-core/src/resource-quota-api.ts @@ -16,91 +16,109 @@ export const ResourceQuotaApi = { /** * Get the details about quota and usage for resource groups * @param queryParameters - Object containing the following keys: quotaOnly. + * @param headerParameters - Object containing the following keys: Authorization. * @returns The request builder, use the `execute()` method to trigger the request. */ - kubesubmitV4ResourceQuotaGetResourceGroupQuota: (queryParameters?: { - quotaOnly?: boolean; - }) => + kubesubmitV4ResourceQuotaGetResourceGroupQuota: ( + queryParameters?: { quotaOnly?: boolean }, + headerParameters?: { Authorization?: string } + ) => new OpenApiRequestBuilder( 'get', '/admin/resourceQuota/resourceGroups', { - queryParameters + queryParameters, + headerParameters } ), /** * Get the details about quota and usage for executables * @param queryParameters - Object containing the following keys: quotaOnly. + * @param headerParameters - Object containing the following keys: Authorization. * @returns The request builder, use the `execute()` method to trigger the request. */ - kubesubmitV4ResourceQuotaGetExecutableQuota: (queryParameters?: { - quotaOnly?: boolean; - }) => + kubesubmitV4ResourceQuotaGetExecutableQuota: ( + queryParameters?: { quotaOnly?: boolean }, + headerParameters?: { Authorization?: string } + ) => new OpenApiRequestBuilder( 'get', '/admin/resourceQuota/executables', { - queryParameters + queryParameters, + headerParameters } ), /** * Get the details about quota and usage for applications * @param queryParameters - Object containing the following keys: quotaOnly. + * @param headerParameters - Object containing the following keys: Authorization. * @returns The request builder, use the `execute()` method to trigger the request. */ - kubesubmitV4ResourceQuotaGetApplicationQuota: (queryParameters?: { - quotaOnly?: boolean; - }) => + kubesubmitV4ResourceQuotaGetApplicationQuota: ( + queryParameters?: { quotaOnly?: boolean }, + headerParameters?: { Authorization?: string } + ) => new OpenApiRequestBuilder( 'get', '/admin/resourceQuota/applications', { - queryParameters + queryParameters, + headerParameters } ), /** * Get the details about quota and usage for repositories * @param queryParameters - Object containing the following keys: quotaOnly. + * @param headerParameters - Object containing the following keys: Authorization. * @returns The request builder, use the `execute()` method to trigger the request. */ - kubesubmitV4ResourceQuotaGetRepositoryQuota: (queryParameters?: { - quotaOnly?: boolean; - }) => + kubesubmitV4ResourceQuotaGetRepositoryQuota: ( + queryParameters?: { quotaOnly?: boolean }, + headerParameters?: { Authorization?: string } + ) => new OpenApiRequestBuilder( 'get', '/admin/resourceQuota/repositories', { - queryParameters + queryParameters, + headerParameters } ), /** * Get the details about quota and usage for tenant-level generic secrets * @param queryParameters - Object containing the following keys: quotaOnly. + * @param headerParameters - Object containing the following keys: Authorization. * @returns The request builder, use the `execute()` method to trigger the request. */ - kubesubmitV4ResourceQuotaGetGenericSecretQuota: (queryParameters?: { - quotaOnly?: boolean; - }) => + kubesubmitV4ResourceQuotaGetGenericSecretQuota: ( + queryParameters?: { quotaOnly?: boolean }, + headerParameters?: { Authorization?: string } + ) => new OpenApiRequestBuilder( 'get', '/admin/resourceQuota/secrets', { - queryParameters + queryParameters, + headerParameters } ), /** * Get the details about quota and usage for docker registry secrets * @param queryParameters - Object containing the following keys: quotaOnly. + * @param headerParameters - Object containing the following keys: Authorization. * @returns The request builder, use the `execute()` method to trigger the request. */ - kubesubmitV4ResourceQuotaGetDockerRegistrySecretQuota: (queryParameters?: { - quotaOnly?: boolean; - }) => + kubesubmitV4ResourceQuotaGetDockerRegistrySecretQuota: ( + queryParameters?: { quotaOnly?: boolean }, + headerParameters?: { Authorization?: string } + ) => new OpenApiRequestBuilder( 'get', '/admin/resourceQuota/dockerRegistrySecrets', { - queryParameters + queryParameters, + headerParameters } ) }; diff --git a/packages/ai-core/src/scenario-api.test.ts b/packages/ai-core/src/scenario-api.test.ts new file mode 100644 index 00000000..e7764b42 --- /dev/null +++ b/packages/ai-core/src/scenario-api.test.ts @@ -0,0 +1,49 @@ +import nock from 'nock'; +import { HttpDestination } from '@sap-cloud-sdk/connectivity'; +import { ScenarioApi, ScenarioList } from './index.js'; + +describe('scenario', () => { + const destination: HttpDestination = { + url: 'https://ai.example.com' + }; + + afterEach(() => { + nock.cleanAll(); + }); + + it('parses a successful response for get request', async () => { + const expectedResponse: ScenarioList = { + count: 1, + resources: [ + { + createdAt: '2024-02-22T17:57:23+00:00', + description: 'AI Core Global Scenario for LLM Access', + id: 'foundation-models', + labels: [ + { + key: 'scenarios.example.com/llm', + value: 'true' + } + ], + modifiedAt: '2024-05-08T08:41:23+00:00', + name: 'foundation-models' + } + ] + }; + nock(destination.url, { + reqheaders: { + 'AI-Resource-Group': 'default' + } + }) + .get('/lm/scenarios') + .reply(200, expectedResponse, { + 'Content-Type': 'application/json' + }); + + const result: ScenarioList = await ScenarioApi.scenarioQuery({ + 'AI-Resource-Group': 'default' + }).execute(destination); + + expect(result).toEqual(expectedResponse); + }); +}); diff --git a/packages/ai-core/src/scenario-api.ts b/packages/ai-core/src/scenario-api.ts index 64cf510a..4af6a914 100644 --- a/packages/ai-core/src/scenario-api.ts +++ b/packages/ai-core/src/scenario-api.ts @@ -12,18 +12,26 @@ import type { ScenarioList, Scenario, VersionList } from './schema/index.js'; export const ScenarioApi = { /** * Retrieve a list of all available scenarios. + * @param headerParameters - Object containing the following keys: AI-Resource-Group. * @returns The request builder, use the `execute()` method to trigger the request. */ - scenarioQuery: () => - new OpenApiRequestBuilder('get', '/lm/scenarios'), + scenarioQuery: (headerParameters: { 'AI-Resource-Group': string }) => + new OpenApiRequestBuilder('get', '/lm/scenarios', { + headerParameters + }), /** * Retrieve details for a scenario specified by scenarioId. * @param scenarioId - Scenario identifier + * @param headerParameters - Object containing the following keys: AI-Resource-Group. * @returns The request builder, use the `execute()` method to trigger the request. */ - scenarioGet: (scenarioId: string) => + scenarioGet: ( + scenarioId: string, + headerParameters: { 'AI-Resource-Group': string } + ) => new OpenApiRequestBuilder('get', '/lm/scenarios/{scenarioId}', { - pathParameters: { scenarioId } + pathParameters: { scenarioId }, + headerParameters }), /** * Retrieve a list of scenario versions based on the versions of executables @@ -31,18 +39,21 @@ export const ScenarioApi = { * * @param scenarioId - Scenario identifier * @param queryParameters - Object containing the following keys: labelSelector. + * @param headerParameters - Object containing the following keys: AI-Resource-Group. * @returns The request builder, use the `execute()` method to trigger the request. */ scenarioQueryVersions: ( scenarioId: string, - queryParameters?: { labelSelector?: string[] } + queryParameters: { labelSelector?: string[] }, + headerParameters: { 'AI-Resource-Group': string } ) => new OpenApiRequestBuilder( 'get', '/lm/scenarios/{scenarioId}/versions', { pathParameters: { scenarioId }, - queryParameters + queryParameters, + headerParameters } ) }; diff --git a/packages/ai-core/src/secret-api.ts b/packages/ai-core/src/secret-api.ts index 347e15f3..886ab137 100644 --- a/packages/ai-core/src/secret-api.ts +++ b/packages/ai-core/src/secret-api.ts @@ -18,58 +18,88 @@ export const SecretApi = { /** * Lists all secrets corresponding to tenant. This retrieves metadata only, not the secret data itself. * @param queryParameters - Object containing the following keys: $top, $skip, $count. + * @param headerParameters - Object containing the following keys: Authorization, AI-Resource-Group, AI-Tenant-Scope. * @returns The request builder, use the `execute()` method to trigger the request. */ - kubesubmitV4GenericSecretsGet: (queryParameters?: { - $top?: number; - $skip?: number; - $count?: boolean; - }) => + kubesubmitV4GenericSecretsGet: ( + queryParameters?: { $top?: number; $skip?: number; $count?: boolean }, + headerParameters?: { + Authorization?: string; + 'AI-Resource-Group'?: string; + 'AI-Tenant-Scope'?: boolean; + } + ) => new OpenApiRequestBuilder( 'get', '/admin/secrets', { - queryParameters + queryParameters, + headerParameters } ), /** * Create a new generic secret in the corresponding resource group or at main tenant level. * @param body - Request body. + * @param headerParameters - Object containing the following keys: Authorization, AI-Resource-Group, AI-Tenant-Scope. * @returns The request builder, use the `execute()` method to trigger the request. */ - kubesubmitV4GenericSecretsCreate: (body: GenericSecretPostBody) => + kubesubmitV4GenericSecretsCreate: ( + body: GenericSecretPostBody, + headerParameters?: { + Authorization?: string; + 'AI-Resource-Group'?: string; + 'AI-Tenant-Scope'?: boolean; + } + ) => new OpenApiRequestBuilder( 'post', '/admin/secrets', { - body + body, + headerParameters } ), /** * Update secret credentials. Replace secret data with the provided data. * @param secretName - Path parameter. * @param body - Request body. + * @param headerParameters - Object containing the following keys: Authorization, AI-Resource-Group, AI-Tenant-Scope. * @returns The request builder, use the `execute()` method to trigger the request. */ kubesubmitV4GenericSecretsUpdate: ( secretName: string, - body: GenericSecretPatchBody + body: GenericSecretPatchBody, + headerParameters?: { + Authorization?: string; + 'AI-Resource-Group'?: string; + 'AI-Tenant-Scope'?: boolean; + } ) => new OpenApiRequestBuilder( 'patch', '/admin/secrets/{secretName}', { pathParameters: { secretName }, - body + body, + headerParameters } ), /** * Deletes the secret from provided resource group namespace * @param secretName - Path parameter. + * @param headerParameters - Object containing the following keys: Authorization, AI-Resource-Group, AI-Tenant-Scope. * @returns The request builder, use the `execute()` method to trigger the request. */ - kubesubmitV4GenericSecretsDelete: (secretName: string) => + kubesubmitV4GenericSecretsDelete: ( + secretName: string, + headerParameters?: { + Authorization?: string; + 'AI-Resource-Group'?: string; + 'AI-Tenant-Scope'?: boolean; + } + ) => new OpenApiRequestBuilder('delete', '/admin/secrets/{secretName}', { - pathParameters: { secretName } + pathParameters: { secretName }, + headerParameters }) }; diff --git a/packages/ai-core/src/service-api.ts b/packages/ai-core/src/service-api.ts index 2fc9622a..706043f5 100644 --- a/packages/ai-core/src/service-api.ts +++ b/packages/ai-core/src/service-api.ts @@ -13,22 +13,32 @@ export const ServiceApi = { /** * Retrieve a list of services for a given main tenant. * + * @param headerParameters - Object containing the following keys: Authorization. * @returns The request builder, use the `execute()` method to trigger the request. */ - kubesubmitV4AiservicesGetAll: () => - new OpenApiRequestBuilder('get', '/admin/services'), + kubesubmitV4AiservicesGetAll: (headerParameters?: { + Authorization?: string; + }) => + new OpenApiRequestBuilder('get', '/admin/services', { + headerParameters + }), /** * Get an service of a given main tenant. * * @param serviceName - Name of the Service + * @param headerParameters - Object containing the following keys: Authorization. * @returns The request builder, use the `execute()` method to trigger the request. */ - kubesubmitV4AiservicesGet: (serviceName: string) => + kubesubmitV4AiservicesGet: ( + serviceName: string, + headerParameters?: { Authorization?: string } + ) => new OpenApiRequestBuilder( 'get', '/admin/services/{serviceName}', { - pathParameters: { serviceName } + pathParameters: { serviceName }, + headerParameters } ) };