import {z} from 'zod' export type IoK8sApimachineryPkgApisMetaV1Patch = Record; export type PatchApiApisOperationsKubeedgeIoV1alpha1ImageprepulljobsNameArgs = {dryRun?: string | undefined, fieldManager?: string | undefined, fieldValidation?: string | undefined, force?: boolean | undefined, body: IoK8sApimachineryPkgApisMetaV1Patch}; export type PatchApiApisOperationsKubeedgeIoV1alpha1ImageprepulljobsNameOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; export const ioK8sApimachineryPkgApisMetaV1Time = z.string(); export const ioK8sApimachineryPkgApisMetaV1FieldsV1 = z.object({}); export const ioK8sApimachineryPkgApisMetaV1ManagedFieldsEntry = z.object({apiVersion: z.string().optional(), fieldsType: z.string().optional(), fieldsV1: ioK8sApimachineryPkgApisMetaV1FieldsV1.optional(), manager: z.string().optional(), operation: z.string().optional(), subresource: z.string().optional(), time: ioK8sApimachineryPkgApisMetaV1Time.optional()}); export const ioK8sApimachineryPkgApisMetaV1OwnerReference = z.object({apiVersion: z.string(), blockOwnerDeletion: z.boolean().optional(), controller: z.boolean().optional(), kind: z.string(), name: z.string(), uid: z.string()}); export const ioK8sApimachineryPkgApisMetaV1ObjectMeta = z.object({annotations: z.record(z.string(), z.string()).optional(), creationTimestamp: ioK8sApimachineryPkgApisMetaV1Time.optional(), deletionGracePeriodSeconds: z.number().int().optional(), deletionTimestamp: ioK8sApimachineryPkgApisMetaV1Time.optional(), finalizers: z.array(z.string()).optional(), generateName: z.string().optional(), generation: z.number().int().optional(), labels: z.record(z.string(), z.string()).optional(), managedFields: z.array(ioK8sApimachineryPkgApisMetaV1ManagedFieldsEntry).optional(), name: z.string().optional(), namespace: z.string().optional(), ownerReferences: z.array(ioK8sApimachineryPkgApisMetaV1OwnerReference).optional(), resourceVersion: z.string().optional(), selfLink: z.string().optional(), uid: z.string().optional()}); export const ioK8sApimachineryPkgApisMetaV1LabelSelectorRequirement = z.object({key: z.string(), operator: z.string(), values: z.array(z.string()).optional()}); export const ioK8sApimachineryPkgApisMetaV1LabelSelector = z.object({matchExpressions: z.array(ioK8sApimachineryPkgApisMetaV1LabelSelectorRequirement).optional(), matchLabels: z.record(z.string(), z.string()).optional()}); export const comGithubKubeedgeApiApisOperationsV1alpha1ImagePrePullTemplate = z.object({checkItems: z.array(z.string()).optional(), concurrency: z.number().int().optional(), failureTolerate: z.string().optional(), imageSecrets: z.string().optional(), images: z.array(z.string()).optional(), labelSelector: ioK8sApimachineryPkgApisMetaV1LabelSelector.optional(), nodeNames: z.array(z.string()).optional(), retryTimes: z.number().int().optional(), timeoutSeconds: z.number().int().optional()}); export const comGithubKubeedgeApiApisOperationsV1alpha1ImagePrePullJobSpec = z.object({imagePrePullTemplate: comGithubKubeedgeApiApisOperationsV1alpha1ImagePrePullTemplate.optional()}); export const comGithubKubeedgeApiApisOperationsV1alpha1ImageStatus = z.object({image: z.string().optional(), reason: z.string().optional(), state: z.string().optional()}); export const comGithubKubeedgeApiApisOperationsV1alpha1TaskStatus = z.object({action: z.string().optional(), event: z.string().optional(), nodeName: z.string().optional(), reason: z.string().optional(), state: z.string().optional(), time: z.string().optional()}); export const comGithubKubeedgeApiApisOperationsV1alpha1ImagePrePullStatus = z.object({imageStatus: z.array(comGithubKubeedgeApiApisOperationsV1alpha1ImageStatus).optional(), nodeStatus: comGithubKubeedgeApiApisOperationsV1alpha1TaskStatus.optional()}); export const comGithubKubeedgeApiApisOperationsV1alpha1ImagePrePullJobStatus = z.object({action: z.string().optional(), event: z.string().optional(), reason: z.string().optional(), state: z.string().optional(), status: z.array(comGithubKubeedgeApiApisOperationsV1alpha1ImagePrePullStatus).optional(), time: z.string().optional()}); export const comGithubKubeedgeApiApisOperationsV1alpha1ImagePrePullJob = z.object({apiVersion: z.string().optional(), kind: z.string().optional(), metadata: ioK8sApimachineryPkgApisMetaV1ObjectMeta.optional(), spec: comGithubKubeedgeApiApisOperationsV1alpha1ImagePrePullJobSpec, status: comGithubKubeedgeApiApisOperationsV1alpha1ImagePrePullJobStatus.optional()}); 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 }; /** * partially update the specified ImagePrePullJob * * PATCH /apis/operations.kubeedge.io/v1alpha1/imageprepulljobs/{name} */ export const patchApiApisOperationsKubeedgeIoV1alpha1ImageprepulljobsName = async (args: PatchApiApisOperationsKubeedgeIoV1alpha1ImageprepulljobsNameArgs, options: PatchApiApisOperationsKubeedgeIoV1alpha1ImageprepulljobsNameOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json-patch+json") headers.set('accept', "application/json") if (args.dryRun != null) query.append("dryRun", String(args.dryRun)) if (args.fieldManager != null) query.append("fieldManager", String(args.fieldManager)) if (args.fieldValidation != null) query.append("fieldValidation", String(args.fieldValidation)) if (args.force != null) query.append("force", String(args.force)) const url = `${baseUrl.replace(/\/+$/, '')}/apis/operations.kubeedge.io/v1alpha1/imageprepulljobs/${encodeURIComponent(String(args.name))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PATCH", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(comGithubKubeedgeApiApisOperationsV1alpha1ImagePrePullJob, await res.json()) };