import {z} from 'zod' export type RvgSecondaryV2v0 = {SecondaryHost?: string | undefined, SecondaryDgId?: string | undefined, RlinkFromPrimary?: string | undefined, RlinkToPrimary?: string | undefined, ConfiguredMode?: ('disable' | 'override') | undefined, CurrentMode?: string | undefined, ReplicationStatus?: string | undefined, DataStatus?: string | undefined, TimestampInfo?: string | undefined, LoggingTo?: string | undefined, SrlProtection?: ('autodcm' | 'dcm' | 'fail' | 'disable' | 'override') | undefined, LatencyProtection?: ('fail' | 'disable' | 'override') | undefined, LatencyHighMark?: string | undefined, LatencyLowMark?: string | undefined, BandwidthLimit?: string | undefined, PacketSize?: number | undefined, Protocol?: ('TCP' | 'UDP') | undefined, DataVolumes?: (Array<{VolId?: string | undefined}>) | undefined}; export type Operation = {Name?: string | undefined, href?: string | undefined}; export type RvgDetailV2v0 = {RvgName?: string | undefined, Primary?: ({PrimaryHost?: string | undefined, DgId?: string | undefined, RvgState?: string | undefined, TotalSecondaries?: number | undefined, FailoverMode?: ('migrate' | 'takeover' | 'takeoverwithautofailback') | undefined}) | undefined, SecondaryHost?: string | undefined, Online?: boolean | undefined, Secondary?: Array | undefined, DataVolumes?: (Array<{VolId?: string | undefined}>) | undefined, SrlVolumeId?: string | undefined, Encrypted?: boolean | undefined, ConfigErrors?: string | undefined, LocalHost?: string | undefined, Operations?: Array | undefined}; export type PatchApiDiskgroupsDgIdRvgsRvgIdArgs = {DgId: string, RvgId: string, nodename?: string | undefined, body: RvgDetailV2v0}; export type PatchApiDiskgroupsDgIdRvgsRvgIdOptions = {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 }; /** * Update a replicated volume group * * PATCH /diskgroups/{DgId}/rvgs/{RvgId} */ export const patchApiDiskgroupsDgIdRvgsRvgId = async (args: PatchApiDiskgroupsDgIdRvgsRvgIdArgs, options: PatchApiDiskgroupsDgIdRvgsRvgIdOptions) => { 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") if (args.nodename != null) query.append("nodename", String(args.nodename)) const url = `${baseUrl.replace(/\/+$/, '')}/diskgroups/${encodeURIComponent(String(args.DgId))}/rvgs/${encodeURIComponent(String(args.RvgId))}${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()) };