import {z} from 'zod' export type DeleteApiSkeV2alpha1Thr3PremiumWorkspacesWorkspaceUUIDSotoonnodepoolsResourceIdArgs = {resourceId: string, workspaceUUID: string}; export type DeleteApiSkeV2alpha1Thr3PremiumWorkspacesWorkspaceUUIDSotoonnodepoolsResourceIdOptions = {baseUrl: string, BearerToken?: string | undefined, fetch?: typeof fetch | undefined}; export const v1ListMeta = z.object({continue: z.string().optional(), remainingItemCount: z.number().int().nullable().optional(), resourceVersion: z.string().optional(), selfLink: z.string().optional()}); export const containerStatus = z.object({apiVersion: z.literal("ske.sotoon.ir/v1alpha1"), code: z.number().int(), kind: z.literal("Status"), message: z.string().optional(), metadata: v1ListMeta.optional(), reason: z.string().optional(), status: z.enum(["Success", "Failure"])}); export const validateResponse = async ( schema: { readonly '~standard': { readonly validate: (value: unknown) => ({ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }) | Promise<{ readonly value: Output; readonly issues?: undefined } | { readonly issues: ReadonlyArray<{ readonly message: string; readonly path?: ReadonlyArray | undefined }> }> } }, value: unknown ): Promise => { const result = await schema['~standard'].validate(value) if (result.issues !== undefined) { const detail = result.issues .map(({ message, path }) => path?.length ? `${path.map((segment) => String(typeof segment === 'object' ? segment.key : segment)).join('.')}: ${message}` : message ) .join('; ') throw new Error(`Response does not match the schema: ${detail}`, { cause: { issues: result.issues } }) } return result.value }; /** * Delete NodePool * * DELETE /ske/v2alpha1/thr3-premium/workspaces/{workspaceUUID}/sotoonnodepools/{resourceId} */ export const deleteApiSkeV2alpha1Thr3PremiumWorkspacesWorkspaceUUIDSotoonnodepoolsResourceId = async (args: DeleteApiSkeV2alpha1Thr3PremiumWorkspacesWorkspaceUUIDSotoonnodepoolsResourceIdArgs, options: DeleteApiSkeV2alpha1Thr3PremiumWorkspacesWorkspaceUUIDSotoonnodepoolsResourceIdOptions) => { const {baseUrl, fetch: fetchFn = fetch, BearerToken} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (BearerToken !== undefined) headers.set('authorization', `Bearer ${BearerToken}`) const url = `${baseUrl.replace(/\/+$/, '')}/ske/v2alpha1/thr3-premium/workspaces/${encodeURIComponent(String(args.workspaceUUID))}/sotoonnodepools/${encodeURIComponent(String(args.resourceId))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "DELETE", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(containerStatus, await res.json()) };