From 9c3581f21ce944663c6f2191810975b6747d6781 Mon Sep 17 00:00:00 2001 From: Gianluca Zuccarelli Date: Tue, 28 Jan 2025 14:44:16 +0000 Subject: [PATCH] store: split apis into sub directories Since we will need to add other api endpoints, e.g. `contentSourcesApi` for the on-prem frontend, this PR restructures the store directory to make future changes more manageable. --- api/config/compliance.ts | 4 +- api/config/contentSources.ts | 4 +- api/config/edge.ts | 4 +- api/config/imageBuilder.ts | 4 +- api/config/provisioning.ts | 4 +- api/config/rhsm.ts | 4 +- api/schema/contentSources.json | 412 ++++++++ api/schema/imageBuilder.yaml | 5 + .../Blueprints/BlueprintsSideBar.tsx | 2 +- src/store/backendApi.ts | 8 +- src/store/{ => cockpit}/cockpitApi.ts | 12 +- src/store/{ => cockpit}/emptyCockpitApi.ts | 2 +- src/store/{ => cockpit}/enhancedCockpitApi.ts | 3 +- src/store/complianceApi.ts | 42 +- src/store/contentSourcesApi.ts | 12 +- src/store/edgeApi.ts | 16 +- src/store/imageBuilderApi.ts | 184 ++-- src/store/index.ts | 4 +- src/store/provisioningApi.ts | 4 +- src/store/rhsmApi.ts | 4 +- src/store/service/complianceApi.ts | 160 +++ src/store/service/contentSourcesApi.ts | 612 +++++++++++ src/store/service/edgeApi.ts | 571 +++++++++++ src/store/{ => service}/emptyComplianceApi.ts | 2 +- .../{ => service}/emptyContentSourcesApi.ts | 2 +- src/store/{ => service}/emptyEdgeApi.ts | 2 +- .../{ => service}/emptyImageBuilderApi.ts | 2 +- .../{ => service}/emptyProvisioningApi.ts | 2 +- src/store/{ => service}/emptyRhsmApi.ts | 2 +- src/store/service/enhancedImageBuilderApi.ts | 228 +++++ src/store/service/imageBuilderApi.ts | 958 ++++++++++++++++++ src/store/service/provisioningApi.ts | 69 ++ src/store/service/rhsmApi.ts | 81 ++ 33 files changed, 3261 insertions(+), 164 deletions(-) rename src/store/{ => cockpit}/cockpitApi.ts (98%) rename src/store/{ => cockpit}/emptyCockpitApi.ts (82%) rename src/store/{ => cockpit}/enhancedCockpitApi.ts (95%) create mode 100644 src/store/service/complianceApi.ts create mode 100644 src/store/service/contentSourcesApi.ts create mode 100644 src/store/service/edgeApi.ts rename src/store/{ => service}/emptyComplianceApi.ts (87%) rename src/store/{ => service}/emptyContentSourcesApi.ts (87%) rename src/store/{ => service}/emptyEdgeApi.ts (88%) rename src/store/{ => service}/emptyImageBuilderApi.ts (96%) rename src/store/{ => service}/emptyProvisioningApi.ts (87%) rename src/store/{ => service}/emptyRhsmApi.ts (88%) create mode 100644 src/store/service/enhancedImageBuilderApi.ts create mode 100644 src/store/service/imageBuilderApi.ts create mode 100644 src/store/service/provisioningApi.ts create mode 100644 src/store/service/rhsmApi.ts diff --git a/api/config/compliance.ts b/api/config/compliance.ts index c117f751..f06197ce 100644 --- a/api/config/compliance.ts +++ b/api/config/compliance.ts @@ -2,9 +2,9 @@ import type { ConfigFile } from '@rtk-query/codegen-openapi'; const config: ConfigFile = { schemaFile: '../schema/compliance.json', - apiFile: '../../src/store/emptyComplianceApi.ts', + apiFile: '../../src/store/service/emptyComplianceApi.ts', apiImport: 'emptyComplianceApi', - outputFile: '../../src/store/complianceApi.ts', + outputFile: '../../src/store/service/complianceApi.ts', exportName: 'complianceApi', hooks: true, unionUndefined: true, diff --git a/api/config/contentSources.ts b/api/config/contentSources.ts index c5ea45b4..87707d14 100644 --- a/api/config/contentSources.ts +++ b/api/config/contentSources.ts @@ -2,9 +2,9 @@ import type { ConfigFile } from '@rtk-query/codegen-openapi'; const config: ConfigFile = { schemaFile: '../schema/contentSources.json', - apiFile: '../../src/store/emptyContentSourcesApi.ts', + apiFile: '../../src/store/service/emptyContentSourcesApi.ts', apiImport: 'emptyContentSourcesApi', - outputFile: '../../src/store/contentSourcesApi.ts', + outputFile: '../../src/store/service/contentSourcesApi.ts', exportName: 'contentSourcesApi', hooks: true, unionUndefined: true, diff --git a/api/config/edge.ts b/api/config/edge.ts index 53e87929..ba528d07 100644 --- a/api/config/edge.ts +++ b/api/config/edge.ts @@ -2,9 +2,9 @@ import type { ConfigFile } from '@rtk-query/codegen-openapi'; const config: ConfigFile = { schemaFile: '../schema/edge.json', - apiFile: '../../src/store/emptyEdgeApi.ts', + apiFile: '../../src/store/service/emptyEdgeApi.ts', apiImport: 'emptyEdgeApi', - outputFile: '../../src/store/edgeApi.ts', + outputFile: '../../src/store/service/edgeApi.ts', exportName: 'edgeApi', hooks: true, unionUndefined: true, diff --git a/api/config/imageBuilder.ts b/api/config/imageBuilder.ts index 0b3f52da..b18c29a0 100644 --- a/api/config/imageBuilder.ts +++ b/api/config/imageBuilder.ts @@ -2,9 +2,9 @@ import type { ConfigFile } from '@rtk-query/codegen-openapi'; const config: ConfigFile = { schemaFile: '../schema/imageBuilder.yaml', - apiFile: '../../src/store/emptyImageBuilderApi.ts', + apiFile: '../../src/store/service/emptyImageBuilderApi.ts', apiImport: 'emptyImageBuilderApi', - outputFile: '../../src/store/imageBuilderApi.ts', + outputFile: '../../src/store/service/imageBuilderApi.ts', exportName: 'imageBuilderApi', hooks: { queries: true, lazyQueries: true, mutations: true }, unionUndefined: true, diff --git a/api/config/provisioning.ts b/api/config/provisioning.ts index c1736b5b..40e5b91b 100644 --- a/api/config/provisioning.ts +++ b/api/config/provisioning.ts @@ -2,9 +2,9 @@ import type { ConfigFile } from '@rtk-query/codegen-openapi'; const config: ConfigFile = { schemaFile: '../schema/provisioning.json', - apiFile: '../../src/store/emptyProvisioningApi.ts', + apiFile: '../../src/store/service/emptyProvisioningApi.ts', apiImport: 'emptyProvisioningApi', - outputFile: '../../src/store/provisioningApi.ts', + outputFile: '../../src/store/service/provisioningApi.ts', exportName: 'provisioningApi', hooks: true, unionUndefined: true, diff --git a/api/config/rhsm.ts b/api/config/rhsm.ts index 5082accf..69797989 100644 --- a/api/config/rhsm.ts +++ b/api/config/rhsm.ts @@ -2,9 +2,9 @@ import type { ConfigFile } from '@rtk-query/codegen-openapi'; const config: ConfigFile = { schemaFile: '../schema/rhsm.json', - apiFile: '../../src/store/emptyRhsmApi.ts', + apiFile: '../../src/store/service/emptyRhsmApi.ts', apiImport: 'emptyRhsmApi', - outputFile: '../../src/store/rhsmApi.ts', + outputFile: '../../src/store/service/rhsmApi.ts', exportName: 'rhsmApi', hooks: true, unionUndefined: true, diff --git a/api/schema/contentSources.json b/api/schema/contentSources.json index 654a7362..267d62f8 100644 --- a/api/schema/contentSources.json +++ b/api/schema/contentSources.json @@ -72,12 +72,22 @@ }, "api.CreateUploadRequest": { "properties": { + "chunk_size": { + "description": "Size of the chunk", + "type": "integer" + }, + "sha256": { + "description": "SHA-256 checksum of the file", + "type": "string" + }, "size": { "description": "Size of the upload in bytes", "type": "integer" } }, "required": [ + "chunk_size", + "sha256", "size" ], "type": "object" @@ -1029,6 +1039,61 @@ }, "type": "object" }, + "api.SearchModuleStreams": { + "properties": { + "module_name": { + "description": "Module name", + "type": "string" + }, + "streams": { + "description": "A list of stream related information for the module", + "items": { + "$ref": "#/components/schemas/api.Stream" + }, + "type": "array" + } + }, + "type": "object" + }, + "api.SearchModuleStreamsRequest": { + "properties": { + "rpm_names": { + "description": "List of rpm names to search", + "items": { + "type": "string" + }, + "type": "array" + }, + "search": { + "description": "Search string to search rpm names", + "type": "string" + }, + "sort_by": { + "description": "SortBy sets the sort order of the result", + "type": "string" + }, + "urls": { + "description": "List of repository URLs to search", + "items": { + "type": "string" + }, + "type": "array" + }, + "uuids": { + "description": "List of repository UUIDs to search", + "items": { + "type": "string" + }, + "type": "array" + } + }, + "required": [ + "rpm_names", + "urls", + "uuids" + ], + "type": "object" + }, "api.SearchPackageGroupResponse": { "properties": { "description": { @@ -1066,6 +1131,37 @@ }, "type": "object" }, + "api.SearchSnapshotModuleStreamsRequest": { + "properties": { + "rpm_names": { + "description": "List of rpm names to restrict returned modules", + "items": { + "type": "string" + }, + "type": "array" + }, + "search": { + "description": "Search string to search module names", + "type": "string" + }, + "sort_by": { + "description": "SortBy sets the sort order of the result", + "type": "string" + }, + "uuids": { + "description": "List of snapshot UUIDs to search", + "items": { + "type": "string" + }, + "type": "array" + } + }, + "required": [ + "rpm_names", + "uuids" + ], + "type": "object" + }, "api.SnapshotCollectionResponse": { "properties": { "data": { @@ -1285,6 +1381,45 @@ }, "type": "object" }, + "api.Stream": { + "properties": { + "arch": { + "description": "The Architecture of the rpm", + "type": "string" + }, + "context": { + "description": "Context of the module", + "type": "string" + }, + "description": { + "description": "Module description", + "type": "string" + }, + "name": { + "description": "Name of the module", + "type": "string" + }, + "profiles": { + "additionalProperties": { + "items": { + "type": "string" + }, + "type": "array" + }, + "description": "Module profile data", + "type": "object" + }, + "stream": { + "description": "Module stream version", + "type": "string" + }, + "version": { + "description": "The version of the rpm", + "type": "string" + } + }, + "type": "object" + }, "api.TaskInfoCollectionResponse": { "properties": { "data": { @@ -1483,6 +1618,22 @@ "description": "Environment ID used by subscription-manager and candlepin", "type": "string" }, + "snapshots": { + "description": "The list of snapshots in use by the template", + "items": { + "$ref": "#/components/schemas/api.SnapshotResponse" + }, + "readOnly": true, + "type": "array" + }, + "to_be_deleted_snapshots": { + "description": "List of snapshots used by this template which are going to be deleted soon", + "items": { + "$ref": "#/components/schemas/api.SnapshotResponse" + }, + "readOnly": true, + "type": "array" + }, "updated_at": { "description": "Datetime template was last updated", "type": "string" @@ -1563,10 +1714,21 @@ }, "api.UploadResponse": { "properties": { + "artifact_href": { + "description": "Artifact href if one exists (on create only)", + "type": "string" + }, "completed": { "description": "Timestamp when upload is committed", "type": "string" }, + "completed_checksums": { + "description": "A list of already completed checksums", + "items": { + "type": "string" + }, + "type": "array" + }, "created": { "description": "Timestamp of creation", "type": "string" @@ -1799,6 +1961,83 @@ ] } }, + "/module_streams/search": { + "post": { + "description": "List modules and their streams for repositories", + "operationId": "searchRepositoryModuleStreams", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/api.SearchModuleStreamsRequest" + } + } + }, + "description": "request body", + "required": true, + "x-originalParamName": "body" + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "items": { + "$ref": "#/components/schemas/api.SearchModuleStreams" + }, + "type": "array" + } + } + }, + "description": "OK" + }, + "400": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/errors.ErrorResponse" + } + } + }, + "description": "Bad Request" + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/errors.ErrorResponse" + } + } + }, + "description": "Unauthorized" + }, + "404": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/errors.ErrorResponse" + } + } + }, + "description": "Not Found" + }, + "500": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/errors.ErrorResponse" + } + } + }, + "description": "Internal Server Error" + } + }, + "summary": "List modules and their streams for repositories", + "tags": [ + "module_streams" + ] + } + }, "/package_groups/names": { "post": { "description": "This enables users to search for package groups in a given list of repositories.", @@ -3938,6 +4177,30 @@ "schema": { "type": "string" } + }, + { + "description": "Sort the response data based on specific repository parameters. Sort criteria can include `created_at`.", + "in": "query", + "name": "sort_by", + "schema": { + "type": "string" + } + }, + { + "description": "Starting point for retrieving a subset of results. Determines how many items to skip from the beginning of the result set. Default value:`0`.", + "in": "query", + "name": "offset", + "schema": { + "type": "integer" + } + }, + { + "description": "Number of items to include in response. Use it to control the number of items, particularly when dealing with large datasets. Default value: `100`.", + "in": "query", + "name": "limit", + "schema": { + "type": "integer" + } } ], "responses": { @@ -4630,6 +4893,83 @@ ] } }, + "/snapshots/module_streams/search": { + "post": { + "description": "List modules and their streams for snapshots", + "operationId": "searchSnapshotModuleStreams", + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/api.SearchSnapshotModuleStreamsRequest" + } + } + }, + "description": "request body", + "required": true, + "x-originalParamName": "body" + }, + "responses": { + "200": { + "content": { + "application/json": { + "schema": { + "items": { + "$ref": "#/components/schemas/api.SearchModuleStreams" + }, + "type": "array" + } + } + }, + "description": "OK" + }, + "400": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/errors.ErrorResponse" + } + } + }, + "description": "Bad Request" + }, + "401": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/errors.ErrorResponse" + } + } + }, + "description": "Unauthorized" + }, + "404": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/errors.ErrorResponse" + } + } + }, + "description": "Not Found" + }, + "500": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/errors.ErrorResponse" + } + } + }, + "description": "Internal Server Error" + } + }, + "summary": "List modules and their streams for snapshots", + "tags": [ + "module_streams" + ] + } + }, "/snapshots/package_groups/names": { "post": { "description": "This enables users to search for package groups in a given list of snapshots.", @@ -5505,6 +5845,78 @@ ] } }, + "/templates/{template_uuid}/config.repo": { + "get": { + "operationId": "getTemplateRepoConfigurationFile", + "parameters": [ + { + "description": "Identifier of the template", + "in": "path", + "name": "template_uuid", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "content": { + "text/plain": { + "schema": { + "type": "string" + } + } + }, + "description": "OK" + }, + "400": { + "content": { + "text/plain": { + "schema": { + "$ref": "#/components/schemas/errors.ErrorResponse" + } + } + }, + "description": "Bad Request" + }, + "401": { + "content": { + "text/plain": { + "schema": { + "$ref": "#/components/schemas/errors.ErrorResponse" + } + } + }, + "description": "Unauthorized" + }, + "404": { + "content": { + "text/plain": { + "schema": { + "$ref": "#/components/schemas/errors.ErrorResponse" + } + } + }, + "description": "Not Found" + }, + "500": { + "content": { + "text/plain": { + "schema": { + "$ref": "#/components/schemas/errors.ErrorResponse" + } + } + }, + "description": "Internal Server Error" + } + }, + "summary": "Get configuration file for all repositories in a template", + "tags": [ + "templates" + ] + } + }, "/templates/{uuid}": { "delete": { "description": "This enables deleting a specific template.", diff --git a/api/schema/imageBuilder.yaml b/api/schema/imageBuilder.yaml index 9477a18a..03b5827c 100644 --- a/api/schema/imageBuilder.yaml +++ b/api/schema/imageBuilder.yaml @@ -2073,6 +2073,11 @@ components: required: - rhsm properties: + id: + type: string + description: | + An ID referring to a repository defined in content sources can be used instead of + 'baseurl', 'mirrorlist' or 'metalink'. rhsm: type: boolean baseurl: diff --git a/src/Components/Blueprints/BlueprintsSideBar.tsx b/src/Components/Blueprints/BlueprintsSideBar.tsx index 1e0bd34e..db5f8c5a 100644 --- a/src/Components/Blueprints/BlueprintsSideBar.tsx +++ b/src/Components/Blueprints/BlueprintsSideBar.tsx @@ -39,12 +39,12 @@ import { setBlueprintSearchInput, setBlueprintsOffset, } from '../../store/BlueprintSlice'; -import { imageBuilderApi } from '../../store/enhancedImageBuilderApi'; import { useAppDispatch, useAppSelector } from '../../store/hooks'; import { BlueprintItem, GetBlueprintsApiArg, } from '../../store/imageBuilderApi'; +import { imageBuilderApi } from '../../store/service/enhancedImageBuilderApi'; import { resolveRelPath } from '../../Utilities/path'; type blueprintSearchProps = { diff --git a/src/store/backendApi.ts b/src/store/backendApi.ts index 792ec36f..0521d534 100644 --- a/src/store/backendApi.ts +++ b/src/store/backendApi.ts @@ -1,8 +1,8 @@ -import * as cockpitQueries from './cockpitApi'; +import * as cockpitQueries from './cockpit/cockpitApi'; +import { cockpitApi } from './cockpit/enhancedCockpitApi'; import { useListSnapshotsByDateMutation as useContentSourcesListSnapshotsByDateMutation } from './contentSourcesApi'; -import { cockpitApi } from './enhancedCockpitApi'; -import { imageBuilderApi } from './enhancedImageBuilderApi'; -import * as imageBuilderQueries from './imageBuilderApi'; +import { imageBuilderApi } from './service/enhancedImageBuilderApi'; +import * as imageBuilderQueries from './service/imageBuilderApi'; export const useGetArchitecturesQuery = process.env.IS_ON_PREMISE ? cockpitQueries.useGetArchitecturesQuery diff --git a/src/store/cockpitApi.ts b/src/store/cockpit/cockpitApi.ts similarity index 98% rename from src/store/cockpitApi.ts rename to src/store/cockpit/cockpitApi.ts index 8674f484..557613be 100644 --- a/src/store/cockpitApi.ts +++ b/src/store/cockpit/cockpitApi.ts @@ -10,11 +10,14 @@ import cockpit from 'cockpit'; import { fsinfo } from 'cockpit/fsinfo'; import { v4 as uuidv4 } from 'uuid'; +import { emptyCockpitApi } from './emptyCockpitApi'; + +import { mapHostedToOnPrem } from '../../Components/Blueprints/helpers/onPremToHostedBlueprintMapper'; +import { BLUEPRINTS_DIR } from '../../constants'; import { ListSnapshotsByDateApiArg, ListSnapshotsByDateApiResponse, -} from './contentSourcesApi'; -import { emptyCockpitApi } from './emptyCockpitApi'; +} from '../service/contentSourcesApi'; import { ComposeBlueprintApiResponse, ComposeBlueprintApiArg, @@ -40,10 +43,7 @@ import { CreateBlueprintApiResponse, CreateBlueprintApiArg, ComposeResponse, -} from './imageBuilderApi'; - -import { mapHostedToOnPrem } from '../Components/Blueprints/helpers/onPremToHostedBlueprintMapper'; -import { BLUEPRINTS_DIR } from '../constants'; +} from '../service/imageBuilderApi'; const getBlueprintsPath = async () => { const user = await cockpit.user(); diff --git a/src/store/emptyCockpitApi.ts b/src/store/cockpit/emptyCockpitApi.ts similarity index 82% rename from src/store/emptyCockpitApi.ts rename to src/store/cockpit/emptyCockpitApi.ts index 54d5254d..34a8a5db 100644 --- a/src/store/emptyCockpitApi.ts +++ b/src/store/cockpit/emptyCockpitApi.ts @@ -1,6 +1,6 @@ import { createApi } from '@reduxjs/toolkit/query/react'; -import { baseQuery } from './cockpit/baseQuery'; +import { baseQuery } from './baseQuery'; export const emptyCockpitApi = createApi({ reducerPath: 'cockpitApi', diff --git a/src/store/enhancedCockpitApi.ts b/src/store/cockpit/enhancedCockpitApi.ts similarity index 95% rename from src/store/enhancedCockpitApi.ts rename to src/store/cockpit/enhancedCockpitApi.ts index 2ccdcd06..b404b961 100644 --- a/src/store/enhancedCockpitApi.ts +++ b/src/store/cockpit/enhancedCockpitApi.ts @@ -1,7 +1,8 @@ import { addNotification } from '@redhat-cloud-services/frontend-components-notifications/redux'; import { cockpitApi } from './cockpitApi'; -import { errorMessage } from './enhancedImageBuilderApi'; + +import { errorMessage } from '../service/enhancedImageBuilderApi'; const enhancedApi = cockpitApi.enhanceEndpoints({ addTagTypes: ['Blueprints', 'Composes'], diff --git a/src/store/complianceApi.ts b/src/store/complianceApi.ts index 1e74e29d..e1311574 100644 --- a/src/store/complianceApi.ts +++ b/src/store/complianceApi.ts @@ -1,11 +1,11 @@ -import { emptyComplianceApi as api } from "./emptyComplianceApi"; +import { emptyComplianceApi as api } from './service/emptyComplianceApi'; const injectedRtkApi = api.injectEndpoints({ endpoints: (build) => ({ policies: build.query({ query: (queryArg) => ({ url: `/policies`, headers: { - "X-RH-IDENTITY": queryArg["X-RH-IDENTITY"], + 'X-RH-IDENTITY': queryArg['X-RH-IDENTITY'], }, params: { limit: queryArg.limit, @@ -20,7 +20,7 @@ const injectedRtkApi = api.injectEndpoints({ query: (queryArg) => ({ url: `/policies/${queryArg.policyId}`, headers: { - "X-RH-IDENTITY": queryArg["X-RH-IDENTITY"], + 'X-RH-IDENTITY': queryArg['X-RH-IDENTITY'], }, }), }), @@ -39,7 +39,7 @@ export type PoliciesApiResponse = /** status 200 Lists Policies */ { }; export type PoliciesApiArg = { /** For internal use only */ - "X-RH-IDENTITY"?: string; + 'X-RH-IDENTITY'?: string; /** Number of items to return per page */ limit?: number; /** Offset of first item of paginated response */ @@ -48,21 +48,21 @@ export type PoliciesApiArg = { idsOnly?: boolean; /** Attribute and direction to sort the items by. Represented by an array of fields with an optional direction (`:asc` or `:desc`).

If no direction is selected, `:asc` is used by default. */ sortBy?: ( - | "title" - | "os_major_version" - | "total_system_count" - | "business_objective" - | "compliance_threshold" - | "title:asc" - | "title:desc" - | "os_major_version:asc" - | "os_major_version:desc" - | "total_system_count:asc" - | "total_system_count:desc" - | "business_objective:asc" - | "business_objective:desc" - | "compliance_threshold:asc" - | "compliance_threshold:desc" + | 'title' + | 'os_major_version' + | 'total_system_count' + | 'business_objective' + | 'compliance_threshold' + | 'title:asc' + | 'title:desc' + | 'os_major_version:asc' + | 'os_major_version:desc' + | 'total_system_count:asc' + | 'total_system_count:desc' + | 'business_objective:asc' + | 'business_objective:desc' + | 'compliance_threshold:asc' + | 'compliance_threshold:desc' )[]; /** Query string to filter items by their attributes. Compliant with scoped_search query language. However, only `=` or `!=` (resp. `<>`) operators are supported.

Policies are searchable using attributes `title`, `os_major_version`, and `os_minor_version`

(e.g.: `(field_1=something AND field_2!="something else") OR field_3>40`) */ filter?: string; @@ -76,7 +76,7 @@ export type PolicyApiResponse = /** status 200 Returns a Policy */ { }; export type PolicyApiArg = { /** For internal use only */ - "X-RH-IDENTITY"?: string; + 'X-RH-IDENTITY'?: string; policyId: string; }; export type Metadata = { @@ -123,7 +123,7 @@ export type Policy = { }; export type PolicyRead = { id?: IdRead | undefined; - type?: "policy" | undefined; + type?: 'policy' | undefined; /** Short title of the Policy */ title?: string | undefined; /** Longer description of the Policy */ diff --git a/src/store/contentSourcesApi.ts b/src/store/contentSourcesApi.ts index 511a4b6c..3f316ffb 100644 --- a/src/store/contentSourcesApi.ts +++ b/src/store/contentSourcesApi.ts @@ -1,4 +1,4 @@ -import { emptyContentSourcesApi as api } from "./emptyContentSourcesApi"; +import { emptyContentSourcesApi as api } from './service/emptyContentSourcesApi'; const injectedRtkApi = api.injectEndpoints({ endpoints: (build) => ({ listFeatures: build.query({ @@ -10,7 +10,7 @@ const injectedRtkApi = api.injectEndpoints({ >({ query: (queryArg) => ({ url: `/package_groups/names`, - method: "POST", + method: 'POST', body: queryArg.apiContentUnitSearchRequest, }), }), @@ -44,7 +44,7 @@ const injectedRtkApi = api.injectEndpoints({ >({ query: (queryArg) => ({ url: `/repositories/`, - method: "POST", + method: 'POST', body: queryArg.apiRepositoryRequest, }), }), @@ -54,7 +54,7 @@ const injectedRtkApi = api.injectEndpoints({ >({ query: (queryArg) => ({ url: `/repositories/bulk_import/`, - method: "POST", + method: 'POST', body: queryArg.body, }), }), @@ -75,7 +75,7 @@ const injectedRtkApi = api.injectEndpoints({ searchRpm: build.mutation({ query: (queryArg) => ({ url: `/rpms/names`, - method: "POST", + method: 'POST', body: queryArg.apiContentUnitSearchRequest, }), }), @@ -85,7 +85,7 @@ const injectedRtkApi = api.injectEndpoints({ >({ query: (queryArg) => ({ url: `/snapshots/for_date/`, - method: "POST", + method: 'POST', body: queryArg.apiListSnapshotByDateRequest, }), }), diff --git a/src/store/edgeApi.ts b/src/store/edgeApi.ts index 6034c289..60e36704 100644 --- a/src/store/edgeApi.ts +++ b/src/store/edgeApi.ts @@ -1,4 +1,4 @@ -import { emptyEdgeApi as api } from "./emptyEdgeApi"; +import { emptyEdgeApi as api } from './service/emptyEdgeApi'; const injectedRtkApi = api.injectEndpoints({ endpoints: (build) => ({ listAllImageSets: build.query< @@ -61,7 +61,7 @@ const injectedRtkApi = api.injectEndpoints({ >({ query: (queryArg) => ({ url: `/image-sets/${queryArg.imageSetId}`, - method: "DELETE", + method: 'DELETE', }), }), getAllImages: build.query({ @@ -81,7 +81,7 @@ const injectedRtkApi = api.injectEndpoints({ createImage: build.mutation({ query: (queryArg) => ({ url: `/images`, - method: "POST", + method: 'POST', body: queryArg.createImage, }), }), @@ -91,7 +91,7 @@ const injectedRtkApi = api.injectEndpoints({ >({ query: (queryArg) => ({ url: `/images/checkImageName`, - method: "POST", + method: 'POST', body: queryArg.createImage, }), }), @@ -101,7 +101,7 @@ const injectedRtkApi = api.injectEndpoints({ >({ query: (queryArg) => ({ url: `/images/${queryArg.imageId}/installer`, - method: "POST", + method: 'POST', body: queryArg.createImage, }), }), @@ -111,7 +111,7 @@ const injectedRtkApi = api.injectEndpoints({ >({ query: (queryArg) => ({ url: `/images/${queryArg.imageId}/kickstart`, - method: "POST", + method: 'POST', body: queryArg.createImage, }), }), @@ -133,7 +133,7 @@ const injectedRtkApi = api.injectEndpoints({ >({ query: (queryArg) => ({ url: `/images/${queryArg.imageId}/retry`, - method: "POST", + method: 'POST', body: queryArg.createImage, }), }), @@ -143,7 +143,7 @@ const injectedRtkApi = api.injectEndpoints({ >({ query: (queryArg) => ({ url: `/images/${queryArg.imageId}/update`, - method: "POST", + method: 'POST', body: queryArg.createImage, }), }), diff --git a/src/store/imageBuilderApi.ts b/src/store/imageBuilderApi.ts index 1990658c..e2ed66eb 100644 --- a/src/store/imageBuilderApi.ts +++ b/src/store/imageBuilderApi.ts @@ -1,4 +1,4 @@ -import { emptyImageBuilderApi as api } from "./emptyImageBuilderApi"; +import { emptyImageBuilderApi as api } from './service/emptyImageBuilderApi'; const injectedRtkApi = api.injectEndpoints({ endpoints: (build) => ({ getArchitectures: build.query< @@ -24,7 +24,7 @@ const injectedRtkApi = api.injectEndpoints({ >({ query: (queryArg) => ({ url: `/blueprints`, - method: "POST", + method: 'POST', body: queryArg.createBlueprintRequest, }), }), @@ -34,7 +34,7 @@ const injectedRtkApi = api.injectEndpoints({ >({ query: (queryArg) => ({ url: `/blueprints/${queryArg.id}`, - method: "PUT", + method: 'PUT', body: queryArg.createBlueprintRequest, }), }), @@ -52,7 +52,7 @@ const injectedRtkApi = api.injectEndpoints({ >({ query: (queryArg) => ({ url: `/blueprints/${queryArg.id}`, - method: "DELETE", + method: 'DELETE', }), }), exportBlueprint: build.query< @@ -67,7 +67,7 @@ const injectedRtkApi = api.injectEndpoints({ >({ query: (queryArg) => ({ url: `/blueprints/${queryArg.id}/compose`, - method: "POST", + method: 'POST', body: queryArg.body, }), }), @@ -104,7 +104,7 @@ const injectedRtkApi = api.injectEndpoints({ cloneCompose: build.mutation({ query: (queryArg) => ({ url: `/composes/${queryArg.composeId}/clone`, - method: "POST", + method: 'POST', body: queryArg.cloneRequest, }), }), @@ -129,7 +129,7 @@ const injectedRtkApi = api.injectEndpoints({ composeImage: build.mutation({ query: (queryArg) => ({ url: `/compose`, - method: "POST", + method: 'POST', body: queryArg.composeRequest, }), }), @@ -167,7 +167,7 @@ const injectedRtkApi = api.injectEndpoints({ >({ query: (queryArg) => ({ url: `/experimental/recommendations`, - method: "POST", + method: 'POST', body: queryArg.recommendPackageRequest, }), }), @@ -308,7 +308,7 @@ export type GetPackagesApiArg = { /** distribution to look up packages for */ distribution: Distributions; /** architecture to look up packages for */ - architecture: "x86_64" | "aarch64"; + architecture: 'x86_64' | 'aarch64'; /** packages to look for */ search: string; /** max amount of packages, default 100 */ @@ -363,33 +363,33 @@ export type HttpErrorList = { errors: HttpError[]; }; export type Distributions = - | "rhel-8" - | "rhel-8-nightly" - | "rhel-84" - | "rhel-85" - | "rhel-86" - | "rhel-87" - | "rhel-88" - | "rhel-89" - | "rhel-8.10" - | "rhel-9" - | "rhel-9-nightly" - | "rhel-9-beta" - | "rhel-90" - | "rhel-91" - | "rhel-92" - | "rhel-93" - | "rhel-94" - | "rhel-95" - | "rhel-10-nightly" - | "rhel-10-beta" - | "centos-9" - | "centos-10" - | "fedora-37" - | "fedora-38" - | "fedora-39" - | "fedora-40" - | "fedora-41"; + | 'rhel-8' + | 'rhel-8-nightly' + | 'rhel-84' + | 'rhel-85' + | 'rhel-86' + | 'rhel-87' + | 'rhel-88' + | 'rhel-89' + | 'rhel-8.10' + | 'rhel-9' + | 'rhel-9-nightly' + | 'rhel-9-beta' + | 'rhel-90' + | 'rhel-91' + | 'rhel-92' + | 'rhel-93' + | 'rhel-94' + | 'rhel-95' + | 'rhel-10-nightly' + | 'rhel-10-beta' + | 'centos-9' + | 'centos-10' + | 'fedora-37' + | 'fedora-38' + | 'fedora-39' + | 'fedora-40' + | 'fedora-41'; export type ListResponseMeta = { count: number; }; @@ -413,27 +413,27 @@ export type CreateBlueprintResponse = { id: string; }; export type ImageTypes = - | "aws" - | "azure" - | "edge-commit" - | "edge-installer" - | "gcp" - | "guest-image" - | "image-installer" - | "oci" - | "vsphere" - | "vsphere-ova" - | "wsl" - | "ami" - | "rhel-edge-commit" - | "rhel-edge-installer" - | "vhd"; + | 'aws' + | 'azure' + | 'edge-commit' + | 'edge-installer' + | 'gcp' + | 'guest-image' + | 'image-installer' + | 'oci' + | 'vsphere' + | 'vsphere-ova' + | 'wsl' + | 'ami' + | 'rhel-edge-commit' + | 'rhel-edge-installer' + | 'vhd'; export type UploadTypes = - | "aws" - | "gcp" - | "azure" - | "aws.s3" - | "oci.objectstorage"; + | 'aws' + | 'gcp' + | 'azure' + | 'aws.s3' + | 'oci.objectstorage'; export type AwsUploadRequestOptions = { share_with_accounts?: string[] | undefined; share_with_sources?: string[] | undefined; @@ -481,7 +481,7 @@ export type AzureUploadRequestOptions = { /** Choose the VM Image HyperV generation, different features on Azure are available depending on the HyperV generation. */ - hyper_v_generation?: ("V1" | "V2") | undefined; + hyper_v_generation?: ('V1' | 'V2') | undefined; }; export type OciUploadRequestOptions = object; export type UploadRequest = { @@ -512,7 +512,7 @@ export type OsTree = { export type ImageRequest = { /** CPU architecture of the image, x86_64 and aarch64 are currently supported. */ - architecture: "x86_64" | "aarch64"; + architecture: 'x86_64' | 'aarch64'; image_type: ImageTypes; upload_request: UploadRequest; ostree?: OsTree | undefined; @@ -560,15 +560,15 @@ export type File = { /** Contents of the file as plain text */ data?: string | undefined; /** When data is base64-encoded to prevent Akamai content filter false positives */ - data_encoding?: ("plain" | "base64") | undefined; + data_encoding?: ('plain' | 'base64') | undefined; /** Ensure that the parent directories exist */ ensure_parents?: boolean | undefined; }; export type Subscription = { organization: number; - "activation-key": string; - "server-url": string; - "base-url": string; + 'activation-key': string; + 'server-url': string; + 'base-url': string; insights: boolean; /** Optional flag to use rhc to register the system, which also always enables Insights. */ @@ -696,7 +696,7 @@ export type Installer = { /** Create a kickstart file for a fully automated installation */ unattended?: boolean | undefined; - "sudo-nopasswd"?: string[] | undefined; + 'sudo-nopasswd'?: string[] | undefined; }; export type Customizations = { containers?: Container[] | undefined; @@ -732,7 +732,7 @@ export type Customizations = { uses LVM, even when there are no extra mountpoints. 'raw' uses raw partitions even when there are one or more mountpoints. */ - partitioning_mode?: ("raw" | "lvm" | "auto-lvm") | undefined; + partitioning_mode?: ('raw' | 'lvm' | 'auto-lvm') | undefined; fips?: Fips | undefined; installer?: Installer | undefined; }; @@ -779,7 +779,7 @@ export type BlueprintExportResponse = { export type ComposeResponse = { id: string; }; -export type ClientId = "api" | "ui"; +export type ClientId = 'api' | 'ui'; export type ComposeRequest = { distribution: Distributions; image_name?: string | undefined; @@ -822,7 +822,7 @@ export type OciUploadStatus = { url: string; }; export type UploadStatus = { - status: "success" | "failure" | "pending" | "running"; + status: 'success' | 'failure' | 'pending' | 'running'; type: UploadTypes; options: | AwsUploadStatus @@ -838,12 +838,12 @@ export type ComposeStatusError = { }; export type ImageStatus = { status: - | "success" - | "failure" - | "pending" - | "building" - | "uploading" - | "registering"; + | 'success' + | 'failure' + | 'pending' + | 'building' + | 'uploading' + | 'registering'; upload_status?: UploadStatus | undefined; error?: ComposeStatusError | undefined; }; @@ -891,26 +891,26 @@ export type PackagesResponse = { data: Package[]; }; export type DistributionProfileItem = - | "xccdf_org.ssgproject.content_profile_anssi_bp28_enhanced" - | "xccdf_org.ssgproject.content_profile_anssi_bp28_high" - | "xccdf_org.ssgproject.content_profile_anssi_bp28_intermediary" - | "xccdf_org.ssgproject.content_profile_anssi_bp28_minimal" - | "xccdf_org.ssgproject.content_profile_ccn_advanced" - | "xccdf_org.ssgproject.content_profile_ccn_basic" - | "xccdf_org.ssgproject.content_profile_ccn_intermediate" - | "xccdf_org.ssgproject.content_profile_cis" - | "xccdf_org.ssgproject.content_profile_cis_server_l1" - | "xccdf_org.ssgproject.content_profile_cis_workstation_l1" - | "xccdf_org.ssgproject.content_profile_cis_workstation_l2" - | "xccdf_org.ssgproject.content_profile_cui" - | "xccdf_org.ssgproject.content_profile_e8" - | "xccdf_org.ssgproject.content_profile_hipaa" - | "xccdf_org.ssgproject.content_profile_ism_o" - | "xccdf_org.ssgproject.content_profile_ospp" - | "xccdf_org.ssgproject.content_profile_pci-dss" - | "xccdf_org.ssgproject.content_profile_standard" - | "xccdf_org.ssgproject.content_profile_stig" - | "xccdf_org.ssgproject.content_profile_stig_gui"; + | 'xccdf_org.ssgproject.content_profile_anssi_bp28_enhanced' + | 'xccdf_org.ssgproject.content_profile_anssi_bp28_high' + | 'xccdf_org.ssgproject.content_profile_anssi_bp28_intermediary' + | 'xccdf_org.ssgproject.content_profile_anssi_bp28_minimal' + | 'xccdf_org.ssgproject.content_profile_ccn_advanced' + | 'xccdf_org.ssgproject.content_profile_ccn_basic' + | 'xccdf_org.ssgproject.content_profile_ccn_intermediate' + | 'xccdf_org.ssgproject.content_profile_cis' + | 'xccdf_org.ssgproject.content_profile_cis_server_l1' + | 'xccdf_org.ssgproject.content_profile_cis_workstation_l1' + | 'xccdf_org.ssgproject.content_profile_cis_workstation_l2' + | 'xccdf_org.ssgproject.content_profile_cui' + | 'xccdf_org.ssgproject.content_profile_e8' + | 'xccdf_org.ssgproject.content_profile_hipaa' + | 'xccdf_org.ssgproject.content_profile_ism_o' + | 'xccdf_org.ssgproject.content_profile_ospp' + | 'xccdf_org.ssgproject.content_profile_pci-dss' + | 'xccdf_org.ssgproject.content_profile_standard' + | 'xccdf_org.ssgproject.content_profile_stig' + | 'xccdf_org.ssgproject.content_profile_stig_gui'; export type DistributionProfileResponse = DistributionProfileItem[]; export type RecommendationsResponse = { packages: string[]; diff --git a/src/store/index.ts b/src/store/index.ts index 46557ae6..4cd4428f 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -3,14 +3,14 @@ import { combineReducers, configureStore } from '@reduxjs/toolkit'; import promiseMiddleware from 'redux-promise-middleware'; import { blueprintsSlice } from './BlueprintSlice'; -import { cockpitApi } from './cockpitApi'; +import { cockpitApi } from './cockpit/cockpitApi'; import { complianceApi } from './complianceApi'; import { contentSourcesApi } from './contentSourcesApi'; import { edgeApi } from './edgeApi'; -import { imageBuilderApi } from './enhancedImageBuilderApi'; import { listenerMiddleware, startAppListening } from './listenerMiddleware'; import { provisioningApi } from './provisioningApi'; import { rhsmApi } from './rhsmApi'; +import { imageBuilderApi } from './service/enhancedImageBuilderApi'; import wizardSlice, { changeArchitecture, changeDistribution, diff --git a/src/store/provisioningApi.ts b/src/store/provisioningApi.ts index b1f6ae82..d2b58c56 100644 --- a/src/store/provisioningApi.ts +++ b/src/store/provisioningApi.ts @@ -1,4 +1,4 @@ -import { emptyProvisioningApi as api } from "./emptyProvisioningApi"; +import { emptyProvisioningApi as api } from './service/emptyProvisioningApi'; const injectedRtkApi = api.injectEndpoints({ endpoints: (build) => ({ getSourceList: build.query({ @@ -22,7 +22,7 @@ export { injectedRtkApi as provisioningApi }; export type GetSourceListApiResponse = /** status 200 Returned on success. */ V1ListSourceResponse; export type GetSourceListApiArg = { - provider?: "aws" | "azure" | "gcp"; + provider?: 'aws' | 'azure' | 'gcp'; }; export type GetSourceUploadInfoApiResponse = /** status 200 Return on success. */ V1SourceUploadInfoResponse; diff --git a/src/store/rhsmApi.ts b/src/store/rhsmApi.ts index c37d922e..a2fd7f5d 100644 --- a/src/store/rhsmApi.ts +++ b/src/store/rhsmApi.ts @@ -1,4 +1,4 @@ -import { emptyRhsmApi as api } from "./emptyRhsmApi"; +import { emptyRhsmApi as api } from './service/emptyRhsmApi'; const injectedRtkApi = api.injectEndpoints({ endpoints: (build) => ({ listActivationKeys: build.query< @@ -13,7 +13,7 @@ const injectedRtkApi = api.injectEndpoints({ >({ query: (queryArg) => ({ url: `/activation_keys`, - method: "POST", + method: 'POST', body: queryArg.body, }), }), diff --git a/src/store/service/complianceApi.ts b/src/store/service/complianceApi.ts new file mode 100644 index 00000000..1e74e29d --- /dev/null +++ b/src/store/service/complianceApi.ts @@ -0,0 +1,160 @@ +import { emptyComplianceApi as api } from "./emptyComplianceApi"; +const injectedRtkApi = api.injectEndpoints({ + endpoints: (build) => ({ + policies: build.query({ + query: (queryArg) => ({ + url: `/policies`, + headers: { + "X-RH-IDENTITY": queryArg["X-RH-IDENTITY"], + }, + params: { + limit: queryArg.limit, + offset: queryArg.offset, + ids_only: queryArg.idsOnly, + sort_by: queryArg.sortBy, + filter: queryArg.filter, + }, + }), + }), + policy: build.query({ + query: (queryArg) => ({ + url: `/policies/${queryArg.policyId}`, + headers: { + "X-RH-IDENTITY": queryArg["X-RH-IDENTITY"], + }, + }), + }), + }), + overrideExisting: false, +}); +export { injectedRtkApi as complianceApi }; +export type PoliciesApiResponse = /** status 200 Lists Policies */ { + meta?: MetadataRead | undefined; + links?: LinksRead | undefined; + data?: + | { + schema?: PolicyRead | undefined; + }[] + | undefined; +}; +export type PoliciesApiArg = { + /** For internal use only */ + "X-RH-IDENTITY"?: string; + /** Number of items to return per page */ + limit?: number; + /** Offset of first item of paginated response */ + offset?: number; + /** Indicates whether to return only resource IDs. */ + idsOnly?: boolean; + /** Attribute and direction to sort the items by. Represented by an array of fields with an optional direction (`:asc` or `:desc`).

If no direction is selected, `:asc` is used by default. */ + sortBy?: ( + | "title" + | "os_major_version" + | "total_system_count" + | "business_objective" + | "compliance_threshold" + | "title:asc" + | "title:desc" + | "os_major_version:asc" + | "os_major_version:desc" + | "total_system_count:asc" + | "total_system_count:desc" + | "business_objective:asc" + | "business_objective:desc" + | "compliance_threshold:asc" + | "compliance_threshold:desc" + )[]; + /** Query string to filter items by their attributes. Compliant with scoped_search query language. However, only `=` or `!=` (resp. `<>`) operators are supported.

Policies are searchable using attributes `title`, `os_major_version`, and `os_minor_version`

(e.g.: `(field_1=something AND field_2!="something else") OR field_3>40`) */ + filter?: string; +}; +export type PolicyApiResponse = /** status 200 Returns a Policy */ { + data?: + | { + schema?: PolicyRead | undefined; + } + | undefined; +}; +export type PolicyApiArg = { + /** For internal use only */ + "X-RH-IDENTITY"?: string; + policyId: string; +}; +export type Metadata = { + /** Attribute and direction the items are sorted by */ + sort_by?: string | undefined; + /** Query string used to filter items by their attributes */ + filter?: string | undefined; +}; +export type MetadataRead = { + /** Total number of items */ + total?: number | undefined; + /** Number of items returned per page */ + limit?: number | undefined; + /** Offset of the first item of paginated response */ + offset?: number | undefined; + /** Attribute and direction the items are sorted by */ + sort_by?: string | undefined; + /** Query string used to filter items by their attributes */ + filter?: string | undefined; +}; +export type Links = {}; +export type LinksRead = { + /** Link to first page */ + first?: string | undefined; + /** Link to last page */ + last?: string | undefined; + /** Link to previous page */ + previous?: string | undefined; + /** Link to next page */ + next?: string | undefined; +}; +export type Id = string; +export type IdRead = string; +export type Policy = { + id?: Id | undefined; + /** Short title of the Policy */ + title?: string | undefined; + /** Longer description of the Policy */ + description?: string | undefined; + /** The Business Objective associated to the Policy */ + business_objective?: string | undefined; + /** The percentage above which the Policy meets compliance requirements */ + compliance_threshold: number; +}; +export type PolicyRead = { + id?: IdRead | undefined; + type?: "policy" | undefined; + /** Short title of the Policy */ + title?: string | undefined; + /** Longer description of the Policy */ + description?: string | undefined; + /** The Business Objective associated to the Policy */ + business_objective?: string | undefined; + /** The percentage above which the Policy meets compliance requirements */ + compliance_threshold: number; + /** Major version of the Operating System that the Policy covers */ + os_major_version?: number | undefined; + /** Identificator of the Profile */ + ref_id?: string | undefined; + /** Title of the associated Policy */ + profile_title?: string | undefined; + /** The number of Systems assigned to this Policy */ + total_system_count?: number | undefined; +}; +export type PolicyWrite = { + id?: Id | undefined; + /** Short title of the Policy */ + title?: string | undefined; + /** Longer description of the Policy */ + description?: string | undefined; + /** The Business Objective associated to the Policy */ + business_objective?: string | undefined; + /** The percentage above which the Policy meets compliance requirements */ + compliance_threshold: number; + /** Identifier of the underlying Profile */ + profile_id: string; +}; +export type Errors = { + errors: string[]; +}; +export const { usePoliciesQuery, usePolicyQuery } = injectedRtkApi; diff --git a/src/store/service/contentSourcesApi.ts b/src/store/service/contentSourcesApi.ts new file mode 100644 index 00000000..511a4b6c --- /dev/null +++ b/src/store/service/contentSourcesApi.ts @@ -0,0 +1,612 @@ +import { emptyContentSourcesApi as api } from "./emptyContentSourcesApi"; +const injectedRtkApi = api.injectEndpoints({ + endpoints: (build) => ({ + listFeatures: build.query({ + query: () => ({ url: `/features/` }), + }), + searchPackageGroup: build.mutation< + SearchPackageGroupApiResponse, + SearchPackageGroupApiArg + >({ + query: (queryArg) => ({ + url: `/package_groups/names`, + method: "POST", + body: queryArg.apiContentUnitSearchRequest, + }), + }), + listRepositories: build.query< + ListRepositoriesApiResponse, + ListRepositoriesApiArg + >({ + query: (queryArg) => ({ + url: `/repositories/`, + params: { + offset: queryArg.offset, + limit: queryArg.limit, + version: queryArg.version, + arch: queryArg.arch, + available_for_version: queryArg.availableForVersion, + available_for_arch: queryArg.availableForArch, + search: queryArg.search, + name: queryArg.name, + url: queryArg.url, + uuid: queryArg.uuid, + sort_by: queryArg.sortBy, + status: queryArg.status, + origin: queryArg.origin, + content_type: queryArg.contentType, + }, + }), + }), + createRepository: build.mutation< + CreateRepositoryApiResponse, + CreateRepositoryApiArg + >({ + query: (queryArg) => ({ + url: `/repositories/`, + method: "POST", + body: queryArg.apiRepositoryRequest, + }), + }), + bulkImportRepositories: build.mutation< + BulkImportRepositoriesApiResponse, + BulkImportRepositoriesApiArg + >({ + query: (queryArg) => ({ + url: `/repositories/bulk_import/`, + method: "POST", + body: queryArg.body, + }), + }), + listRepositoriesRpms: build.query< + ListRepositoriesRpmsApiResponse, + ListRepositoriesRpmsApiArg + >({ + query: (queryArg) => ({ + url: `/repositories/${queryArg.uuid}/rpms`, + params: { + limit: queryArg.limit, + offset: queryArg.offset, + search: queryArg.search, + sort_by: queryArg.sortBy, + }, + }), + }), + searchRpm: build.mutation({ + query: (queryArg) => ({ + url: `/rpms/names`, + method: "POST", + body: queryArg.apiContentUnitSearchRequest, + }), + }), + listSnapshotsByDate: build.mutation< + ListSnapshotsByDateApiResponse, + ListSnapshotsByDateApiArg + >({ + query: (queryArg) => ({ + url: `/snapshots/for_date/`, + method: "POST", + body: queryArg.apiListSnapshotByDateRequest, + }), + }), + }), + overrideExisting: false, +}); +export { injectedRtkApi as contentSourcesApi }; +export type ListFeaturesApiResponse = /** status 200 OK */ ApiFeatureSet; +export type ListFeaturesApiArg = void; +export type SearchPackageGroupApiResponse = + /** status 200 OK */ ApiSearchPackageGroupResponse[]; +export type SearchPackageGroupApiArg = { + /** request body */ + apiContentUnitSearchRequest: ApiContentUnitSearchRequest; +}; +export type ListRepositoriesApiResponse = + /** status 200 OK */ ApiRepositoryCollectionResponseRead; +export type ListRepositoriesApiArg = { + /** Starting point for retrieving a subset of results. Determines how many items to skip from the beginning of the result set. Default value:`0`. */ + offset?: number; + /** Number of items to include in response. Use it to control the number of items, particularly when dealing with large datasets. Default value: `100`. */ + limit?: number; + /** A comma separated list of release versions to filter on. For example, `1,2` would return repositories with versions 1 or 2 only. */ + version?: string; + /** A comma separated list of architectures or platforms for that you want to retrieve repositories. It controls responses where repositories support multiple architectures or platforms. For example, ‘x86_64,s390x' returns repositories with `x86_64` or `s390x` only. */ + arch?: string; + /** Filter repositories by supported release version. For example, `1` returns repositories with the version `1` or where version is not set. */ + availableForVersion?: string; + /** Filter repositories by architecture. For example, `x86_64` returns repositories with the version `x86_64` or where architecture is not set. */ + availableForArch?: string; + /** Term to filter and retrieve items that match the specified search criteria. Search term can include name or URL. */ + search?: string; + /** Filter repositories by name. */ + name?: string; + /** A comma separated list of URLs to control api response. */ + url?: string; + /** A comma separated list of UUIDs to control api response. */ + uuid?: string; + /** Sort the response data based on specific repository parameters. Sort criteria can include `name`, `url`, `status`, and `package_count`. */ + sortBy?: string; + /** A comma separated list of statuses to control api response. Statuses can include `Pending`, `Valid`, `Invalid`, `Unavailable`. */ + status?: string; + /** A comma separated list of origins to filter api response. Origins can include `red_hat` and `external`. */ + origin?: string; + /** content type of a repository to filter on (rpm) */ + contentType?: string; +}; +export type CreateRepositoryApiResponse = + /** status 201 Created */ ApiRepositoryResponseRead; +export type CreateRepositoryApiArg = { + /** request body */ + apiRepositoryRequest: ApiRepositoryRequest; +}; +export type BulkImportRepositoriesApiResponse = + /** status 201 Created */ ApiRepositoryImportResponseRead[]; +export type BulkImportRepositoriesApiArg = { + /** request body */ + body: ApiRepositoryRequest[]; +}; +export type ListRepositoriesRpmsApiResponse = + /** status 200 OK */ ApiRepositoryRpmCollectionResponse; +export type ListRepositoriesRpmsApiArg = { + /** Repository ID. */ + uuid: string; + /** Number of items to include in response. Use it to control the number of items, particularly when dealing with large datasets. Default value: `100`. */ + limit?: number; + /** Starting point for retrieving a subset of results. Determines how many items to skip from the beginning of the result set. Default value:`0`. */ + offset?: number; + /** Term to filter and retrieve items that match the specified search criteria. Search term can include name. */ + search?: string; + /** Sort the response based on specific repository parameters. Sort criteria can include `name`, `url`, `status`, and `package_count`. */ + sortBy?: string; +}; +export type SearchRpmApiResponse = /** status 200 OK */ ApiSearchRpmResponse[]; +export type SearchRpmApiArg = { + /** request body */ + apiContentUnitSearchRequest: ApiContentUnitSearchRequest; +}; +export type ListSnapshotsByDateApiResponse = + /** status 200 OK */ ApiListSnapshotByDateResponse; +export type ListSnapshotsByDateApiArg = { + /** request body */ + apiListSnapshotByDateRequest: ApiListSnapshotByDateRequest; +}; +export type ApiFeature = { + /** Whether the current user can access the feature */ + accessible?: boolean | undefined; + /** Whether the feature is enabled on the running server */ + enabled?: boolean | undefined; +}; +export type ApiFeatureSet = { + [key: string]: ApiFeature; +}; +export type ApiSearchPackageGroupResponse = { + /** Description of the package group found */ + description?: string | undefined; + /** Package group ID */ + id?: string | undefined; + /** Name of package group found */ + package_group_name?: string | undefined; + /** Package list of the package group found */ + package_list?: string[] | undefined; +}; +export type ErrorsHandlerError = { + /** An explanation specific to the problem */ + detail?: string | undefined; + /** HTTP status code applicable to the error */ + status?: number | undefined; + /** A summary of the problem */ + title?: string | undefined; +}; +export type ErrorsErrorResponse = { + errors?: ErrorsHandlerError[] | undefined; +}; +export type ApiContentUnitSearchRequest = { + /** List of names to search using an exact match */ + exact_names?: string[] | undefined; + /** Maximum number of records to return for the search */ + limit?: number | undefined; + /** Search string to search content unit names */ + search?: string | undefined; + /** URLs of repositories to search */ + urls?: string[] | undefined; + /** List of repository UUIDs to search */ + uuids?: string[] | undefined; +}; +export type ApiSnapshotResponse = { + /** Count of each content type */ + added_counts?: + | { + [key: string]: number; + } + | undefined; + /** Count of each content type */ + content_counts?: + | { + [key: string]: number; + } + | undefined; + /** Datetime the snapshot was created */ + created_at?: string | undefined; + /** Count of each content type */ + removed_counts?: + | { + [key: string]: number; + } + | undefined; + /** Name of repository the snapshot belongs to */ + repository_name?: string | undefined; + /** Path to repository snapshot contents */ + repository_path?: string | undefined; + /** UUID of the repository the snapshot belongs to */ + repository_uuid?: string | undefined; + /** URL to the snapshot's content */ + url?: string | undefined; + uuid?: string | undefined; +}; +export type ApiTaskInfoResponse = { + /** Timestamp of task creation */ + created_at?: string | undefined; + /** UUIDs of parent tasks */ + dependencies?: string[] | undefined; + /** UUIDs of child tasks */ + dependents?: string[] | undefined; + /** Timestamp task ended running at */ + ended_at?: string | undefined; + /** Error thrown while running task */ + error?: string | undefined; + /** Name of the associated repository or template */ + object_name?: string | undefined; + /** Type of the associated object, either repository or template */ + object_type?: string | undefined; + /** UUID of the associated repository or template */ + object_uuid?: string | undefined; + /** Organization ID of the owner */ + org_id?: string | undefined; + /** Status of task (running, failed, completed, canceled, pending) */ + status?: string | undefined; + /** Type of task */ + type?: string | undefined; + /** UUID of the object */ + uuid?: string | undefined; +}; +export type ApiRepositoryResponse = { + /** Content Type (rpm) of the repository */ + content_type?: string | undefined; + /** Architecture to restrict client usage to */ + distribution_arch?: string | undefined; + /** Versions to restrict client usage to */ + distribution_versions?: string[] | undefined; + /** Number of consecutive failed introspections */ + failed_introspections_count?: number | undefined; + /** GPG key for repository */ + gpg_key?: string | undefined; + /** Label used to configure the yum repository on clients */ + label?: string | undefined; + /** Error of last attempted introspection */ + last_introspection_error?: string | undefined; + /** Status of last introspection */ + last_introspection_status?: string | undefined; + /** Timestamp of last attempted introspection */ + last_introspection_time?: string | undefined; + last_snapshot?: ApiSnapshotResponse | undefined; + last_snapshot_task?: ApiTaskInfoResponse | undefined; + /** UUID of the last snapshot task */ + last_snapshot_task_uuid?: string | undefined; + /** UUID of the last dao.Snapshot */ + last_snapshot_uuid?: string | undefined; + /** Timestamp of last successful introspection */ + last_success_introspection_time?: string | undefined; + /** Timestamp of last introspection that had updates */ + last_update_introspection_time?: string | undefined; + /** Latest URL for the snapshot distribution */ + latest_snapshot_url?: string | undefined; + /** Verify packages */ + metadata_verification?: boolean | undefined; + /** Disable modularity filtering on this repository */ + module_hotfixes?: boolean | undefined; + /** Name of the remote yum repository */ + name?: string | undefined; + /** Origin of the repository */ + origin?: string | undefined; + /** Number of packages last read in the repository */ + package_count?: number | undefined; + /** Enable snapshotting and hosting of this repository */ + snapshot?: boolean | undefined; + /** Combined status of last introspection and snapshot of repository (Valid, Invalid, Unavailable, Pending) */ + status?: string | undefined; + /** URL of the remote yum repository */ + url?: string | undefined; +}; +export type ApiRepositoryResponseRead = { + /** Account ID of the owner */ + account_id?: string | undefined; + /** Content Type (rpm) of the repository */ + content_type?: string | undefined; + /** Architecture to restrict client usage to */ + distribution_arch?: string | undefined; + /** Versions to restrict client usage to */ + distribution_versions?: string[] | undefined; + /** Number of consecutive failed introspections */ + failed_introspections_count?: number | undefined; + /** GPG key for repository */ + gpg_key?: string | undefined; + /** Label used to configure the yum repository on clients */ + label?: string | undefined; + /** Error of last attempted introspection */ + last_introspection_error?: string | undefined; + /** Status of last introspection */ + last_introspection_status?: string | undefined; + /** Timestamp of last attempted introspection */ + last_introspection_time?: string | undefined; + last_snapshot?: ApiSnapshotResponse | undefined; + last_snapshot_task?: ApiTaskInfoResponse | undefined; + /** UUID of the last snapshot task */ + last_snapshot_task_uuid?: string | undefined; + /** UUID of the last dao.Snapshot */ + last_snapshot_uuid?: string | undefined; + /** Timestamp of last successful introspection */ + last_success_introspection_time?: string | undefined; + /** Timestamp of last introspection that had updates */ + last_update_introspection_time?: string | undefined; + /** Latest URL for the snapshot distribution */ + latest_snapshot_url?: string | undefined; + /** Verify packages */ + metadata_verification?: boolean | undefined; + /** Disable modularity filtering on this repository */ + module_hotfixes?: boolean | undefined; + /** Name of the remote yum repository */ + name?: string | undefined; + /** Organization ID of the owner */ + org_id?: string | undefined; + /** Origin of the repository */ + origin?: string | undefined; + /** Number of packages last read in the repository */ + package_count?: number | undefined; + /** Enable snapshotting and hosting of this repository */ + snapshot?: boolean | undefined; + /** Combined status of last introspection and snapshot of repository (Valid, Invalid, Unavailable, Pending) */ + status?: string | undefined; + /** URL of the remote yum repository */ + url?: string | undefined; + /** UUID of the object */ + uuid?: string | undefined; +}; +export type ApiLinks = { + /** Path to first page of results */ + first?: string | undefined; + /** Path to last page of results */ + last?: string | undefined; + /** Path to next page of results */ + next?: string | undefined; + /** Path to previous page of results */ + prev?: string | undefined; +}; +export type ApiResponseMetadata = { + /** Total count of results */ + count?: number | undefined; + /** Limit of results used for the request */ + limit?: number | undefined; + /** Offset into results used for the request */ + offset?: number | undefined; +}; +export type ApiRepositoryCollectionResponse = { + /** Requested Data */ + data?: ApiRepositoryResponse[] | undefined; + links?: ApiLinks | undefined; + meta?: ApiResponseMetadata | undefined; +}; +export type ApiRepositoryCollectionResponseRead = { + /** Requested Data */ + data?: ApiRepositoryResponseRead[] | undefined; + links?: ApiLinks | undefined; + meta?: ApiResponseMetadata | undefined; +}; +export type ApiRepositoryRequest = { + /** Architecture to restrict client usage to */ + distribution_arch?: string | undefined; + /** Versions to restrict client usage to */ + distribution_versions?: string[] | undefined; + /** GPG key for repository */ + gpg_key?: string | undefined; + /** Verify packages */ + metadata_verification?: boolean | undefined; + /** Disable modularity filtering on this repository */ + module_hotfixes?: boolean | undefined; + /** Name of the remote yum repository */ + name: string; + /** Enable snapshotting and hosting of this repository */ + snapshot?: boolean | undefined; + /** URL of the remote yum repository */ + url?: string | undefined; +}; +export type ApiRepositoryRequestRead = { + /** Architecture to restrict client usage to */ + distribution_arch?: string | undefined; + /** Versions to restrict client usage to */ + distribution_versions?: string[] | undefined; + /** GPG key for repository */ + gpg_key?: string | undefined; + /** Verify packages */ + metadata_verification?: boolean | undefined; + /** Disable modularity filtering on this repository */ + module_hotfixes?: boolean | undefined; + /** Name of the remote yum repository */ + name: string; + /** Origin of the repository */ + origin?: string | undefined; + /** Enable snapshotting and hosting of this repository */ + snapshot?: boolean | undefined; + /** URL of the remote yum repository */ + url?: string | undefined; +}; +export type ApiRepositoryImportResponse = { + /** Content Type (rpm) of the repository */ + content_type?: string | undefined; + /** Architecture to restrict client usage to */ + distribution_arch?: string | undefined; + /** Versions to restrict client usage to */ + distribution_versions?: string[] | undefined; + /** Number of consecutive failed introspections */ + failed_introspections_count?: number | undefined; + /** GPG key for repository */ + gpg_key?: string | undefined; + /** Label used to configure the yum repository on clients */ + label?: string | undefined; + /** Error of last attempted introspection */ + last_introspection_error?: string | undefined; + /** Status of last introspection */ + last_introspection_status?: string | undefined; + /** Timestamp of last attempted introspection */ + last_introspection_time?: string | undefined; + last_snapshot?: ApiSnapshotResponse | undefined; + last_snapshot_task?: ApiTaskInfoResponse | undefined; + /** UUID of the last snapshot task */ + last_snapshot_task_uuid?: string | undefined; + /** UUID of the last dao.Snapshot */ + last_snapshot_uuid?: string | undefined; + /** Timestamp of last successful introspection */ + last_success_introspection_time?: string | undefined; + /** Timestamp of last introspection that had updates */ + last_update_introspection_time?: string | undefined; + /** Latest URL for the snapshot distribution */ + latest_snapshot_url?: string | undefined; + /** Verify packages */ + metadata_verification?: boolean | undefined; + /** Disable modularity filtering on this repository */ + module_hotfixes?: boolean | undefined; + /** Name of the remote yum repository */ + name?: string | undefined; + /** Origin of the repository */ + origin?: string | undefined; + /** Number of packages last read in the repository */ + package_count?: number | undefined; + /** Enable snapshotting and hosting of this repository */ + snapshot?: boolean | undefined; + /** Combined status of last introspection and snapshot of repository (Valid, Invalid, Unavailable, Pending) */ + status?: string | undefined; + /** URL of the remote yum repository */ + url?: string | undefined; + /** Warnings to alert user of mismatched fields if there is an existing repo with the same URL */ + warnings?: + | { + [key: string]: any; + }[] + | undefined; +}; +export type ApiRepositoryImportResponseRead = { + /** Account ID of the owner */ + account_id?: string | undefined; + /** Content Type (rpm) of the repository */ + content_type?: string | undefined; + /** Architecture to restrict client usage to */ + distribution_arch?: string | undefined; + /** Versions to restrict client usage to */ + distribution_versions?: string[] | undefined; + /** Number of consecutive failed introspections */ + failed_introspections_count?: number | undefined; + /** GPG key for repository */ + gpg_key?: string | undefined; + /** Label used to configure the yum repository on clients */ + label?: string | undefined; + /** Error of last attempted introspection */ + last_introspection_error?: string | undefined; + /** Status of last introspection */ + last_introspection_status?: string | undefined; + /** Timestamp of last attempted introspection */ + last_introspection_time?: string | undefined; + last_snapshot?: ApiSnapshotResponse | undefined; + last_snapshot_task?: ApiTaskInfoResponse | undefined; + /** UUID of the last snapshot task */ + last_snapshot_task_uuid?: string | undefined; + /** UUID of the last dao.Snapshot */ + last_snapshot_uuid?: string | undefined; + /** Timestamp of last successful introspection */ + last_success_introspection_time?: string | undefined; + /** Timestamp of last introspection that had updates */ + last_update_introspection_time?: string | undefined; + /** Latest URL for the snapshot distribution */ + latest_snapshot_url?: string | undefined; + /** Verify packages */ + metadata_verification?: boolean | undefined; + /** Disable modularity filtering on this repository */ + module_hotfixes?: boolean | undefined; + /** Name of the remote yum repository */ + name?: string | undefined; + /** Organization ID of the owner */ + org_id?: string | undefined; + /** Origin of the repository */ + origin?: string | undefined; + /** Number of packages last read in the repository */ + package_count?: number | undefined; + /** Enable snapshotting and hosting of this repository */ + snapshot?: boolean | undefined; + /** Combined status of last introspection and snapshot of repository (Valid, Invalid, Unavailable, Pending) */ + status?: string | undefined; + /** URL of the remote yum repository */ + url?: string | undefined; + /** UUID of the object */ + uuid?: string | undefined; + /** Warnings to alert user of mismatched fields if there is an existing repo with the same URL */ + warnings?: + | { + [key: string]: any; + }[] + | undefined; +}; +export type ApiRepositoryRpm = { + /** The architecture of the rpm */ + arch?: string | undefined; + /** The checksum of the rpm */ + checksum?: string | undefined; + /** The epoch of the rpm */ + epoch?: number | undefined; + /** The rpm package name */ + name?: string | undefined; + /** The release of the rpm */ + release?: string | undefined; + /** The summary of the rpm */ + summary?: string | undefined; + /** Identifier of the rpm */ + uuid?: string | undefined; + /** The version of the rpm */ + version?: string | undefined; +}; +export type ApiRepositoryRpmCollectionResponse = { + /** List of rpms */ + data?: ApiRepositoryRpm[] | undefined; + links?: ApiLinks | undefined; + meta?: ApiResponseMetadata | undefined; +}; +export type ApiSearchRpmResponse = { + /** Package name found */ + package_name?: string | undefined; + /** Summary of the package found */ + summary?: string | undefined; +}; +export type ApiSnapshotForDate = { + /** Is the snapshot after the specified date */ + is_after?: boolean | undefined; + match?: ApiSnapshotResponse | undefined; + /** Repository uuid for associated snapshot */ + repository_uuid?: string | undefined; +}; +export type ApiListSnapshotByDateResponse = { + /** Requested Data */ + data?: ApiSnapshotForDate[] | undefined; +}; +export type ApiListSnapshotByDateRequest = { + /** Exact date to search by. */ + date: string; + /** Repository UUIDs to find snapshots for */ + repository_uuids: string[]; +}; +export const { + useListFeaturesQuery, + useSearchPackageGroupMutation, + useListRepositoriesQuery, + useCreateRepositoryMutation, + useBulkImportRepositoriesMutation, + useListRepositoriesRpmsQuery, + useSearchRpmMutation, + useListSnapshotsByDateMutation, +} = injectedRtkApi; diff --git a/src/store/service/edgeApi.ts b/src/store/service/edgeApi.ts new file mode 100644 index 00000000..6034c289 --- /dev/null +++ b/src/store/service/edgeApi.ts @@ -0,0 +1,571 @@ +import { emptyEdgeApi as api } from "./emptyEdgeApi"; +const injectedRtkApi = api.injectEndpoints({ + endpoints: (build) => ({ + listAllImageSets: build.query< + ListAllImageSetsApiResponse, + ListAllImageSetsApiArg + >({ + query: (queryArg) => ({ + url: `/image-sets`, + params: { + sort_by: queryArg.sortBy, + name: queryArg.name, + status: queryArg.status, + limit: queryArg.limit, + offset: queryArg.offset, + }, + }), + }), + getImageSetsView: build.query< + GetImageSetsViewApiResponse, + GetImageSetsViewApiArg + >({ + query: (queryArg) => ({ + url: `/image-sets/view`, + params: { + sort_by: queryArg.sortBy, + name: queryArg.name, + status: queryArg.status, + id: queryArg.id, + limit: queryArg.limit, + offset: queryArg.offset, + }, + }), + }), + getImageSetImageView: build.query< + GetImageSetImageViewApiResponse, + GetImageSetImageViewApiArg + >({ + query: (queryArg) => ({ + url: `/image-sets/view/${queryArg.imageSetId}/versions/${queryArg.imageId}`, + }), + }), + getAllImageSetImagesView: build.query< + GetAllImageSetImagesViewApiResponse, + GetAllImageSetImagesViewApiArg + >({ + query: (queryArg) => ({ + url: `/image-sets/view/${queryArg.imageSetId}/versions`, + params: { + sort_by: queryArg.sortBy, + status: queryArg.status, + version: queryArg.version, + limit: queryArg.limit, + offset: queryArg.offset, + }, + }), + }), + deleteImageSet: build.mutation< + DeleteImageSetApiResponse, + DeleteImageSetApiArg + >({ + query: (queryArg) => ({ + url: `/image-sets/${queryArg.imageSetId}`, + method: "DELETE", + }), + }), + getAllImages: build.query({ + query: (queryArg) => ({ + url: `/images`, + params: { + limit: queryArg.limit, + offset: queryArg.offset, + sort_by: queryArg.sortBy, + name: queryArg.name, + status: queryArg.status, + distribution: queryArg.distribution, + created_at: queryArg.createdAt, + }, + }), + }), + createImage: build.mutation({ + query: (queryArg) => ({ + url: `/images`, + method: "POST", + body: queryArg.createImage, + }), + }), + checkImageName: build.mutation< + CheckImageNameApiResponse, + CheckImageNameApiArg + >({ + query: (queryArg) => ({ + url: `/images/checkImageName`, + method: "POST", + body: queryArg.createImage, + }), + }), + createInstallerForImage: build.mutation< + CreateInstallerForImageApiResponse, + CreateInstallerForImageApiArg + >({ + query: (queryArg) => ({ + url: `/images/${queryArg.imageId}/installer`, + method: "POST", + body: queryArg.createImage, + }), + }), + createKickStartForImage: build.mutation< + CreateKickStartForImageApiResponse, + CreateKickStartForImageApiArg + >({ + query: (queryArg) => ({ + url: `/images/${queryArg.imageId}/kickstart`, + method: "POST", + body: queryArg.createImage, + }), + }), + getMetadataForImage: build.query< + GetMetadataForImageApiResponse, + GetMetadataForImageApiArg + >({ + query: (queryArg) => ({ url: `/images/${queryArg.imageId}/metadata` }), + }), + getRepoForImage: build.query< + GetRepoForImageApiResponse, + GetRepoForImageApiArg + >({ + query: (queryArg) => ({ url: `/images/${queryArg.imageId}/repo` }), + }), + retryCreateImage: build.mutation< + RetryCreateImageApiResponse, + RetryCreateImageApiArg + >({ + query: (queryArg) => ({ + url: `/images/${queryArg.imageId}/retry`, + method: "POST", + body: queryArg.createImage, + }), + }), + createImageUpdate: build.mutation< + CreateImageUpdateApiResponse, + CreateImageUpdateApiArg + >({ + query: (queryArg) => ({ + url: `/images/${queryArg.imageId}/update`, + method: "POST", + body: queryArg.createImage, + }), + }), + getImageByOstree: build.query< + GetImageByOstreeApiResponse, + GetImageByOstreeApiArg + >({ + query: (queryArg) => ({ + url: `/images/${queryArg.ostreeCommitHash}/info`, + }), + }), + }), + overrideExisting: false, +}); +export { injectedRtkApi as edgeApi }; +export type ListAllImageSetsApiResponse = + /** status 200 OK */ ModelsImageSetsResponseApi; +export type ListAllImageSetsApiArg = { + /** Define sort fields: created_at, updated_at, name. To sort DESC use - */ + sortBy?: string; + /** field: filter by name */ + name?: string; + /** field: filter by status */ + status?: string; + /** field: return number of image-set view until limit is reached. Default is 100. */ + limit?: number; + /** field: return number of image-set view beginning at the offset. */ + offset?: number; +}; +export type GetImageSetsViewApiResponse = + /** status 200 OK */ ModelsImageSetsViewResponseApi; +export type GetImageSetsViewApiArg = { + /** Define sort fields: created_at, updated_at, name. To sort DESC use - */ + sortBy?: string; + /** field: filter by name */ + name?: string; + /** field: filter by status */ + status?: string; + /** field: filter by id */ + id?: number; + /** field: return number of image-set view until limit is reached. Default is 30. */ + limit?: number; + /** field: return number of image-set view beginning at the offset. */ + offset?: number; +}; +export type GetImageSetImageViewApiResponse = + /** status 200 OK */ ModelsImageSetImageIdViewApi; +export type GetImageSetImageViewApiArg = { + /** the image set id */ + imageSetId: number; + /** the image id */ + imageId: number; +}; +export type GetAllImageSetImagesViewApiResponse = + /** status 200 OK */ ModelsImagesViewDataApi; +export type GetAllImageSetImagesViewApiArg = { + /** the image-set id */ + imageSetId: number; + /** Define sort fields: created_at, version, To sort DESC use - */ + sortBy?: string; + /** field: filter by status */ + status?: string; + /** field: filter by version */ + version?: string; + /** field: return number of images until limit is reached. Default is 100. */ + limit?: number; + /** field: return number of images beginning at the offset. */ + offset?: number; +}; +export type DeleteImageSetApiResponse = /** status 200 OK */ ModelsImageSetApi; +export type DeleteImageSetApiArg = { + /** Identifier of the ImageSet */ + imageSetId: number; +}; +export type GetAllImagesApiResponse = + /** status 200 OK */ ModelsSuccessPlaceholderResponse; +export type GetAllImagesApiArg = { + /** Return number of images until limit is reached. */ + limit?: number; + /** Return number of images beginning at the offset */ + offset?: number; + /** created_at, distribution, name,status. To sort DESC use -before the fields */ + sortBy?: string; + /** Filter by name. */ + name?: string; + /** Filter by status. */ + status?: string; + /** Filter by distribution. */ + distribution?: string; + /** Filter by creation date. */ + createdAt?: string; +}; +export type CreateImageApiResponse = /** status 200 OK */ ImageResponse; +export type CreateImageApiArg = { + /** request body */ + createImage: CreateImage; +}; +export type CheckImageNameApiResponse = + /** status 200 OK */ ModelsSuccessPlaceholderResponse; +export type CheckImageNameApiArg = { + /** request body */ + createImage: CreateImage; +}; +export type CreateInstallerForImageApiResponse = + /** status 200 OK */ ModelsSuccessPlaceholderResponse; +export type CreateInstallerForImageApiArg = { + /** Image ID */ + imageId: number; + /** request body */ + createImage: CreateImage; +}; +export type CreateKickStartForImageApiResponse = + /** status 200 OK */ ModelsSuccessPlaceholderResponse; +export type CreateKickStartForImageApiArg = { + /** Image ID */ + imageId: number; + /** request body */ + createImage: CreateImage; +}; +export type GetMetadataForImageApiResponse = + /** status 200 OK */ ModelsSuccessPlaceholderResponse; +export type GetMetadataForImageApiArg = { + /** Image ID */ + imageId: number; +}; +export type GetRepoForImageApiResponse = + /** status 200 OK */ ModelsSuccessPlaceholderResponse; +export type GetRepoForImageApiArg = { + /** Image ID */ + imageId: number; +}; +export type RetryCreateImageApiResponse = + /** status 201 Retry is being processed */ ModelsSuccessPlaceholderResponse; +export type RetryCreateImageApiArg = { + /** Image ID */ + imageId: number; + /** request body */ + createImage: CreateImage; +}; +export type CreateImageUpdateApiResponse = + /** status 200 OK */ ModelsSuccessPlaceholderResponse; +export type CreateImageUpdateApiArg = { + /** Image ID */ + imageId: number; + /** request body */ + createImage: CreateImage; +}; +export type GetImageByOstreeApiResponse = + /** status 200 OK */ ModelsSuccessPlaceholderResponse; +export type GetImageByOstreeApiArg = { + /** Ostree Commit Hash */ + ostreeCommitHash: string; +}; +export type ModelsEdgeApiTime = { + time?: string | undefined; + /** Valid is true if Time is not NULL */ + valid?: boolean | undefined; +}; +export type GormDeletedAt = { + time?: string | undefined; + /** Valid is true if Time is not NULL */ + valid?: boolean | undefined; +}; +export type ModelsInstalledPackage = { + CreatedAt?: ModelsEdgeApiTime | undefined; + DeletedAt?: GormDeletedAt | undefined; + ID?: number | undefined; + UpdatedAt?: ModelsEdgeApiTime | undefined; + arch?: string | undefined; + commits?: ModelsCommit[] | undefined; + epoch?: string | undefined; + name?: string | undefined; + release?: string | undefined; + sigmd5?: string | undefined; + signature?: string | undefined; + type?: string | undefined; + version?: string | undefined; +}; +export type ModelsRepo = { + CreatedAt?: ModelsEdgeApiTime | undefined; + DeletedAt?: GormDeletedAt | undefined; + ID?: number | undefined; + RepoStatus?: string | undefined; + RepoURL?: string | undefined; + UpdatedAt?: ModelsEdgeApiTime | undefined; +}; +export type ModelsCommit = { + Account?: string | undefined; + Arch?: string | undefined; + BlueprintToml?: string | undefined; + BuildDate?: string | undefined; + BuildNumber?: number | undefined; + ChangesRefs?: boolean | undefined; + ComposeJobID?: string | undefined; + CreatedAt?: ModelsEdgeApiTime | undefined; + DeletedAt?: GormDeletedAt | undefined; + ID?: number | undefined; + ImageBuildHash?: string | undefined; + ImageBuildParentHash?: string | undefined; + ImageBuildTarURL?: string | undefined; + InstalledPackages?: ModelsInstalledPackage[] | undefined; + OSTreeCommit?: string | undefined; + OSTreeParentCommit?: string | undefined; + OSTreeParentRef?: string | undefined; + OSTreeRef?: string | undefined; + Repo?: ModelsRepo | undefined; + RepoID?: number | undefined; + Status?: string | undefined; + UpdatedAt?: ModelsEdgeApiTime | undefined; + external?: boolean | undefined; + name?: string | undefined; + org_id?: string | undefined; +}; +export type ModelsPackage = { + CreatedAt?: ModelsEdgeApiTime | undefined; + DeletedAt?: GormDeletedAt | undefined; + ID?: number | undefined; + Name?: string | undefined; + UpdatedAt?: ModelsEdgeApiTime | undefined; +}; +export type ModelsInstaller = { + Account?: string | undefined; + Checksum?: string | undefined; + ComposeJobID?: string | undefined; + CreatedAt?: ModelsEdgeApiTime | undefined; + DeletedAt?: GormDeletedAt | undefined; + ID?: number | undefined; + ImageBuildISOURL?: string | undefined; + SshKey?: string | undefined; + Status?: string | undefined; + UpdatedAt?: ModelsEdgeApiTime | undefined; + Username?: string | undefined; + org_id?: string | undefined; +}; +export type ModelsThirdPartyRepo = { + CreatedAt?: ModelsEdgeApiTime | undefined; + DeletedAt?: GormDeletedAt | undefined; + Description?: string | undefined; + ID?: number | undefined; + Images?: ModelsImage[] | undefined; + Name?: string | undefined; + URL?: string | undefined; + UpdatedAt?: ModelsEdgeApiTime | undefined; + account?: string | undefined; + distribution_arch?: string | undefined; + distribution_version?: string[] | undefined; + gpg_key?: string | undefined; + org_id?: string | undefined; + package_count?: number | undefined; + uuid?: string | undefined; +}; +export type ModelsImage = { + Account?: string | undefined; + Commit?: ModelsCommit | undefined; + CommitID?: number | undefined; + CreatedAt?: ModelsEdgeApiTime | undefined; + CustomPackages?: ModelsPackage[] | undefined; + DeletedAt?: GormDeletedAt | undefined; + Description?: string | undefined; + Distribution?: string | undefined; + ID?: number | undefined; + /** TODO: Wipe staging database and set to not nullable */ + ImageSetID?: number | undefined; + /** TODO: Remove as soon as the frontend stops using */ + ImageType?: string | undefined; + Installer?: ModelsInstaller | undefined; + InstallerID?: number | undefined; + Name?: string | undefined; + OutputTypes?: string[] | undefined; + Packages?: ModelsPackage[] | undefined; + Status?: string | undefined; + /** only for forms */ + SystemsRunning?: number | undefined; + ThirdPartyRepositories?: ModelsThirdPartyRepo[] | undefined; + /** only for forms */ + TotalPackages?: number | undefined; + UpdatedAt?: ModelsEdgeApiTime | undefined; + Version?: number | undefined; + org_id?: string | undefined; + /** storing for logging reference on resume */ + request_id?: string | undefined; +}; +export type ModelsImageSetApi = { + CreatedAt?: ModelsEdgeApiTime | undefined; + DeletedAt?: GormDeletedAt | undefined; + ID?: number | undefined; + /** images of image set */ + Images?: ModelsImage[] | undefined; + UpdatedAt?: ModelsEdgeApiTime | undefined; + /** the image set name */ + name?: string | undefined; + /** the image set version */ + version?: number | undefined; +}; +export type ModelsImageSetInstallerUrlapi = { + /** The image-set latest available image ISO */ + image_build_iso_url?: string | undefined; + /** image set data */ + image_set?: ModelsImageSetApi | undefined; +}; +export type ModelsImageSetsResponseApi = { + /** count of image-sets */ + Count?: number | undefined; + /** all data of image-sets */ + Data?: ModelsImageSetInstallerUrlapi[] | undefined; +}; +export type ErrorsBadRequest = { + Code?: string | undefined; + Status?: number | undefined; + Title?: string | undefined; +}; +export type ErrorsNotFound = { + Code?: string | undefined; + Status?: number | undefined; + Title?: string | undefined; +}; +export type ErrorsInternalServerError = { + Code?: string | undefined; + Status?: number | undefined; + Title?: string | undefined; +}; +export type ModelsImageSetView = { + Distribution?: string | undefined; + ID?: number | undefined; + ImageBuildIsoURL?: string | undefined; + ImageID?: number | undefined; + Name?: string | undefined; + OutputTypes?: string[] | undefined; + Status?: string | undefined; + UpdatedAt?: ModelsEdgeApiTime | undefined; + Version?: number | undefined; +}; +export type ModelsImageSetsViewResponseApi = { + /** count of image-sets */ + count?: number | undefined; + /** data of image set view */ + data?: ModelsImageSetView[] | undefined; +}; +export type ModelsImageDetailApi = { + /** Number of additional packages */ + additional_packages?: number | undefined; + image?: ModelsImage | undefined; + /** Number of packages */ + packages?: number | undefined; + /** Number of added update */ + update_added?: number | undefined; + /** Number of removed update */ + update_removed?: number | undefined; + /** Number of updated update */ + update_updated?: number | undefined; +}; +export type ModelsImageSetImageIdViewApi = { + /** The image-set latest available image ISO */ + ImageBuildIsoURL?: string | undefined; + /** the requested image details */ + ImageDetails?: ModelsImageDetailApi | undefined; + /** image set data */ + ImageSet?: ModelsImageSetApi | undefined; +}; +export type ModelsImageView = { + CommitCheckSum?: string | undefined; + CreatedAt?: ModelsEdgeApiTime | undefined; + ID?: number | undefined; + ImageBuildIsoURL?: string | undefined; + ImageType?: string | undefined; + Name?: string | undefined; + OutputTypes?: string[] | undefined; + Status?: string | undefined; + Version?: number | undefined; +}; +export type ModelsImagesViewDataApi = { + /** total number of image view data */ + count?: number | undefined; + data?: ModelsImageView[] | undefined; +}; +export type ModelsSuccessPlaceholderResponse = object; +export type ImageResponse = { + Account?: string | undefined; + Commit?: ModelsCommit | undefined; + CommitID?: number | undefined; + CreatedAt?: ModelsEdgeApiTime | undefined; + CustomPackages?: ModelsPackage[] | undefined; + DeletedAt?: GormDeletedAt | undefined; + Description?: string | undefined; + Distribution?: string | undefined; + ID?: number | undefined; + /** TODO: Wipe staging database and set to not nullable */ + ImageSetID?: number | undefined; + /** TODO: Remove as soon as the frontend stops using */ + ImageType?: string | undefined; + Installer?: ModelsInstaller | undefined; + InstallerID?: number | undefined; + Name?: string | undefined; + OutputTypes?: string[] | undefined; + Packages?: ModelsPackage[] | undefined; + Status?: string | undefined; + /** only for forms */ + SystemsRunning?: number | undefined; + ThirdPartyRepositories?: ModelsThirdPartyRepo[] | undefined; + /** only for forms */ + TotalPackages?: number | undefined; + UpdatedAt?: ModelsEdgeApiTime | undefined; + Version?: number | undefined; + org_id?: string | undefined; + /** storing for logging reference on resume */ + request_id?: string | undefined; +}; +export type CreateImage = object; +export const { + useListAllImageSetsQuery, + useGetImageSetsViewQuery, + useGetImageSetImageViewQuery, + useGetAllImageSetImagesViewQuery, + useDeleteImageSetMutation, + useGetAllImagesQuery, + useCreateImageMutation, + useCheckImageNameMutation, + useCreateInstallerForImageMutation, + useCreateKickStartForImageMutation, + useGetMetadataForImageQuery, + useGetRepoForImageQuery, + useRetryCreateImageMutation, + useCreateImageUpdateMutation, + useGetImageByOstreeQuery, +} = injectedRtkApi; diff --git a/src/store/emptyComplianceApi.ts b/src/store/service/emptyComplianceApi.ts similarity index 87% rename from src/store/emptyComplianceApi.ts rename to src/store/service/emptyComplianceApi.ts index 1fb49d99..0f8b012e 100644 --- a/src/store/emptyComplianceApi.ts +++ b/src/store/service/emptyComplianceApi.ts @@ -1,6 +1,6 @@ import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react'; -import { COMPLIANCE_API } from '../constants'; +import { COMPLIANCE_API } from '../../constants'; // initialize an empty api service that we'll inject endpoints into later as needed export const emptyComplianceApi = createApi({ diff --git a/src/store/emptyContentSourcesApi.ts b/src/store/service/emptyContentSourcesApi.ts similarity index 87% rename from src/store/emptyContentSourcesApi.ts rename to src/store/service/emptyContentSourcesApi.ts index 42bf4615..b27297ef 100644 --- a/src/store/emptyContentSourcesApi.ts +++ b/src/store/service/emptyContentSourcesApi.ts @@ -1,6 +1,6 @@ import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react'; -import { CONTENT_SOURCES_API } from '../constants'; +import { CONTENT_SOURCES_API } from '../../constants'; // initialize an empty api service that we'll inject endpoints into later as needed export const emptyContentSourcesApi = createApi({ diff --git a/src/store/emptyEdgeApi.ts b/src/store/service/emptyEdgeApi.ts similarity index 88% rename from src/store/emptyEdgeApi.ts rename to src/store/service/emptyEdgeApi.ts index 55b0fff1..786f8aa1 100644 --- a/src/store/emptyEdgeApi.ts +++ b/src/store/service/emptyEdgeApi.ts @@ -1,6 +1,6 @@ import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react'; -import { EDGE_API } from '../constants'; +import { EDGE_API } from '../../constants'; // initialize an empty api service that we'll inject endpoints into later as needed export const emptyEdgeApi = createApi({ diff --git a/src/store/emptyImageBuilderApi.ts b/src/store/service/emptyImageBuilderApi.ts similarity index 96% rename from src/store/emptyImageBuilderApi.ts rename to src/store/service/emptyImageBuilderApi.ts index c3ca3ce6..72645618 100644 --- a/src/store/emptyImageBuilderApi.ts +++ b/src/store/service/emptyImageBuilderApi.ts @@ -1,6 +1,6 @@ import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react'; -import { IMAGE_BUILDER_API } from '../constants'; +import { IMAGE_BUILDER_API } from '../../constants'; // initialize an empty api service that we'll inject endpoints into later as needed export const emptyImageBuilderApi = createApi({ diff --git a/src/store/emptyProvisioningApi.ts b/src/store/service/emptyProvisioningApi.ts similarity index 87% rename from src/store/emptyProvisioningApi.ts rename to src/store/service/emptyProvisioningApi.ts index 6d66f927..cc239afb 100644 --- a/src/store/emptyProvisioningApi.ts +++ b/src/store/service/emptyProvisioningApi.ts @@ -1,6 +1,6 @@ import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react'; -import { PROVISIONING_API } from '../constants'; +import { PROVISIONING_API } from '../../constants'; // initialize an empty api service that we'll inject endpoints into later as needed export const emptyProvisioningApi = createApi({ diff --git a/src/store/emptyRhsmApi.ts b/src/store/service/emptyRhsmApi.ts similarity index 88% rename from src/store/emptyRhsmApi.ts rename to src/store/service/emptyRhsmApi.ts index b55199e6..285f4564 100644 --- a/src/store/emptyRhsmApi.ts +++ b/src/store/service/emptyRhsmApi.ts @@ -1,6 +1,6 @@ import { createApi, fetchBaseQuery } from '@reduxjs/toolkit/query/react'; -import { RHSM_API } from '../constants'; +import { RHSM_API } from '../../constants'; // initialize an empty api service that we'll inject endpoints into later as needed export const emptyRhsmApi = createApi({ diff --git a/src/store/service/enhancedImageBuilderApi.ts b/src/store/service/enhancedImageBuilderApi.ts new file mode 100644 index 00000000..14efa0d6 --- /dev/null +++ b/src/store/service/enhancedImageBuilderApi.ts @@ -0,0 +1,228 @@ +import { addNotification } from '@redhat-cloud-services/frontend-components-notifications/redux'; + +import { imageBuilderApi } from '../imageBuilderApi'; + +/* eslint-disable @typescript-eslint/no-explicit-any */ +export const errorMessage = (err: any) => { + let msg = err.error.statusText; + if ( + err.error.data?.errors && + err.error.data?.errors.length > 0 && + err.error.data?.errors[0]?.detail + ) { + msg = err.error.data?.errors[0]?.detail; + } + return msg; +}; + +const enhancedApi = imageBuilderApi.enhanceEndpoints({ + addTagTypes: [ + 'Clone', + 'Compose', + 'Blueprints', + 'BlueprintComposes', + 'Blueprint', + ], + endpoints: { + getBlueprint: { + providesTags: () => { + return [{ type: 'Blueprint' }]; + }, + }, + getBlueprints: { + providesTags: () => { + return [{ type: 'Blueprints' }]; + }, + }, + getBlueprintComposes: { + providesTags: () => { + return [{ type: 'BlueprintComposes' }]; + }, + }, + getComposes: { + providesTags: () => { + return [{ type: 'Compose' }]; + }, + }, + getComposeClones: { + providesTags: (_request, _error, arg) => { + return [{ type: 'Clone', id: arg.composeId }]; + }, + }, + updateBlueprint: { + onQueryStarted: async (_, { dispatch, queryFulfilled }) => { + queryFulfilled + .then(() => { + dispatch( + // @ts-expect-error Typescript is unaware of tag types being defined concurrently in enhanceEndpoints() + imageBuilderApi.util.invalidateTags(['Blueprints', 'Blueprint']) + ); + dispatch( + addNotification({ + variant: 'success', + title: 'Changes saved to blueprint', + }) + ); + }) + .catch((err) => { + dispatch( + addNotification({ + variant: 'danger', + title: 'Blueprint could not be updated', + description: `Status code ${err.error.status}: ${errorMessage( + err + )}`, + }) + ); + }); + }, + }, + createBlueprint: { + onQueryStarted: async (_, { dispatch, queryFulfilled }) => { + queryFulfilled + .then(() => { + // @ts-expect-error Typescript is unaware of tag types being defined concurrently in enhanceEndpoints() + dispatch(imageBuilderApi.util.invalidateTags(['Blueprints'])); + dispatch( + addNotification({ + variant: 'success', + title: 'Blueprint is being created', + }) + ); + }) + .catch((err) => { + dispatch( + addNotification({ + variant: 'danger', + title: 'Blueprint could not be created', + description: `Status code ${err.error.status}: ${errorMessage( + err + )}`, + }) + ); + }); + }, + }, + cloneCompose: { + onQueryStarted: async ( + { composeId, cloneRequest }, + { dispatch, queryFulfilled } + ) => { + queryFulfilled + .then(() => { + dispatch( + imageBuilderApi.util.invalidateTags([ + // @ts-expect-error Typescript is unaware of tag types being defined concurrently in enhanceEndpoints() + { type: 'Clone', id: composeId }, + ]) + ); + + dispatch( + addNotification({ + variant: 'success', + title: + 'Your image is being shared to ' + + cloneRequest.region + + ' region', + }) + ); + }) + .catch((err) => { + dispatch( + addNotification({ + variant: 'danger', + title: 'Your image could not be shared', + description: `Status code ${err.error.status}: ${errorMessage( + err + )}`, + }) + ); + }); + }, + }, + composeBlueprint: { + invalidatesTags: [{ type: 'Compose' }, { type: 'BlueprintComposes' }], + onQueryStarted: async (_, { dispatch, queryFulfilled }) => { + queryFulfilled + .then(() => { + dispatch( + addNotification({ + variant: 'success', + title: 'Image is being built', + }) + ); + }) + .catch((err) => { + dispatch( + addNotification({ + variant: 'danger', + title: 'Image could not be built', + description: `Status code ${err.error.status}: ${errorMessage( + err + )}`, + }) + ); + }); + }, + }, + composeImage: { + onQueryStarted: async (_, { dispatch, queryFulfilled }) => { + queryFulfilled + .then(() => { + dispatch( + // @ts-expect-error Typescript is unaware of tag types being defined concurrently in enhanceEndpoints() + imageBuilderApi.util.invalidateTags(['Blueprints', 'Compose']) + ); + dispatch( + addNotification({ + variant: 'success', + title: 'Your image is being created', + }) + ); + }) + .catch((err) => { + dispatch( + addNotification({ + variant: 'danger', + title: 'Your image could not be created', + description: `Status code ${err.error.status}: ${errorMessage( + err + )}`, + }) + ); + }); + }, + }, + deleteBlueprint: { + invalidatesTags: [ + { type: 'Blueprints' }, + { type: 'BlueprintComposes' }, + { type: 'Compose' }, + ], + onQueryStarted: async (_, { dispatch, queryFulfilled }) => { + queryFulfilled + .then(() => { + dispatch( + addNotification({ + variant: 'success', + title: 'Blueprint was deleted', + }) + ); + }) + .catch((err) => { + dispatch( + addNotification({ + variant: 'danger', + title: 'Blueprint could not be deleted', + description: `Status code ${err.error.status}: ${errorMessage( + err + )}`, + }) + ); + }); + }, + }, + }, +}); + +export { enhancedApi as imageBuilderApi }; diff --git a/src/store/service/imageBuilderApi.ts b/src/store/service/imageBuilderApi.ts new file mode 100644 index 00000000..72987f21 --- /dev/null +++ b/src/store/service/imageBuilderApi.ts @@ -0,0 +1,958 @@ +import { emptyImageBuilderApi as api } from "./emptyImageBuilderApi"; +const injectedRtkApi = api.injectEndpoints({ + endpoints: (build) => ({ + getArchitectures: build.query< + GetArchitecturesApiResponse, + GetArchitecturesApiArg + >({ + query: (queryArg) => ({ url: `/architectures/${queryArg.distribution}` }), + }), + getBlueprints: build.query({ + query: (queryArg) => ({ + url: `/blueprints`, + params: { + name: queryArg.name, + search: queryArg.search, + limit: queryArg.limit, + offset: queryArg.offset, + }, + }), + }), + createBlueprint: build.mutation< + CreateBlueprintApiResponse, + CreateBlueprintApiArg + >({ + query: (queryArg) => ({ + url: `/blueprints`, + method: "POST", + body: queryArg.createBlueprintRequest, + }), + }), + updateBlueprint: build.mutation< + UpdateBlueprintApiResponse, + UpdateBlueprintApiArg + >({ + query: (queryArg) => ({ + url: `/blueprints/${queryArg.id}`, + method: "PUT", + body: queryArg.createBlueprintRequest, + }), + }), + getBlueprint: build.query({ + query: (queryArg) => ({ + url: `/blueprints/${queryArg.id}`, + params: { + version: queryArg.version, + }, + }), + }), + deleteBlueprint: build.mutation< + DeleteBlueprintApiResponse, + DeleteBlueprintApiArg + >({ + query: (queryArg) => ({ + url: `/blueprints/${queryArg.id}`, + method: "DELETE", + }), + }), + exportBlueprint: build.query< + ExportBlueprintApiResponse, + ExportBlueprintApiArg + >({ + query: (queryArg) => ({ url: `/blueprints/${queryArg.id}/export` }), + }), + composeBlueprint: build.mutation< + ComposeBlueprintApiResponse, + ComposeBlueprintApiArg + >({ + query: (queryArg) => ({ + url: `/blueprints/${queryArg.id}/compose`, + method: "POST", + body: queryArg.body, + }), + }), + getBlueprintComposes: build.query< + GetBlueprintComposesApiResponse, + GetBlueprintComposesApiArg + >({ + query: (queryArg) => ({ + url: `/blueprints/${queryArg.id}/composes`, + params: { + blueprint_version: queryArg.blueprintVersion, + limit: queryArg.limit, + offset: queryArg.offset, + ignoreImageTypes: queryArg.ignoreImageTypes, + }, + }), + }), + getComposes: build.query({ + query: (queryArg) => ({ + url: `/composes`, + params: { + limit: queryArg.limit, + offset: queryArg.offset, + ignoreImageTypes: queryArg.ignoreImageTypes, + }, + }), + }), + getComposeStatus: build.query< + GetComposeStatusApiResponse, + GetComposeStatusApiArg + >({ + query: (queryArg) => ({ url: `/composes/${queryArg.composeId}` }), + }), + cloneCompose: build.mutation({ + query: (queryArg) => ({ + url: `/composes/${queryArg.composeId}/clone`, + method: "POST", + body: queryArg.cloneRequest, + }), + }), + getComposeClones: build.query< + GetComposeClonesApiResponse, + GetComposeClonesApiArg + >({ + query: (queryArg) => ({ + url: `/composes/${queryArg.composeId}/clones`, + params: { + limit: queryArg.limit, + offset: queryArg.offset, + }, + }), + }), + getCloneStatus: build.query< + GetCloneStatusApiResponse, + GetCloneStatusApiArg + >({ + query: (queryArg) => ({ url: `/clones/${queryArg.id}` }), + }), + composeImage: build.mutation({ + query: (queryArg) => ({ + url: `/compose`, + method: "POST", + body: queryArg.composeRequest, + }), + }), + getPackages: build.query({ + query: (queryArg) => ({ + url: `/packages`, + params: { + distribution: queryArg.distribution, + architecture: queryArg.architecture, + search: queryArg.search, + limit: queryArg.limit, + offset: queryArg.offset, + }, + }), + }), + getOscapProfiles: build.query< + GetOscapProfilesApiResponse, + GetOscapProfilesApiArg + >({ + query: (queryArg) => ({ + url: `/oscap/${queryArg.distribution}/profiles`, + }), + }), + getOscapCustomizations: build.query< + GetOscapCustomizationsApiResponse, + GetOscapCustomizationsApiArg + >({ + query: (queryArg) => ({ + url: `/oscap/${queryArg.distribution}/${queryArg.profile}/customizations`, + }), + }), + recommendPackage: build.mutation< + RecommendPackageApiResponse, + RecommendPackageApiArg + >({ + query: (queryArg) => ({ + url: `/experimental/recommendations`, + method: "POST", + body: queryArg.recommendPackageRequest, + }), + }), + }), + overrideExisting: false, +}); +export { injectedRtkApi as imageBuilderApi }; +export type GetArchitecturesApiResponse = + /** status 200 a list of available architectures and their associated image types */ Architectures; +export type GetArchitecturesApiArg = { + /** distribution for which to look up available architectures */ + distribution: Distributions; +}; +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 */ + limit?: number; + /** blueprint page offset, default 0 */ + offset?: number; +}; +export type CreateBlueprintApiResponse = + /** status 201 blueprint was saved */ CreateBlueprintResponse; +export type CreateBlueprintApiArg = { + /** details of blueprint */ + createBlueprintRequest: CreateBlueprintRequest; +}; +export type UpdateBlueprintApiResponse = + /** status 200 blueprint was updated */ CreateBlueprintResponse; +export type UpdateBlueprintApiArg = { + /** UUID of a blueprint */ + id: string; + /** details of blueprint */ + createBlueprintRequest: CreateBlueprintRequest; +}; +export type GetBlueprintApiResponse = + /** status 200 detail of a blueprint */ BlueprintResponse; +export type GetBlueprintApiArg = { + /** UUID of a blueprint */ + id: string; + /** Filter by a specific version of the Blueprint we want to fetch. + Omit or pass -1 to fetch latest version. + */ + version?: number; +}; +export type DeleteBlueprintApiResponse = unknown; +export type DeleteBlueprintApiArg = { + /** UUID of a blueprint */ + id: string; +}; +export type ExportBlueprintApiResponse = + /** status 200 detail of a blueprint */ BlueprintExportResponse; +export type ExportBlueprintApiArg = { + /** UUID of a blueprint */ + id: string; +}; +export type ComposeBlueprintApiResponse = + /** status 201 compose was created */ ComposeResponse[]; +export type ComposeBlueprintApiArg = { + /** UUID of a blueprint */ + id: string; + /** list of target image types that the user wants to build for this compose */ + body: { + image_types?: ImageTypes[] | undefined; + }; +}; +export type GetBlueprintComposesApiResponse = + /** status 200 a list of composes */ ComposesResponse; +export type GetBlueprintComposesApiArg = { + /** UUID of a blueprint */ + id: string; + /** 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; + /** composes page offset, default 0 */ + offset?: number; + /** Filter the composes on image type. The filter is optional and can be specified multiple times. + */ + ignoreImageTypes?: ImageTypes[]; +}; +export type GetComposesApiResponse = + /** status 200 a list of composes */ ComposesResponse; +export type GetComposesApiArg = { + /** max amount of composes, default 100 */ + limit?: number; + /** composes page offset, default 0 */ + offset?: number; + /** Filter the composes on image type. The filter is optional and can be specified multiple times. + */ + ignoreImageTypes?: ImageTypes[]; +}; +export type GetComposeStatusApiResponse = + /** status 200 compose status */ ComposeStatus; +export type GetComposeStatusApiArg = { + /** Id of compose */ + composeId: string; +}; +export type CloneComposeApiResponse = + /** status 201 cloning has started */ CloneResponse; +export type CloneComposeApiArg = { + /** Id of compose to clone */ + composeId: string; + /** details of the new clone */ + cloneRequest: CloneRequest; +}; +export type GetComposeClonesApiResponse = + /** status 200 compose clones */ ClonesResponse; +export type GetComposeClonesApiArg = { + /** Id of compose to get the clones of */ + composeId: string; + /** max amount of clones, default 100 */ + limit?: number; + /** clones page offset, default 0 */ + offset?: number; +}; +export type GetCloneStatusApiResponse = + /** status 200 clone status */ CloneStatusResponse; +export type GetCloneStatusApiArg = { + /** Id of clone status to get */ + id: string; +}; +export type ComposeImageApiResponse = + /** status 201 compose has started */ ComposeResponse; +export type ComposeImageApiArg = { + /** details of image to be composed */ + composeRequest: ComposeRequest; +}; +export type GetPackagesApiResponse = + /** status 200 a list of packages */ PackagesResponse; +export type GetPackagesApiArg = { + /** distribution to look up packages for */ + distribution: Distributions; + /** architecture to look up packages for */ + architecture: "x86_64" | "aarch64"; + /** packages to look for */ + search: string; + /** max amount of packages, default 100 */ + limit?: number; + /** packages page offset, default 0 */ + offset?: number; +}; +export type GetOscapProfilesApiResponse = + /** status 200 A list of profiles configurable for this distribution. + */ DistributionProfileResponse; +export type GetOscapProfilesApiArg = { + distribution: Distributions; +}; +export type GetOscapCustomizationsApiResponse = + /** status 200 A customizations array updated with the needed elements. + */ Customizations; +export type GetOscapCustomizationsApiArg = { + distribution: Distributions; + /** Name of the profile to retrieve customizations from */ + profile: DistributionProfileItem; +}; +export type RecommendPackageApiResponse = + /** status 200 Return the recommended packages. */ RecommendationsResponse; +export type RecommendPackageApiArg = { + recommendPackageRequest: RecommendPackageRequest; +}; +export type Repository = { + /** An ID referring to a repository defined in content sources can be used instead of + 'baseurl', 'mirrorlist' or 'metalink'. + */ + id?: string | undefined; + rhsm: boolean; + baseurl?: string | undefined; + mirrorlist?: string | undefined; + metalink?: string | undefined; + gpgkey?: string | undefined; + check_gpg?: boolean | undefined; + /** Enables gpg verification of the repository metadata + */ + check_repo_gpg?: boolean | undefined; + ignore_ssl?: boolean | undefined; + module_hotfixes?: boolean | undefined; +}; +export type ArchitectureItem = { + arch: string; + image_types: string[]; + /** Base repositories for the given distribution and architecture. */ + repositories: Repository[]; +}; +export type Architectures = ArchitectureItem[]; +export type HttpError = { + title: string; + detail: string; +}; +export type HttpErrorList = { + errors: HttpError[]; +}; +export type Distributions = + | "rhel-8" + | "rhel-8-nightly" + | "rhel-84" + | "rhel-85" + | "rhel-86" + | "rhel-87" + | "rhel-88" + | "rhel-89" + | "rhel-8.10" + | "rhel-9" + | "rhel-9-nightly" + | "rhel-9-beta" + | "rhel-90" + | "rhel-91" + | "rhel-92" + | "rhel-93" + | "rhel-94" + | "rhel-95" + | "rhel-10-nightly" + | "rhel-10-beta" + | "centos-9" + | "centos-10" + | "fedora-37" + | "fedora-38" + | "fedora-39" + | "fedora-40" + | "fedora-41"; +export type ListResponseMeta = { + count: number; +}; +export type ListResponseLinks = { + first: string; + last: string; +}; +export type BlueprintItem = { + id: string; + version: number; + name: string; + description: string; + last_modified_at: string; +}; +export type BlueprintsResponse = { + meta: ListResponseMeta; + links: ListResponseLinks; + data: BlueprintItem[]; +}; +export type CreateBlueprintResponse = { + id: string; +}; +export type ImageTypes = + | "aws" + | "azure" + | "edge-commit" + | "edge-installer" + | "gcp" + | "guest-image" + | "image-installer" + | "oci" + | "vsphere" + | "vsphere-ova" + | "wsl" + | "ami" + | "rhel-edge-commit" + | "rhel-edge-installer" + | "vhd"; +export type UploadTypes = + | "aws" + | "gcp" + | "azure" + | "aws.s3" + | "oci.objectstorage"; +export type AwsUploadRequestOptions = { + share_with_accounts?: string[] | undefined; + share_with_sources?: string[] | undefined; +}; +export type Awss3UploadRequestOptions = object; +export type GcpUploadRequestOptions = { + /** List of valid Google accounts to share the imported Compute Node image with. + Each string must contain a specifier of the account type. Valid formats are: + - 'user:{emailid}': An email address that represents a specific + Google account. For example, 'alice@example.com'. + - 'serviceAccount:{emailid}': An email address that represents a + service account. For example, 'my-other-app@appspot.gserviceaccount.com'. + - 'group:{emailid}': An email address that represents a Google group. + For example, 'admins@example.com'. + - 'domain:{domain}': The G Suite domain (primary) that represents all + the users of that domain. For example, 'google.com' or 'example.com'. + If not specified, the imported Compute Node image is not shared with any + account. + */ + share_with_accounts?: string[] | undefined; +}; +export type AzureUploadRequestOptions = { + /** ID of the source that will be used to resolve the tenant and subscription IDs. + Do not provide a tenant_id or subscription_id when providing a source_id. + */ + source_id?: string | undefined; + /** ID of the tenant where the image should be uploaded. This link explains how + to find it in the Azure Portal: + https://docs.microsoft.com/en-us/azure/active-directory/fundamentals/active-directory-how-to-find-tenant + When providing a tenant_id, also be sure to provide a subscription_id and do not include a source_id. + */ + tenant_id?: string | undefined; + /** ID of subscription where the image should be uploaded. + When providing a subscription_id, also be sure to provide a tenant_id and do not include a source_id. + */ + subscription_id?: string | undefined; + /** Name of the resource group where the image should be uploaded. + */ + resource_group: string; + /** Name of the created image. + Must begin with a letter or number, end with a letter, number or underscore, and may contain only letters, numbers, underscores, periods, or hyphens. + The total length is limited to 60 characters. + */ + image_name?: string | undefined; + /** Choose the VM Image HyperV generation, different features on Azure are available + depending on the HyperV generation. + */ + hyper_v_generation?: ("V1" | "V2") | undefined; +}; +export type OciUploadRequestOptions = object; +export type UploadRequest = { + type: UploadTypes; + options: + | AwsUploadRequestOptions + | Awss3UploadRequestOptions + | GcpUploadRequestOptions + | AzureUploadRequestOptions + | OciUploadRequestOptions; +}; +export type OsTree = { + url?: string | undefined; + /** A URL which, if set, is used for fetching content. Implies that `url` is set as well, + which will be used for metadata only. + */ + contenturl?: string | undefined; + ref?: string | undefined; + /** Can be either a commit (example: 02604b2da6e954bd34b8b82a835e5a77d2b60ffa), or a branch-like reference (example: rhel/8/x86_64/edge) + */ + parent?: string | undefined; + /** Determines whether a valid subscription manager (candlepin) identity is required to + access this repository. Consumer certificates will be used as client certificates when + fetching metadata and content. + */ + rhsm?: boolean | undefined; +}; +export type ImageRequest = { + /** CPU architecture of the image, x86_64 and aarch64 are currently supported. + */ + architecture: "x86_64" | "aarch64"; + image_type: ImageTypes; + upload_request: UploadRequest; + ostree?: OsTree | undefined; + /** Size of image, in bytes. When set to 0 the image size is a minimum + defined by the image type. + */ + size?: any | undefined; + /** 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. The format must be YYYY-MM-DD (ISO 8601 extended). + */ + snapshot_date?: string | undefined; +}; +export type Container = { + /** Reference to the container to embed */ + source: string; + /** Name to use for the container from the image */ + name?: string | undefined; + /** Control TLS verifification */ + tls_verify?: boolean | undefined; +}; +export type Directory = { + /** Path to the directory */ + path: string; + /** Permissions string for the directory in octal format */ + mode?: string | undefined; + /** Owner of the directory as a user name or a uid */ + user?: (string | number) | undefined; + /** Group of the directory as a group name or a gid */ + group?: (string | number) | undefined; + /** Ensure that the parent directories exist */ + ensure_parents?: boolean | undefined; +}; +export type File = { + /** Path to the file */ + path: string; + /** Permissions string for the file in octal format */ + mode?: string | undefined; + /** Owner of the file as a uid or a user name */ + user?: (string | number) | undefined; + /** Group of the file as a gid or a group name */ + group?: (string | number) | undefined; + /** Contents of the file as plain text */ + data?: string | undefined; + /** When data is base64-encoded to prevent Akamai content filter false positives */ + data_encoding?: ("plain" | "base64") | undefined; + /** Ensure that the parent directories exist */ + ensure_parents?: boolean | undefined; +}; +export type Subscription = { + organization: number; + "activation-key": string; + "server-url": string; + "base-url": string; + insights: boolean; + /** Optional flag to use rhc to register the system, which also always enables Insights. + */ + rhc?: boolean | undefined; +}; +export type CustomRepository = { + id: string; + name?: string | undefined; + filename?: string | undefined; + baseurl?: string[] | undefined; + mirrorlist?: string | undefined; + metalink?: string | undefined; + /** GPG key used to sign packages in this repository. Can be a gpg key or a URL */ + gpgkey?: string[] | undefined; + check_gpg?: boolean | undefined; + check_repo_gpg?: boolean | undefined; + enabled?: boolean | undefined; + priority?: number | undefined; + ssl_verify?: boolean | undefined; + module_hotfixes?: boolean | undefined; +}; +export type OpenScapProfile = { + /** Uses the OpenSCAP tooling directly to apply a pre-defined profile without tailorings. + */ + profile_id: string; + /** The profile type */ + profile_name?: string | undefined; + /** The longform profile description */ + profile_description?: string | undefined; +}; +export type OpenScapCompliance = { + /** Apply a compliance policy which is defined in the Red Hat Insights Compliance + service. This policy can include tailorings. This only works for RHEL images, and the + policy needs to be available for the specific RHEL version. + */ + policy_id: string; +}; +export type OpenScap = OpenScapProfile | OpenScapCompliance; +export type Filesystem = { + mountpoint: string; + /** size of the filesystem in bytes */ + min_size: any; +}; +export type User = { + name: string; + /** List of groups to add the user to. The 'wheel' group should be added explicitly, as the + default value is empty. + */ + groups?: string[] | undefined; + ssh_key?: string | undefined; + /** Plaintext passwords are also supported, they will be hashed and stored using the SHA-512 algorithm. + The password is never returned in the response. + Empty string can be used to remove the password during update but only with ssh_key set. + */ + password?: string | undefined; +}; +export type Services = { + /** List of services to enable by default */ + enabled?: string[] | undefined; + /** List of services to disable by default */ + disabled?: string[] | undefined; + /** List of services to mask by default */ + masked?: string[] | undefined; +}; +export type Kernel = { + /** Name of the kernel to use */ + name?: string | undefined; + /** Appends arguments to the bootloader kernel command line */ + append?: string | undefined; +}; +export type Group = { + /** Name of the group to create */ + name: string; + /** Group id of the group to create (optional) */ + gid?: number | undefined; +}; +export type Timezone = { + /** Name of the timezone, defaults to UTC */ + timezone?: string | undefined; + /** List of ntp servers */ + ntpservers?: string[] | undefined; +}; +export type Locale = { + /** List of locales to be installed, the first one becomes primary, subsequent ones are secondary + */ + languages?: string[] | undefined; + /** Sets the keyboard layout */ + keyboard?: string | undefined; +}; +export type FirewallCustomization = { + /** List of ports (or port ranges) and protocols to open */ + ports?: string[] | undefined; + /** Firewalld services to enable or disable */ + services?: + | { + /** List of services to enable */ + enabled?: string[] | undefined; + /** List of services to disable */ + disabled?: string[] | undefined; + } + | undefined; +}; +export type Fdo = { + manufacturing_server_url?: string | undefined; + diun_pub_key_insecure?: string | undefined; + diun_pub_key_hash?: string | undefined; + diun_pub_key_root_certs?: string | undefined; +}; +export type IgnitionEmbedded = { + config: string; +}; +export type IgnitionFirstboot = { + /** Provisioning URL */ + url: string; +}; +export type Ignition = { + embedded?: IgnitionEmbedded | undefined; + firstboot?: IgnitionFirstboot | undefined; +}; +export type Fips = { + /** Enables the system FIPS mode */ + enabled?: boolean | undefined; +}; +export type Installer = { + /** Create a kickstart file for a fully automated installation + */ + unattended?: boolean | undefined; + "sudo-nopasswd"?: string[] | undefined; +}; +export type Customizations = { + containers?: Container[] | undefined; + directories?: Directory[] | undefined; + files?: File[] | undefined; + subscription?: Subscription | undefined; + packages?: string[] | undefined; + payload_repositories?: Repository[] | undefined; + /** List of custom repositories. */ + custom_repositories?: CustomRepository[] | undefined; + openscap?: OpenScap | undefined; + filesystem?: Filesystem[] | undefined; + /** List of users that a customer can add, + also specifying their respective groups and SSH keys and/or password + */ + users?: User[] | undefined; + services?: Services | undefined; + /** Configures the hostname */ + hostname?: string | undefined; + kernel?: Kernel | undefined; + /** List of groups to create */ + groups?: Group[] | undefined; + timezone?: Timezone | undefined; + locale?: Locale | undefined; + firewall?: FirewallCustomization | undefined; + /** Name of the installation device, currently only useful for the edge-simplified-installer type + */ + installation_device?: string | undefined; + fdo?: Fdo | undefined; + ignition?: Ignition | undefined; + /** Select how the disk image will be partitioned. 'auto-lvm' will use raw unless + there are one or more mountpoints in which case it will use LVM. 'lvm' always + uses LVM, even when there are no extra mountpoints. 'raw' uses raw partitions + even when there are one or more mountpoints. + */ + partitioning_mode?: ("raw" | "lvm" | "auto-lvm") | undefined; + fips?: Fips | undefined; + installer?: Installer | undefined; +}; +export type BlueprintMetadata = { + parent_id: string | null; + exported_at: string; + is_on_prem: boolean; +}; +export type CreateBlueprintRequest = { + name: string; + description?: string | undefined; + distribution: Distributions; + /** Array of image requests. Having more image requests in a single blueprint is currently not supported. + */ + image_requests: ImageRequest[]; + customizations: Customizations; + metadata?: BlueprintMetadata | undefined; +}; +export type BlueprintResponse = { + id: string; + name: string; + description: string; + distribution: Distributions; + /** Array of image requests. Having more image requests in a single blueprint is currently not supported. + */ + image_requests: ImageRequest[]; + customizations: Customizations; +}; +export type BlueprintExportResponse = { + name: string; + description: string; + distribution: Distributions; + customizations: Customizations; + metadata: BlueprintMetadata; + /** List of custom repositories including all the repository details needed in order + to recreate the repositories. + */ + content_sources?: object[] | undefined; + /** Importing the snapshot date will not yet be supported. It is exported for informative reasons. + The format is YYYY-MM-DD. + */ + snapshot_date?: string | undefined; +}; +export type ComposeResponse = { + id: string; +}; +export type ClientId = "api" | "ui"; +export type ComposeRequest = { + distribution: Distributions; + image_name?: string | undefined; + image_description?: string | undefined; + client_id?: ClientId | undefined; + /** Array of exactly one image request. Having more image requests in one compose is currently not supported. + */ + image_requests: ImageRequest[]; + customizations?: Customizations | undefined; +}; +export type ComposesResponseItem = { + id: string; + request: ComposeRequest; + created_at: string; + image_name?: string | undefined; + client_id?: ClientId | undefined; + blueprint_id?: (string | null) | undefined; + blueprint_version?: (number | null) | undefined; +}; +export type ComposesResponse = { + meta: ListResponseMeta; + links: ListResponseLinks; + data: ComposesResponseItem[]; +}; +export type AwsUploadStatus = { + ami: string; + region: string; +}; +export type Awss3UploadStatus = { + url: string; +}; +export type GcpUploadStatus = { + project_id: string; + image_name: string; +}; +export type AzureUploadStatus = { + image_name: string; +}; +export type OciUploadStatus = { + url: string; +}; +export type UploadStatus = { + status: "success" | "failure" | "pending" | "running"; + type: UploadTypes; + options: + | AwsUploadStatus + | Awss3UploadStatus + | GcpUploadStatus + | AzureUploadStatus + | OciUploadStatus; +}; +export type ComposeStatusError = { + id: number; + reason: string; + details?: any | undefined; +}; +export type ImageStatus = { + status: + | "success" + | "failure" + | "pending" + | "building" + | "uploading" + | "registering"; + upload_status?: UploadStatus | undefined; + error?: ComposeStatusError | undefined; +}; +export type ComposeStatus = { + image_status: ImageStatus; + request: ComposeRequest; +}; +export type CloneResponse = { + id: string; +}; +export type Awsec2Clone = { + /** A region as described in + https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html#concepts-regions + */ + region: string; + /** An array of AWS account IDs as described in + https://docs.aws.amazon.com/IAM/latest/UserGuide/console_account-alias.html + */ + share_with_accounts?: string[] | undefined; + share_with_sources?: string[] | undefined; +}; +export type CloneRequest = Awsec2Clone; +export type ClonesResponseItem = { + id: string; + /** UUID of the parent compose of the clone */ + compose_id: string; + request: CloneRequest; + created_at: string; +}; +export type ClonesResponse = { + meta: ListResponseMeta; + links: ListResponseLinks; + data: ClonesResponseItem[]; +}; +export type CloneStatusResponse = { + compose_id?: string | undefined; +} & UploadStatus; +export type Package = { + name: string; + summary: string; +}; +export type PackagesResponse = { + meta: ListResponseMeta; + links: ListResponseLinks; + data: Package[]; +}; +export type DistributionProfileItem = + | "xccdf_org.ssgproject.content_profile_anssi_bp28_enhanced" + | "xccdf_org.ssgproject.content_profile_anssi_bp28_high" + | "xccdf_org.ssgproject.content_profile_anssi_bp28_intermediary" + | "xccdf_org.ssgproject.content_profile_anssi_bp28_minimal" + | "xccdf_org.ssgproject.content_profile_ccn_advanced" + | "xccdf_org.ssgproject.content_profile_ccn_basic" + | "xccdf_org.ssgproject.content_profile_ccn_intermediate" + | "xccdf_org.ssgproject.content_profile_cis" + | "xccdf_org.ssgproject.content_profile_cis_server_l1" + | "xccdf_org.ssgproject.content_profile_cis_workstation_l1" + | "xccdf_org.ssgproject.content_profile_cis_workstation_l2" + | "xccdf_org.ssgproject.content_profile_cui" + | "xccdf_org.ssgproject.content_profile_e8" + | "xccdf_org.ssgproject.content_profile_hipaa" + | "xccdf_org.ssgproject.content_profile_ism_o" + | "xccdf_org.ssgproject.content_profile_ospp" + | "xccdf_org.ssgproject.content_profile_pci-dss" + | "xccdf_org.ssgproject.content_profile_standard" + | "xccdf_org.ssgproject.content_profile_stig" + | "xccdf_org.ssgproject.content_profile_stig_gui"; +export type DistributionProfileResponse = DistributionProfileItem[]; +export type RecommendationsResponse = { + packages: string[]; +}; +export type RecommendPackageRequest = { + packages: string[]; + recommendedPackages: number; +}; +export const { + useGetArchitecturesQuery, + useLazyGetArchitecturesQuery, + useGetBlueprintsQuery, + useLazyGetBlueprintsQuery, + useCreateBlueprintMutation, + useUpdateBlueprintMutation, + useGetBlueprintQuery, + useLazyGetBlueprintQuery, + useDeleteBlueprintMutation, + useExportBlueprintQuery, + useLazyExportBlueprintQuery, + useComposeBlueprintMutation, + useGetBlueprintComposesQuery, + useLazyGetBlueprintComposesQuery, + useGetComposesQuery, + useLazyGetComposesQuery, + useGetComposeStatusQuery, + useLazyGetComposeStatusQuery, + useCloneComposeMutation, + useGetComposeClonesQuery, + useLazyGetComposeClonesQuery, + useGetCloneStatusQuery, + useLazyGetCloneStatusQuery, + useComposeImageMutation, + useGetPackagesQuery, + useLazyGetPackagesQuery, + useGetOscapProfilesQuery, + useLazyGetOscapProfilesQuery, + useGetOscapCustomizationsQuery, + useLazyGetOscapCustomizationsQuery, + useRecommendPackageMutation, +} = injectedRtkApi; diff --git a/src/store/service/provisioningApi.ts b/src/store/service/provisioningApi.ts new file mode 100644 index 00000000..b1f6ae82 --- /dev/null +++ b/src/store/service/provisioningApi.ts @@ -0,0 +1,69 @@ +import { emptyProvisioningApi as api } from "./emptyProvisioningApi"; +const injectedRtkApi = api.injectEndpoints({ + endpoints: (build) => ({ + getSourceList: build.query({ + query: (queryArg) => ({ + url: `/sources`, + params: { + provider: queryArg.provider, + }, + }), + }), + getSourceUploadInfo: build.query< + GetSourceUploadInfoApiResponse, + GetSourceUploadInfoApiArg + >({ + query: (queryArg) => ({ url: `/sources/${queryArg.id}/upload_info` }), + }), + }), + overrideExisting: false, +}); +export { injectedRtkApi as provisioningApi }; +export type GetSourceListApiResponse = + /** status 200 Returned on success. */ V1ListSourceResponse; +export type GetSourceListApiArg = { + provider?: "aws" | "azure" | "gcp"; +}; +export type GetSourceUploadInfoApiResponse = + /** status 200 Return on success. */ V1SourceUploadInfoResponse; +export type GetSourceUploadInfoApiArg = { + /** Source ID from Sources Database */ + id: number; +}; +export type V1ListSourceResponse = { + data?: + | { + id?: string | undefined; + name?: string | undefined; + source_type_id?: string | undefined; + uid?: string | undefined; + }[] + | undefined; +}; +export type V1ResponseError = { + build_time?: string | undefined; + edge_id?: string | undefined; + environment?: string | undefined; + error?: string | undefined; + msg?: string | undefined; + trace_id?: string | undefined; + version?: string | undefined; +}; +export type V1SourceUploadInfoResponse = { + aws?: + | ({ + account_id?: string | undefined; + } | null) + | undefined; + azure?: + | ({ + resource_groups?: string[] | undefined; + subscription_id?: string | undefined; + tenant_id?: string | undefined; + } | null) + | undefined; + gcp?: (any | null) | undefined; + provider?: string | undefined; +}; +export const { useGetSourceListQuery, useGetSourceUploadInfoQuery } = + injectedRtkApi; diff --git a/src/store/service/rhsmApi.ts b/src/store/service/rhsmApi.ts new file mode 100644 index 00000000..c37d922e --- /dev/null +++ b/src/store/service/rhsmApi.ts @@ -0,0 +1,81 @@ +import { emptyRhsmApi as api } from "./emptyRhsmApi"; +const injectedRtkApi = api.injectEndpoints({ + endpoints: (build) => ({ + listActivationKeys: build.query< + ListActivationKeysApiResponse, + ListActivationKeysApiArg + >({ + query: () => ({ url: `/activation_keys` }), + }), + createActivationKeys: build.mutation< + CreateActivationKeysApiResponse, + CreateActivationKeysApiArg + >({ + query: (queryArg) => ({ + url: `/activation_keys`, + method: "POST", + body: queryArg.body, + }), + }), + showActivationKey: build.query< + ShowActivationKeyApiResponse, + ShowActivationKeyApiArg + >({ + query: (queryArg) => ({ url: `/activation_keys/${queryArg.name}` }), + }), + }), + overrideExisting: false, +}); +export { injectedRtkApi as rhsmApi }; +export type ListActivationKeysApiResponse = + /** status 200 Array of activation keys */ { + body?: ActivationKeys[] | undefined; + }; +export type ListActivationKeysApiArg = void; +export type CreateActivationKeysApiResponse = /** status 200 Activation key */ { + body?: ActivationKeys | undefined; +}; +export type CreateActivationKeysApiArg = { + /** Create an activation key */ + body: { + additionalRepositories?: + | { + repositoryLabel?: string | undefined; + }[] + | undefined; + /** Name should be present, unique and can only contain letters, numbers, underscores, or hyphens */ + name: string; + releaseVersion?: string | undefined; + role?: string | undefined; + serviceLevel?: string | undefined; + usage?: string | undefined; + }; +}; +export type ShowActivationKeyApiResponse = /** status 200 Activation key */ { + body?: ActivationKeys | undefined; +}; +export type ShowActivationKeyApiArg = { + name: string; +}; +export type AdditionalRepositories = { + repositoryLabel?: string | undefined; + repositoryName?: string | undefined; +}; +export type ActivationKeys = { + additionalRepositories?: AdditionalRepositories[] | undefined; + id?: string | undefined; + name?: string | undefined; + releaseVersion?: string | undefined; + role?: string | undefined; + serviceLevel?: string | undefined; + usage?: string | undefined; +}; +export type ErrorDetails = { + code?: number | undefined; + message?: string | undefined; +}; +export const { + useListActivationKeysQuery, + useCreateActivationKeysMutation, + useShowActivationKeyQuery, +} = injectedRtkApi;