|
| 1 | +// This file was automatically generated. DO NOT EDIT. |
| 2 | +// If you have any remark or suggestion do not hesitate to open an issue. |
| 3 | +import { |
| 4 | + API, |
| 5 | + enrichForPagination, |
| 6 | + resolveOneOf, |
| 7 | + urlParams, |
| 8 | + validatePathParam, |
| 9 | +} from '../../../bridge' |
| 10 | +import { |
| 11 | + unmarshalCategory, |
| 12 | + unmarshalImage, |
| 13 | + unmarshalListCategoriesResponse, |
| 14 | + unmarshalListImagesResponse, |
| 15 | + unmarshalListLocalImagesResponse, |
| 16 | + unmarshalListVersionsResponse, |
| 17 | + unmarshalLocalImage, |
| 18 | + unmarshalVersion, |
| 19 | +} from './marshalling.gen' |
| 20 | +import type { |
| 21 | + Category, |
| 22 | + GetCategoryRequest, |
| 23 | + GetImageRequest, |
| 24 | + GetLocalImageRequest, |
| 25 | + GetVersionRequest, |
| 26 | + Image, |
| 27 | + ListCategoriesRequest, |
| 28 | + ListCategoriesResponse, |
| 29 | + ListImagesRequest, |
| 30 | + ListImagesResponse, |
| 31 | + ListLocalImagesRequest, |
| 32 | + ListLocalImagesResponse, |
| 33 | + ListVersionsRequest, |
| 34 | + ListVersionsResponse, |
| 35 | + LocalImage, |
| 36 | + Version, |
| 37 | +} from './types.gen' |
| 38 | + |
| 39 | +/** Marketplace API. */ |
| 40 | +export class MarketplaceV2GenAPI extends API { |
| 41 | + protected pageOfListImages = (request: Readonly<ListImagesRequest>) => |
| 42 | + this.client.fetch<ListImagesResponse>( |
| 43 | + { |
| 44 | + method: 'GET', |
| 45 | + path: `/marketplace/v2/images`, |
| 46 | + urlParams: urlParams( |
| 47 | + ['arch', request.arch], |
| 48 | + ['category', request.category], |
| 49 | + ['include_eol', request.includeEol], |
| 50 | + ['order_by', request.orderBy ?? 'name_asc'], |
| 51 | + ['page', request.page], |
| 52 | + [ |
| 53 | + 'page_size', |
| 54 | + request.pageSize ?? this.client.settings.defaultPageSize, |
| 55 | + ], |
| 56 | + ), |
| 57 | + }, |
| 58 | + unmarshalListImagesResponse, |
| 59 | + ) |
| 60 | + |
| 61 | + /** |
| 62 | + * List marketplace images |
| 63 | + * |
| 64 | + * @param request - The request {@link ListImagesRequest} |
| 65 | + * @returns A Promise of ListImagesResponse |
| 66 | + */ |
| 67 | + listImages = (request: Readonly<ListImagesRequest>) => |
| 68 | + enrichForPagination('images', this.pageOfListImages, request) |
| 69 | + |
| 70 | + /** |
| 71 | + * Get a specific marketplace image |
| 72 | + * |
| 73 | + * @param request - The request {@link GetImageRequest} |
| 74 | + * @returns A Promise of Image |
| 75 | + */ |
| 76 | + getImage = (request: Readonly<GetImageRequest>) => |
| 77 | + this.client.fetch<Image>( |
| 78 | + { |
| 79 | + method: 'GET', |
| 80 | + path: `/marketplace/v2/images/${validatePathParam( |
| 81 | + 'imageId', |
| 82 | + request.imageId, |
| 83 | + )}`, |
| 84 | + }, |
| 85 | + unmarshalImage, |
| 86 | + ) |
| 87 | + |
| 88 | + protected pageOfListVersions = (request: Readonly<ListVersionsRequest>) => |
| 89 | + this.client.fetch<ListVersionsResponse>( |
| 90 | + { |
| 91 | + method: 'GET', |
| 92 | + path: `/marketplace/v2/versions`, |
| 93 | + urlParams: urlParams( |
| 94 | + ['image_id', request.imageId], |
| 95 | + ['order_by', request.orderBy ?? 'created_at_asc'], |
| 96 | + ['page', request.page], |
| 97 | + [ |
| 98 | + 'page_size', |
| 99 | + request.pageSize ?? this.client.settings.defaultPageSize, |
| 100 | + ], |
| 101 | + ), |
| 102 | + }, |
| 103 | + unmarshalListVersionsResponse, |
| 104 | + ) |
| 105 | + |
| 106 | + listVersions = (request: Readonly<ListVersionsRequest>) => |
| 107 | + enrichForPagination('versions', this.pageOfListVersions, request) |
| 108 | + |
| 109 | + getVersion = (request: Readonly<GetVersionRequest>) => |
| 110 | + this.client.fetch<Version>( |
| 111 | + { |
| 112 | + method: 'GET', |
| 113 | + path: `/marketplace/v2/versions/${validatePathParam( |
| 114 | + 'versionId', |
| 115 | + request.versionId, |
| 116 | + )}`, |
| 117 | + }, |
| 118 | + unmarshalVersion, |
| 119 | + ) |
| 120 | + |
| 121 | + protected pageOfListLocalImages = ( |
| 122 | + request: Readonly<ListLocalImagesRequest> = {}, |
| 123 | + ) => |
| 124 | + this.client.fetch<ListLocalImagesResponse>( |
| 125 | + { |
| 126 | + method: 'GET', |
| 127 | + path: `/marketplace/v2/local-images`, |
| 128 | + urlParams: urlParams( |
| 129 | + ['order_by', request.orderBy ?? 'created_at_asc'], |
| 130 | + ['page', request.page], |
| 131 | + [ |
| 132 | + 'page_size', |
| 133 | + request.pageSize ?? this.client.settings.defaultPageSize, |
| 134 | + ], |
| 135 | + ...Object.entries( |
| 136 | + resolveOneOf([ |
| 137 | + { |
| 138 | + param: 'image_id', |
| 139 | + value: request.imageId, |
| 140 | + }, |
| 141 | + { |
| 142 | + param: 'version_id', |
| 143 | + value: request.versionId, |
| 144 | + }, |
| 145 | + ]), |
| 146 | + ), |
| 147 | + ), |
| 148 | + }, |
| 149 | + unmarshalListLocalImagesResponse, |
| 150 | + ) |
| 151 | + |
| 152 | + listLocalImages = (request: Readonly<ListLocalImagesRequest> = {}) => |
| 153 | + enrichForPagination('localImages', this.pageOfListLocalImages, request) |
| 154 | + |
| 155 | + getLocalImage = (request: Readonly<GetLocalImageRequest>) => |
| 156 | + this.client.fetch<LocalImage>( |
| 157 | + { |
| 158 | + method: 'GET', |
| 159 | + path: `/marketplace/v2/local-images/${validatePathParam( |
| 160 | + 'localImageId', |
| 161 | + request.localImageId, |
| 162 | + )}`, |
| 163 | + }, |
| 164 | + unmarshalLocalImage, |
| 165 | + ) |
| 166 | + |
| 167 | + protected pageOfListCategories = ( |
| 168 | + request: Readonly<ListCategoriesRequest> = {}, |
| 169 | + ) => |
| 170 | + this.client.fetch<ListCategoriesResponse>( |
| 171 | + { |
| 172 | + method: 'GET', |
| 173 | + path: `/marketplace/v2/categories`, |
| 174 | + urlParams: urlParams( |
| 175 | + ['page', request.page], |
| 176 | + [ |
| 177 | + 'page_size', |
| 178 | + request.pageSize ?? this.client.settings.defaultPageSize, |
| 179 | + ], |
| 180 | + ), |
| 181 | + }, |
| 182 | + unmarshalListCategoriesResponse, |
| 183 | + ) |
| 184 | + |
| 185 | + listCategories = (request: Readonly<ListCategoriesRequest> = {}) => |
| 186 | + enrichForPagination('categories', this.pageOfListCategories, request) |
| 187 | + |
| 188 | + getCategory = (request: Readonly<GetCategoryRequest>) => |
| 189 | + this.client.fetch<Category>( |
| 190 | + { |
| 191 | + method: 'GET', |
| 192 | + path: `/marketplace/v2/categories/${validatePathParam( |
| 193 | + 'categoryId', |
| 194 | + request.categoryId, |
| 195 | + )}`, |
| 196 | + }, |
| 197 | + unmarshalCategory, |
| 198 | + ) |
| 199 | +} |
0 commit comments