import {z} from 'zod' export type Attribute = {Value: unknown, Type?: ('scalar' | 'vector' | 'keylist' | 'associate') | undefined, KeyAttribute?: boolean | undefined}; export type ProtocolVersionV2 = {ProductName: 'cvm' | 'fen' | 'fs' | 'gab' | 'odm' | 'vcs', Version?: string | undefined, SupportedVersions?: (Array<{NodeName?: string | undefined, Versions?: Array | undefined}>) | undefined}; export type ClusterV2v0 = {AdministratorGroups?: Attribute | undefined, Administrators?: Attribute | undefined, AutoClearQ?: Attribute | undefined, AutoStartTimeout?: Attribute | undefined, AutoAddSystemToCSG?: Attribute | undefined, BackupInterval?: Attribute | undefined, CID?: Attribute | undefined, ClusState?: Attribute | undefined, ClusterAddress?: Attribute | undefined, ClusterLocation?: Attribute | undefined, ClusterName?: Attribute | undefined, ClusterOwner?: Attribute | undefined, ClusterRecipients?: Attribute | undefined, ClusterTime?: Attribute | undefined, ClusterUUID?: Attribute | undefined, CompareRSM?: Attribute | undefined, ConfigState?: ('DUMP' | 'MAKERO_DUMP' | 'MAKERW') | undefined, Protocols?: Array | undefined, ConnectorState?: Attribute | undefined, CounterInterval?: Attribute | undefined, CounterMissAction?: Attribute | undefined, CounterMissTolerance?: Attribute | undefined, CredRenewFrequency?: Attribute | undefined, CVMNodeStates?: (Array<{system?: string | undefined, role?: string | undefined, state?: string | undefined, errDetails?: string | undefined}>) | undefined, DeleteOnlineResource?: Attribute | undefined, DumpingMembership?: Attribute | undefined, EngineClass?: Attribute | undefined, EngineVersion?: Attribute | undefined, EnableFFDC?: Attribute | undefined, EnableVMAutoDiscovery?: Attribute | undefined, EnablePBF?: Attribute | undefined, EnginePriority?: Attribute | undefined, EngineShutdown?: Attribute | undefined, FipsMode?: Attribute | undefined, GlobalCounter?: Attribute | undefined, Guests?: Attribute | undefined, GuestGroups?: Attribute | undefined, DefaultGuestAccess?: Attribute | undefined, GroupLimit?: Attribute | undefined, HacliUserLevel?: Attribute | undefined, HostAvailableMeters?: Attribute | undefined, HostMeters?: Attribute | undefined, IV256List?: Attribute | undefined, LockMemory?: Attribute | undefined, LogClusterUUID?: Attribute | undefined, LogSize?: Attribute | undefined, MeterControl?: Attribute | undefined, MeterUnit?: Attribute | undefined, MeterWeight?: Attribute | undefined, MixedVersion?: Attribute | undefined, Notifier?: Attribute | undefined, OpenVCSCommunicationPort?: Attribute | undefined, OperatorGroups?: Attribute | undefined, Operators?: Attribute | undefined, PanicOnNoMem?: Attribute | undefined, PreferredFencingPolicy?: Attribute | undefined, PrintMsg?: Attribute | undefined, ProcessClass?: Attribute | undefined, ProcessPriority?: Attribute | undefined, ProtocolNumber?: Attribute | undefined, ReadOnly?: Attribute | undefined, ResourceLimit?: Attribute | undefined, SecInfo?: Attribute | undefined, SecInfo256?: Attribute | undefined, IV256?: Attribute | undefined, SecInfoLevel?: Attribute | undefined, SecureClus?: Attribute | undefined, SiteAware?: Attribute | undefined, SourceFile?: Attribute | undefined, Statistics?: Attribute | undefined, Stewards?: Attribute | undefined, SystemRebootAction?: Attribute | undefined, TypeLimit?: Attribute | undefined, UseFence?: Attribute | undefined, UserNames?: Attribute | undefined, VCSFeatures?: Attribute | undefined, VCSMode?: Attribute | undefined, WACPort?: Attribute | undefined}; export type PatchApiClustersClusterNameArgs = {ClusterName: string, body: ClusterV2v0}; export type PatchApiClustersClusterNameOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; export const response = z.object({detail: z.string().optional(), status: z.number().int().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 }; /** * Operate on the cluster * * PATCH /clusters/{ClusterName} */ export const patchApiClustersClusterName = async (args: PatchApiClustersClusterNameArgs, options: PatchApiClustersClusterNameOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/clusters/${encodeURIComponent(String(args.ClusterName))}${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(response, await res.json()) };