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
1 change: 1 addition & 0 deletions packages/clients/src/api/marketplace/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
export * as v1 from './v1'
export * as v2 from './v2'
199 changes: 199 additions & 0 deletions packages/clients/src/api/marketplace/v2/api.gen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,199 @@
// This file was automatically generated. DO NOT EDIT.
// If you have any remark or suggestion do not hesitate to open an issue.
import {
API,
enrichForPagination,
resolveOneOf,
urlParams,
validatePathParam,
} from '../../../bridge'
import {
unmarshalCategory,
unmarshalImage,
unmarshalListCategoriesResponse,
unmarshalListImagesResponse,
unmarshalListLocalImagesResponse,
unmarshalListVersionsResponse,
unmarshalLocalImage,
unmarshalVersion,
} from './marshalling.gen'
import type {
Category,
GetCategoryRequest,
GetImageRequest,
GetLocalImageRequest,
GetVersionRequest,
Image,
ListCategoriesRequest,
ListCategoriesResponse,
ListImagesRequest,
ListImagesResponse,
ListLocalImagesRequest,
ListLocalImagesResponse,
ListVersionsRequest,
ListVersionsResponse,
LocalImage,
Version,
} from './types.gen'

/** Marketplace API. */
export class MarketplaceV2GenAPI extends API {
protected pageOfListImages = (request: Readonly<ListImagesRequest>) =>
this.client.fetch<ListImagesResponse>(
{
method: 'GET',
path: `/marketplace/v2/images`,
urlParams: urlParams(
['arch', request.arch],
['category', request.category],
['include_eol', request.includeEol],
['order_by', request.orderBy ?? 'name_asc'],
['page', request.page],
[
'page_size',
request.pageSize ?? this.client.settings.defaultPageSize,
],
),
},
unmarshalListImagesResponse,
)

/**
* List marketplace images
*
* @param request - The request {@link ListImagesRequest}
* @returns A Promise of ListImagesResponse
*/
listImages = (request: Readonly<ListImagesRequest>) =>
enrichForPagination('images', this.pageOfListImages, request)

/**
* Get a specific marketplace image
*
* @param request - The request {@link GetImageRequest}
* @returns A Promise of Image
*/
getImage = (request: Readonly<GetImageRequest>) =>
this.client.fetch<Image>(
{
method: 'GET',
path: `/marketplace/v2/images/${validatePathParam(
'imageId',
request.imageId,
)}`,
},
unmarshalImage,
)

protected pageOfListVersions = (request: Readonly<ListVersionsRequest>) =>
this.client.fetch<ListVersionsResponse>(
{
method: 'GET',
path: `/marketplace/v2/versions`,
urlParams: urlParams(
['image_id', request.imageId],
['order_by', request.orderBy ?? 'created_at_asc'],
['page', request.page],
[
'page_size',
request.pageSize ?? this.client.settings.defaultPageSize,
],
),
},
unmarshalListVersionsResponse,
)

listVersions = (request: Readonly<ListVersionsRequest>) =>
enrichForPagination('versions', this.pageOfListVersions, request)

getVersion = (request: Readonly<GetVersionRequest>) =>
this.client.fetch<Version>(
{
method: 'GET',
path: `/marketplace/v2/versions/${validatePathParam(
'versionId',
request.versionId,
)}`,
},
unmarshalVersion,
)

protected pageOfListLocalImages = (
request: Readonly<ListLocalImagesRequest> = {},
) =>
this.client.fetch<ListLocalImagesResponse>(
{
method: 'GET',
path: `/marketplace/v2/local-images`,
urlParams: urlParams(
['order_by', request.orderBy ?? 'created_at_asc'],
['page', request.page],
[
'page_size',
request.pageSize ?? this.client.settings.defaultPageSize,
],
...Object.entries(
resolveOneOf([
{
param: 'image_id',
value: request.imageId,
},
{
param: 'version_id',
value: request.versionId,
},
]),
),
),
},
unmarshalListLocalImagesResponse,
)

listLocalImages = (request: Readonly<ListLocalImagesRequest> = {}) =>
enrichForPagination('localImages', this.pageOfListLocalImages, request)

getLocalImage = (request: Readonly<GetLocalImageRequest>) =>
this.client.fetch<LocalImage>(
{
method: 'GET',
path: `/marketplace/v2/local-images/${validatePathParam(
'localImageId',
request.localImageId,
)}`,
},
unmarshalLocalImage,
)

protected pageOfListCategories = (
request: Readonly<ListCategoriesRequest> = {},
) =>
this.client.fetch<ListCategoriesResponse>(
{
method: 'GET',
path: `/marketplace/v2/categories`,
urlParams: urlParams(
['page', request.page],
[
'page_size',
request.pageSize ?? this.client.settings.defaultPageSize,
],
),
},
unmarshalListCategoriesResponse,
)

listCategories = (request: Readonly<ListCategoriesRequest> = {}) =>
enrichForPagination('categories', this.pageOfListCategories, request)

getCategory = (request: Readonly<GetCategoryRequest>) =>
this.client.fetch<Category>(
{
method: 'GET',
path: `/marketplace/v2/categories/${validatePathParam(
'categoryId',
request.categoryId,
)}`,
},
unmarshalCategory,
)
}
3 changes: 3 additions & 0 deletions packages/clients/src/api/marketplace/v2/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export { MarketplaceV2GenAPI as API } from './api.gen'
export * from './content.gen'
export * from './types.gen'
134 changes: 134 additions & 0 deletions packages/clients/src/api/marketplace/v2/marshalling.gen.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,134 @@
// This file was automatically generated. DO NOT EDIT.
// If you have any remark or suggestion do not hesitate to open an issue.
import {
isJSONObject,
unmarshalArrayOfObject,
unmarshalDate,
} from '../../../bridge'
import type {
Category,
Image,
ListCategoriesResponse,
ListImagesResponse,
ListLocalImagesResponse,
ListVersionsResponse,
LocalImage,
Version,
} from './types.gen'

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

return {
description: data.description,
id: data.id,
name: data.name,
} as Category
}

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

return {
categories: data.categories,
createdAt: unmarshalDate(data.created_at),
description: data.description,
id: data.id,
label: data.label,
logo: data.logo,
name: data.name,
updatedAt: unmarshalDate(data.updated_at),
validUntil: unmarshalDate(data.valid_until),
} as Image
}

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

return {
arch: data.arch,
compatibleCommercialTypes: data.compatible_commercial_types,
id: data.id,
zone: data.zone,
} as LocalImage
}

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

return {
createdAt: unmarshalDate(data.created_at),
id: data.id,
name: data.name,
publishedAt: unmarshalDate(data.published_at),
updatedAt: unmarshalDate(data.updated_at),
} as Version
}

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

return {
categories: unmarshalArrayOfObject(data.categories, unmarshalCategory),
totalCount: data.total_count,
} as ListCategoriesResponse
}

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

return {
images: unmarshalArrayOfObject(data.images, unmarshalImage),
totalCount: data.total_count,
} as ListImagesResponse
}

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

return {
localImages: unmarshalArrayOfObject(data.local_images, unmarshalLocalImage),
totalCount: data.total_count,
} as ListLocalImagesResponse
}

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

return {
totalCount: data.total_count,
versions: unmarshalArrayOfObject(data.versions, unmarshalVersion),
} as ListVersionsResponse
}
Loading