import * as API from "@distilled.cloud/core/api"; import * as C from "@distilled.cloud/core/category"; // AUTO-GENERATED by scripts/generate.ts from .generated-specs (specs/spec-mirror-stackit). Do not edit. import * as S from "@distilled.cloud/core/schema-lite"; import * as __L from "@distilled.cloud/core/schema-lite"; import { StackitServiceErrors } from "../errors.ts"; import { StackitProtocol, type StackitOpError, type StackitOpContext } from "../protocol.ts"; import * as Retry from "../retry.ts"; import * as T from "../traits.ts"; // Schema table, filled on first reach (see __S at the end). const __s: any[] = []; export type { StackitOpError, StackitOpContext }; /** Span facts shared by every operation (com.distilled.telemetry#service). */ const TELEMETRY = { system: "stackit-api", responseHeaders: [ { header: "x-request-id", name: "http.response.header.x-request-id", transform: "list" }, { header: "request-id", name: "http.response.header.request-id", transform: "list" }, ], prefix: "STACKIT", service: "ServiceEnablement", labels: "stackit", propagate: "w3c", } as const; export class BadRequest extends /*@__PURE__*/ T.applyErrorMatchers( /*@__PURE__*/ S.TaggedError()("BadRequest", { code: S.Number, message: S.String, body: /*@__PURE__*/ S.optional(S.Unknown), headers: /*@__PURE__*/ S.optional(/*@__PURE__*/ S.Record(S.String, S.String)), }).pipe(C.withBadRequestError), [{ status: 400 }], ) {} export class Forbidden extends /*@__PURE__*/ T.applyErrorMatchers( /*@__PURE__*/ S.TaggedError()("Forbidden", { code: S.Number, message: S.String, body: /*@__PURE__*/ S.optional( /*@__PURE__*/ S.Union([/*@__PURE__*/ S.suspend(() => __S(0, __c0, 0)), S.String]), ), headers: /*@__PURE__*/ S.optional(/*@__PURE__*/ S.Record(S.String, S.String)), }).pipe(C.withAuthError), [{ status: 403 }], ) { declare readonly body?: ErrorResponse | string; } export class NotFound extends /*@__PURE__*/ T.applyErrorMatchers( /*@__PURE__*/ S.TaggedError()("NotFound", { code: S.Number, message: S.String, body: /*@__PURE__*/ S.optional(S.Unknown), headers: /*@__PURE__*/ S.optional(/*@__PURE__*/ S.Record(S.String, S.String)), }).pipe(C.withBadRequestError), [{ status: 404 }], ) {} export interface DisableServiceRegionalRequest { projectId: string; region: string; serviceId: string; } export interface DisableServiceRegionalResponse {} export interface EnableServiceRegionalRequest { projectId: string; region: string; serviceId: string; } export interface EnableServiceRegionalResponse {} export interface GetServiceStatusRegionalRequest { projectId: string; region: string; serviceId: string; } /** a list of service IDs which this service depend on. If the service is enabled, those service are enabled as well automatically. */ export type DependenciesHardList = Array; /** a list of service IDs which this service depend on. When they are disabled a notification is sent. */ export type DependenciesSoftList = Array; export interface Dependencies { /** a list of service IDs which this service depend on. If the service is enabled, those service are enabled as well automatically. */ hard?: DependenciesHardList | undefined; /** a list of service IDs which this service depend on. When they are disabled a notification is sent. */ soft?: DependenciesSoftList | undefined; } export type ServiceStatusEnablement = "REQUEST" | "AUTO"; /** the last action which was triggered on this service */ export type ActionErrorAction = "DISABLE" | "ENABLE"; /** the last error for this service. */ export interface ActionError { /** the last action which was triggered on this service */ action?: ActionErrorAction | undefined; /** the error code if provided by the service */ code?: string | undefined; /** the error reason provided by the service */ reason?: string | undefined; } export type ServiceStatusLabelsMap = { [key: string]: string | undefined }; export type ServiceStatusLifecycle = "FLEX" | "PROJECT"; export type ParametersGeneralProjectScope = "SCHWARZ" | "PUBLIC"; export interface ParametersGeneral { organizationId?: string | undefined; projectName?: string | undefined; projectScope?: ParametersGeneralProjectScope | undefined; } /** service parameters */ export interface Parameters { general?: ParametersGeneral | undefined; [key: string]: unknown; } export type ServiceStatusScope = "PRIVATE" | "PUBLIC"; /** the state of a service within a project */ export type ServiceStatusState = "ENABLED" | "ENABLING" | "DISABLED" | "DISABLING"; export interface ServiceStatus { dependencies?: Dependencies | undefined; enablement?: ServiceStatusEnablement | undefined; error?: ActionError | undefined; labels?: ServiceStatusLabelsMap | undefined; lifecycle?: ServiceStatusLifecycle | undefined; parameters?: Parameters | undefined; scope?: ServiceStatusScope | undefined; serviceId?: string | undefined; /** the state of a service within a project */ state?: ServiceStatusState | undefined; } export interface ListServiceStatusRegionalRequest { projectId: string; region: string; cursor?: string | undefined; } export type ListServiceStatusRegionalResponseItemsList = Array; export interface ListServiceStatusRegionalResponse { items?: ListServiceStatusRegionalResponseItemsList | undefined; nextCursor?: string | undefined; } export interface ErrorResponse { error?: string | undefined; message?: string | undefined; path?: string | undefined; status?: number | undefined; timestamp?: string | undefined; } export type DisableServiceRegionalError = BadRequest | Forbidden | NotFound | StackitOpError; /** disables the service in a project. */ export const disableServiceRegional: API.OperationMethod< DisableServiceRegionalRequest, DisableServiceRegionalResponse, DisableServiceRegionalError, StackitOpContext > = /*@__PURE__*/ API.make(() => ({ input: __S(8, __c1, 0) as any as S.Schema, output: __S(16, __c2, 0) as any as S.Schema, errors: [BadRequest, Forbidden, NotFound], serviceErrors: StackitServiceErrors, protocol: StackitProtocol, retry: Retry.Retry, telemetry: TELEMETRY, span: "DisableServiceRegional", })); export type EnableServiceRegionalError = BadRequest | Forbidden | NotFound | StackitOpError; /** enables the service in a project. */ export const enableServiceRegional: API.OperationMethod< EnableServiceRegionalRequest, EnableServiceRegionalResponse, EnableServiceRegionalError, StackitOpContext > = /*@__PURE__*/ API.make(() => ({ input: __S(24, __c3, 0) as any as S.Schema, output: __S(16, __c2, 0) as any as S.Schema, errors: [BadRequest, Forbidden, NotFound], serviceErrors: StackitServiceErrors, protocol: StackitProtocol, retry: Retry.Retry, telemetry: TELEMETRY, span: "EnableServiceRegional", })); export type GetServiceStatusRegionalError = BadRequest | Forbidden | NotFound | StackitOpError; /** returns the current status of a service in a project. */ export const getServiceStatusRegional: API.OperationMethod< GetServiceStatusRegionalRequest, ServiceStatus, GetServiceStatusRegionalError, StackitOpContext > = /*@__PURE__*/ API.make(() => ({ input: __S(32, __c4, 0) as any as S.Schema, output: __S(46, __c5, 6) as any as S.Schema, errors: [BadRequest, Forbidden, NotFound], serviceErrors: StackitServiceErrors, protocol: StackitProtocol, retry: Retry.Retry, telemetry: TELEMETRY, span: "GetServiceStatusRegional", })); export type ListServiceStatusRegionalError = BadRequest | Forbidden | StackitOpError; /** returns a list of all available services for a project. */ export const listServiceStatusRegional: API.OperationMethod< ListServiceStatusRegionalRequest, ListServiceStatusRegionalResponse, ListServiceStatusRegionalError, StackitOpContext > = /*@__PURE__*/ API.make(() => ({ input: __S(48, __c6, 0) as any as S.Schema, output: __S(50, __c6, 2) as any as S.Schema, errors: [BadRequest, Forbidden], serviceErrors: StackitServiceErrors, protocol: StackitProtocol, retry: Retry.Retry, telemetry: TELEMETRY, span: "ListServiceStatusRegional", })); // Schema builders: each runs one schema initializer, on that schema's first use. function __c0(j: number): any { switch (j) { case 0: return S.suspend(() => S.Struct({ error: S.optional(S.String), message: S.optional(S.String), path: S.optional(S.String), status: S.optional(S.Number), timestamp: S.optional(S.String), }), ).annotate({ identifier: "ErrorResponse" }); } } function __c1(j: number): any { switch (j) { case 0: return S.suspend(() => S.Struct({ projectId: S.String.pipe(T.Label()), region: S.String.pipe(T.Label()), serviceId: S.String.pipe(T.Label()), }).pipe( T.Http({ method: "DELETE", uri: "/v2/projects/{projectId}/regions/{region}/services/{serviceId}", code: 200, baseUrl: "https://service-enablement.api.stackit.cloud", }), ), ).annotate({ identifier: "DisableServiceRegionalRequest" }); } } function __c2(j: number): any { switch (j) { case 0: return S.suspend(() => S.Struct({})).annotate({ identifier: "DisableServiceRegionalResponse", }); } } function __c3(j: number): any { switch (j) { case 0: return S.suspend(() => S.Struct({ projectId: S.String.pipe(T.Label()), region: S.String.pipe(T.Label()), serviceId: S.String.pipe(T.Label()), }).pipe( T.Http({ method: "POST", uri: "/v2/projects/{projectId}/regions/{region}/services/{serviceId}", code: 200, baseUrl: "https://service-enablement.api.stackit.cloud", }), ), ).annotate({ identifier: "EnableServiceRegionalRequest" }); } } function __c4(j: number): any { switch (j) { case 0: return S.suspend(() => S.Struct({ projectId: S.String.pipe(T.Label()), region: S.String.pipe(T.Label()), serviceId: S.String.pipe(T.Label()), }).pipe( T.Http({ method: "GET", uri: "/v2/projects/{projectId}/regions/{region}/services/{serviceId}", code: 200, baseUrl: "https://service-enablement.api.stackit.cloud", }), ), ).annotate({ identifier: "GetServiceStatusRegionalRequest" }); } } function __c5(j: number): any { switch (j) { case 0: return S.Array(S.String); case 1: return S.suspend(() => S.Struct({ hard: S.optional(__S(40, __c5, 0)), soft: S.optional(__S(40, __c5, 0)), }), ).annotate({ identifier: "Dependencies" }); case 2: return S.suspend(() => S.Struct({ action: S.optional(S.String), code: S.optional(S.String), reason: S.optional(S.String), }), ).annotate({ identifier: "ActionError" }); case 3: return S.Record(S.String, S.String); case 4: return S.suspend(() => S.Struct({ organizationId: S.optional(S.String), projectName: S.optional(S.String), projectScope: S.optional(S.String), }), ).annotate({ identifier: "ParametersGeneral" }); case 5: return S.suspend(() => S.StructWithRest( S.Struct({ general: S.optional(__S(44, __c5, 4)), }), [S.Record(S.String, S.Unknown)], ), ).annotate({ identifier: "Parameters" }); case 6: return S.suspend(() => S.Struct({ dependencies: S.optional(__S(41, __c5, 1)), enablement: S.optional(S.String), error: S.optional(__S(42, __c5, 2)), labels: S.optional(__S(43, __c5, 3)), lifecycle: S.optional(S.String), parameters: S.optional(__S(45, __c5, 5)), scope: S.optional(S.String), serviceId: S.optional(S.String), state: S.optional(S.String), }), ).annotate({ identifier: "ServiceStatus" }); } } function __c6(j: number): any { switch (j) { case 0: return S.suspend(() => S.Struct({ projectId: S.String.pipe(T.Label()), region: S.String.pipe(T.Label()), cursor: S.optional(S.String.pipe(T.Query())), }).pipe( T.Http({ method: "GET", uri: "/v2/projects/{projectId}/regions/{region}/services", code: 200, baseUrl: "https://service-enablement.api.stackit.cloud", }), ), ).annotate({ identifier: "ListServiceStatusRegionalRequest" }); case 1: return S.Array(__S(46, __c5, 6)); case 2: return S.suspend(() => S.Struct({ items: S.optional(__S(49, __c6, 1)), nextCursor: S.optional(S.String), }), ).annotate({ identifier: "ListServiceStatusRegionalResponse" }); } } // Schema table: entry i is schema j of builder f, made on first reach. function __S(i: number, f: (j: number) => unknown, j: number): any { return (__s[i] ??= __L.at(f, j)); }