Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
72 changes: 72 additions & 0 deletions packages_generated/qaas/src/v1alpha1/api.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import {
} from './content.gen'
import {
marshalCreateJobRequest,
marshalCreateModelRequest,
marshalCreateProcessRequest,
marshalCreateSessionRequest,
marshalUpdateBookingRequest,
Expand All @@ -32,11 +33,13 @@ import {
unmarshalListBookingsResponse,
unmarshalListJobResultsResponse,
unmarshalListJobsResponse,
unmarshalListModelsResponse,
unmarshalListPlatformsResponse,
unmarshalListProcessesResponse,
unmarshalListProcessResultsResponse,
unmarshalListSessionACLsResponse,
unmarshalListSessionsResponse,
unmarshalModel,
unmarshalPlatform,
unmarshalProcess,
unmarshalSession,
Expand All @@ -47,6 +50,7 @@ import type {
CancelJobRequest,
CancelProcessRequest,
CreateJobRequest,
CreateModelRequest,
CreateProcessRequest,
CreateSessionRequest,
DeleteJobRequest,
Expand All @@ -56,6 +60,7 @@ import type {
GetBookingRequest,
GetJobCircuitRequest,
GetJobRequest,
GetModelRequest,
GetPlatformRequest,
GetProcessRequest,
GetSessionRequest,
Expand All @@ -69,6 +74,8 @@ import type {
ListJobResultsResponse,
ListJobsRequest,
ListJobsResponse,
ListModelsRequest,
ListModelsResponse,
ListPlatformsRequest,
ListPlatformsResponse,
ListProcessesRequest,
Expand All @@ -79,6 +86,7 @@ import type {
ListSessionACLsResponse,
ListSessionsRequest,
ListSessionsResponse,
Model,
Platform,
Process,
Session,
Expand Down Expand Up @@ -784,4 +792,68 @@ export class API extends ParentAPI {
},
unmarshalBooking,
)

/**
* Create a new model. Create and register a new model that can be executed through next jobs. A model can also be assigned to a Session.
*
* @param request - The request {@link CreateModelRequest}
* @returns A Promise of Model
*/
createModel = (request: Readonly<CreateModelRequest> = {}) =>
this.client.fetch<Model>(
{
body: JSON.stringify(
marshalCreateModelRequest(request, this.client.settings),
),
headers: jsonContentHeaders,
method: 'POST',
path: `/qaas/v1alpha1/models`,
},
unmarshalModel,
)

/**
* Get model information. Retrieve information about of the provided **model ID**.
*
* @param request - The request {@link GetModelRequest}
* @returns A Promise of Model
*/
getModel = (request: Readonly<GetModelRequest>) =>
this.client.fetch<Model>(
{
method: 'GET',
path: `/qaas/v1alpha1/models/${validatePathParam('modelId', request.modelId)}`,
},
unmarshalModel,
)

protected pageOfListModels = (request: Readonly<ListModelsRequest> = {}) =>
this.client.fetch<ListModelsResponse>(
{
method: 'GET',
path: `/qaas/v1alpha1/models`,
urlParams: urlParams(
['order_by', request.orderBy],
['page', request.page],
[
'page_size',
request.pageSize ?? this.client.settings.defaultPageSize,
],
[
'project_id',
request.projectId ?? this.client.settings.defaultProjectId,
],
),
},
unmarshalListModelsResponse,
)

/**
* List all models attached to the **project ID**. Retrieve information about all models of the provided **project ID**.
*
* @param request - The request {@link ListModelsRequest}
* @returns A Promise of ListModelsResponse
*/
listModels = (request: Readonly<ListModelsRequest> = {}) =>
enrichForPagination('models', this.pageOfListModels, request)
}
6 changes: 6 additions & 0 deletions packages_generated/qaas/src/v1alpha1/index.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export type {
CancelJobRequest,
CancelProcessRequest,
CreateJobRequest,
CreateModelRequest,
CreateProcessRequest,
CreateSessionRequest,
CreateSessionRequestBookingDemand,
Expand All @@ -21,6 +22,7 @@ export type {
GetBookingRequest,
GetJobCircuitRequest,
GetJobRequest,
GetModelRequest,
GetPlatformRequest,
GetProcessRequest,
GetSessionRequest,
Expand All @@ -40,6 +42,9 @@ export type {
ListJobsRequest,
ListJobsRequestOrderBy,
ListJobsResponse,
ListModelsRequest,
ListModelsRequestOrderBy,
ListModelsResponse,
ListPlatformsRequest,
ListPlatformsRequestOrderBy,
ListPlatformsResponse,
Expand All @@ -55,6 +60,7 @@ export type {
ListSessionsRequest,
ListSessionsRequestOrderBy,
ListSessionsResponse,
Model,
Platform,
PlatformAvailability,
PlatformBookingRequirement,
Expand Down
47 changes: 47 additions & 0 deletions packages_generated/qaas/src/v1alpha1/marshalling.gen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import type {
Application,
Booking,
CreateJobRequest,
CreateModelRequest,
CreateProcessRequest,
CreateSessionRequest,
CreateSessionRequestBookingDemand,
Expand All @@ -23,11 +24,13 @@ import type {
ListBookingsResponse,
ListJobResultsResponse,
ListJobsResponse,
ListModelsResponse,
ListPlatformsResponse,
ListProcessesResponse,
ListProcessResultsResponse,
ListSessionACLsResponse,
ListSessionsResponse,
Model,
Platform,
PlatformBookingRequirement,
PlatformHardware,
Expand Down Expand Up @@ -99,7 +102,9 @@ export const unmarshalJob = (data: unknown): Job => {
createdAt: unmarshalDate(data.created_at),
id: data.id,
jobDuration: data.job_duration,
modelId: data.model_id,
name: data.name,
parameters: data.parameters,
progressMessage: data.progress_message,
resultDistribution: data.result_distribution,
sessionId: data.session_id,
Expand All @@ -110,6 +115,21 @@ export const unmarshalJob = (data: unknown): Job => {
} as Job
}

export const unmarshalModel = (data: unknown): Model => {
if (!isJSONObject(data)) {
throw new TypeError(
`Unmarshalling the type 'Model' failed as data isn't a dictionary.`,
)
}

return {
createdAt: unmarshalDate(data.created_at),
id: data.id,
projectId: data.project_id,
url: data.url,
} as Model
}

const unmarshalPlatformBookingRequirement = (
data: unknown,
): PlatformBookingRequirement => {
Expand Down Expand Up @@ -226,6 +246,7 @@ export const unmarshalSession = (data: unknown): Session => {
id: data.id,
maxDuration: data.max_duration,
maxIdleDuration: data.max_idle_duration,
modelId: data.model_id,
name: data.name,
originId: data.origin_id,
originType: data.origin_type,
Expand Down Expand Up @@ -317,6 +338,21 @@ export const unmarshalListJobsResponse = (data: unknown): ListJobsResponse => {
} as ListJobsResponse
}

export const unmarshalListModelsResponse = (
data: unknown,
): ListModelsResponse => {
if (!isJSONObject(data)) {
throw new TypeError(
`Unmarshalling the type 'ListModelsResponse' failed as data isn't a dictionary.`,
)
}

return {
models: unmarshalArrayOfObject(data.models, unmarshalModel),
totalCount: data.total_count,
} as ListModelsResponse
}

export const unmarshalListPlatformsResponse = (
data: unknown,
): ListPlatformsResponse => {
Expand Down Expand Up @@ -425,11 +461,21 @@ export const marshalCreateJobRequest = (
): Record<string, unknown> => ({
circuit: marshalJobCircuit(request.circuit, defaults),
max_duration: request.maxDuration,
model_id: request.modelId,
name: request.name,
parameters: request.parameters,
session_id: request.sessionId,
tags: request.tags,
})

export const marshalCreateModelRequest = (
request: CreateModelRequest,
defaults: DefaultValues,
): Record<string, unknown> => ({
payload: request.payload,
project_id: request.projectId ?? defaults.defaultProjectId,
})

export const marshalCreateProcessRequest = (
request: CreateProcessRequest,
defaults: DefaultValues,
Expand Down Expand Up @@ -465,6 +511,7 @@ export const marshalCreateSessionRequest = (
deduplication_id: request.deduplicationId,
max_duration: request.maxDuration,
max_idle_duration: request.maxIdleDuration,
model_id: request.modelId,
name: request.name,
platform_id: request.platformId,
project_id: request.projectId ?? defaults.defaultProjectId,
Expand Down
Loading
Loading