API: Update imageBuilder API schema

This updates the imageBuilder API schema.
This commit is contained in:
regexowl 2024-04-17 10:35:07 +02:00 committed by Lucas Garfield
parent 2431d176ac
commit 6de7645be5
4 changed files with 180 additions and 102 deletions

View file

@ -25,6 +25,7 @@ const config: ConfigFile = {
'getBlueprintComposes',
'deleteBlueprint',
'getBlueprint',
'recommendPackage',
],
};

View file

@ -46,6 +46,7 @@ paths:
operationId: getOpenapiJson
tags:
- meta
- noAuth
responses:
'200':
description: returns this document
@ -422,6 +423,12 @@ paths:
tags:
- blueprint
parameters:
- in: query
name: name
required: false
schema:
type: string
description: fetch blueprint with specific name
- in: query
name: search
required: false
@ -470,7 +477,7 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/CreateBlueprintResponse'
'400':
'422':
description: blueprint is malformed
content:
application/json:
@ -605,7 +612,8 @@ paths:
schema:
type: integer
description: |
Filter by a specific version of the Blueprint we want to fetch composes for
Filter by a specific version of the Blueprint we want to fetch composes for.
Pass special value -1 to fetch composes for latest version of the Blueprint.
- in: query
name: limit
schema:
@ -644,7 +652,28 @@ paths:
application/json:
schema:
$ref: '#/components/schemas/HTTPErrorList'
/experimental/recommendations:
post:
summary: List recommended packages.
description: "Returns a list of recommended packages for given list of packages."
operationId: recommendPackage
tags:
- recommendations
requestBody:
content:
application/json:
schema:
"$ref": "#/components/schemas/RecommendPackageRequest"
required: true
responses:
'200':
description: Return the recommended packages.
content:
application/json:
schema:
type: array
items:
$ref: "#/components/schemas/RecommendationsResponse"
components:
schemas:
HTTPError:
@ -670,6 +699,10 @@ components:
properties:
version:
type: string
build_time:
type: string
build_commit:
type: string
Readiness:
type: object
required:
@ -677,6 +710,23 @@ components:
properties:
readiness:
type: string
ListResponseMeta:
type: object
required:
- count
properties:
count:
type: integer
ListResponseLinks:
type: object
required:
- first
- last
properties:
first:
type: string
last:
type: string
DistributionsResponse:
type: array
description: |
@ -859,7 +909,6 @@ components:
additionalProperties: false
required:
- name
- description
- distribution
- image_requests
- customizations
@ -898,22 +947,9 @@ components:
- data
properties:
meta:
type: object
required:
- count
properties:
count:
type: integer
$ref: '#/components/schemas/ListResponseMeta'
links:
type: object
required:
- first
- last
properties:
first:
type: string
last:
type: string
$ref: '#/components/schemas/ListResponseLinks'
data:
type: array
items:
@ -993,6 +1029,7 @@ components:
- fedora-38
- fedora-39
- fedora-40
- fedora-41
ImageRequest:
type: object
additionalProperties: false
@ -1020,6 +1057,14 @@ components:
description: |
Size of image, in bytes. When set to 0 the image size is a minimum
defined by the image type.
snapshot_date:
type: string
description: |
Snapshotted content will be used instead of the official repositories of the
distribution. The snapshot that was made closest to, but before the specified date will
be used. If no snapshots made before the specified date can be found, the snapshot
closest to, but after the specified date will be used. If no snapshots can be found at
all, the request will fail.
ImageTypes:
type: string
enum:
@ -1046,24 +1091,9 @@ components:
- data
properties:
meta:
type: object
required:
- count
properties:
count:
type: integer
$ref: '#/components/schemas/ListResponseMeta'
links:
type: object
required:
- first
- last
properties:
first:
type: string
example: "/api/image-builder/v1/composes?limit=10&offset=0"
last:
type: string
example: "/api/image-builder/v1/composes?limit=10&offset=10"
$ref: '#/components/schemas/ListResponseLinks'
data:
type: array
items:
@ -1246,24 +1276,9 @@ components:
- data
properties:
meta:
type: object
required:
- count
properties:
count:
type: integer
$ref: '#/components/schemas/ListResponseMeta'
links:
type: object
required:
- first
- last
properties:
first:
type: string
example: "/api/image-builder/v1/packages?limit=10&offset=0&distribution...."
last:
type: string
example: "/api/image-builder/v1/packages?limit=10&offset=10&distribution...."
$ref: '#/components/schemas/ListResponseLinks'
data:
type: array
items:
@ -1313,6 +1328,29 @@ components:
type: string
signature:
type: string
RecommendPackageRequest:
required:
- packages
- recommendedPackages
type: object
properties:
packages:
type: array
items:
type: string
recommendedPackages:
type: integer
format: int32
default: 3
RecommendationsResponse:
required:
- packages
type: object
properties:
packages:
type: array
items:
type: string
ClonesResponse:
required:
- meta
@ -1320,24 +1358,9 @@ components:
- data
properties:
meta:
type: object
required:
- count
properties:
count:
type: integer
$ref: '#/components/schemas/ListResponseMeta'
links:
type: object
required:
- first
- last
properties:
first:
type: string
example: "/api/image-builder/v1/composes?limit=10&offset=0"
last:
type: string
example: "/api/image-builder/v1/composes?limit=10&offset=10"
$ref: '#/components/schemas/ListResponseLinks'
data:
type: array
items:
@ -1513,6 +1536,8 @@ components:
even when there are one or more mountpoints.
fips:
$ref: '#/components/schemas/FIPS'
installer:
$ref: '#/components/schemas/Installer'
Container:
type: object
required:
@ -1618,6 +1643,11 @@ components:
data:
type: string
description: Contents of the file as plain text
data_encoding:
type: string
enum: ['plain', 'base64']
description: When data is base64-encoded to prevent Akamai content filter false positives
default: 'plain'
ensure_parents:
type: boolean
description: Ensure that the parent directories exist
@ -1713,6 +1743,21 @@ components:
type: boolean
description: Enables the system FIPS mode
default: false
Installer:
type: object
additionalProperties: false
description: Anaconda installer configuration
properties:
unattended:
type: boolean
description: |
Create a kickstart file for a fully automated installation
sudo-nopasswd:
type: array
items:
type: string
description: |
Enable passwordless sudo for users or groups (groups must be prefixed by %)
Ignition:
type: object
additionalProperties: false

View file

@ -30,6 +30,7 @@ const Release = ({ release }: ReleaseProps) => {
'fedora-38': 'Fedora 38',
'fedora-39': 'Fedora 39',
'fedora-40': 'Fedora 40',
'fedora-41': 'Fedora 41',
};
return <p>{releaseDisplayValue[release]}</p>;

View file

@ -84,6 +84,7 @@ const injectedRtkApi = api.injectEndpoints({
query: (queryArg) => ({
url: `/experimental/blueprints`,
params: {
name: queryArg.name,
search: queryArg.search,
limit: queryArg.limit,
offset: queryArg.offset,
@ -145,6 +146,16 @@ const injectedRtkApi = api.injectEndpoints({
},
}),
}),
recommendPackage: build.mutation<
RecommendPackageApiResponse,
RecommendPackageApiArg
>({
query: (queryArg) => ({
url: `/experimental/recommendations`,
method: "POST",
body: queryArg.recommendPackageRequest,
}),
}),
}),
overrideExisting: false,
});
@ -233,6 +244,8 @@ export type GetOscapCustomizationsApiArg = {
export type GetBlueprintsApiResponse =
/** status 200 a list of blueprints */ BlueprintsResponse;
export type GetBlueprintsApiArg = {
/** fetch blueprint with specific name */
name?: string;
/** search for blueprints by name or description */
search?: string;
/** max amount of blueprints, default 100 */
@ -277,8 +290,9 @@ export type GetBlueprintComposesApiResponse =
export type GetBlueprintComposesApiArg = {
/** UUID of a blueprint */
id: string;
/** Filter by a specific version of the Blueprint we want to fetch composes for
*/
/** Filter by a specific version of the Blueprint we want to fetch composes for.
Pass special value -1 to fetch composes for latest version of the Blueprint.
*/
blueprintVersion?: number;
/** max amount of composes, default 100 */
limit?: number;
@ -288,6 +302,11 @@ export type GetBlueprintComposesApiArg = {
*/
ignoreImageTypes?: ImageTypes[];
};
export type RecommendPackageApiResponse =
/** status 200 Return the recommended packages. */ RecommendationsResponse[];
export type RecommendPackageApiArg = {
recommendPackageRequest: RecommendPackageRequest;
};
export type Repository = {
rhsm: boolean;
baseurl?: string;
@ -335,7 +354,15 @@ export type Distributions =
| "fedora-37"
| "fedora-38"
| "fedora-39"
| "fedora-40";
| "fedora-40"
| "fedora-41";
export type ListResponseMeta = {
count: number;
};
export type ListResponseLinks = {
first: string;
last: string;
};
export type ClientId = "api" | "ui";
export type ImageTypes =
| "aws"
@ -441,6 +468,13 @@ export type ImageRequest = {
defined by the image type.
*/
size?: any;
/** Snapshotted content will be used instead of the official repositories of the
distribution. The snapshot that was made closest to, but before the specified date will
be used. If no snapshots made before the specified date can be found, the snapshot
closest to, but after the specified date will be used. If no snapshots can be found at
all, the request will fail.
*/
snapshot_date?: string;
};
export type Container = {
/** Reference to the container to embed */
@ -473,6 +507,8 @@ export type File = {
group?: string | number;
/** Contents of the file as plain text */
data?: string;
/** When data is base64-encoded to prevent Akamai content filter false positives */
data_encoding?: "plain" | "base64";
/** Ensure that the parent directories exist */
ensure_parents?: boolean;
};
@ -584,6 +620,12 @@ export type Fips = {
/** Enables the system FIPS mode */
enabled?: boolean;
};
export type Installer = {
/** Create a kickstart file for a fully automated installation
*/
unattended?: boolean;
"sudo-nopasswd"?: string[];
};
export type Customizations = {
containers?: Container[];
directories?: Directory[];
@ -617,6 +659,7 @@ export type Customizations = {
*/
partitioning_mode?: "raw" | "lvm" | "auto-lvm";
fips?: Fips;
installer?: Installer;
};
export type ComposeRequest = {
distribution: Distributions;
@ -638,13 +681,8 @@ export type ComposesResponseItem = {
blueprint_version?: number | null;
};
export type ComposesResponse = {
meta: {
count: number;
};
links: {
first: string;
last: string;
};
meta: ListResponseMeta;
links: ListResponseLinks;
data: ComposesResponseItem[];
};
export type AwsUploadStatus = {
@ -717,13 +755,8 @@ export type ClonesResponseItem = {
created_at: string;
};
export type ClonesResponse = {
meta: {
count: number;
};
links: {
first: string;
last: string;
};
meta: ListResponseMeta;
links: ListResponseLinks;
data: ClonesResponseItem[];
};
export type CloneStatusResponse = {
@ -737,13 +770,8 @@ export type Package = {
summary: string;
};
export type PackagesResponse = {
meta: {
count: number;
};
links: {
first: string;
last: string;
};
meta: ListResponseMeta;
links: ListResponseLinks;
data: Package[];
};
export type DistributionProfileItem =
@ -773,13 +801,8 @@ export type BlueprintItem = {
last_modified_at: string;
};
export type BlueprintsResponse = {
meta: {
count: number;
};
links: {
first: string;
last: string;
};
meta: ListResponseMeta;
links: ListResponseLinks;
data: BlueprintItem[];
};
export type CreateBlueprintResponse = {
@ -787,7 +810,7 @@ export type CreateBlueprintResponse = {
};
export type CreateBlueprintRequest = {
name: string;
description: string;
description?: string;
distribution: Distributions;
/** Array of image requests. Having more image requests in a single blueprint is currently not supported.
*/
@ -804,6 +827,13 @@ export type BlueprintResponse = {
image_requests: ImageRequest[];
customizations: Customizations;
};
export type RecommendationsResponse = {
packages: string[];
};
export type RecommendPackageRequest = {
packages: string[];
recommendedPackages: number;
};
export const {
useGetArchitecturesQuery,
useLazyGetArchitecturesQuery,
@ -833,4 +863,5 @@ export const {
useComposeBlueprintMutation,
useGetBlueprintComposesQuery,
useLazyGetBlueprintComposesQuery,
useRecommendPackageMutation,
} = injectedRtkApi;