import {z} from 'zod' export type GetApiDiskgroupsDgIdVsetsVsetIdFilesystemsFsIdArgs = {DgId: string, VsetId: string, FsId: string, nodename?: string | undefined, humanReadableFormat?: boolean | undefined}; export type GetApiDiskgroupsDgIdVsetsVsetIdFilesystemsFsIdOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; export const filesystemInfo = z.object({FilesystemType: z.string().max(31).optional(), BlockDevice: z.string().optional(), Mounted: z.boolean().optional(), FSSize: z.string().optional(), BlockSize: z.union([z.literal(1024), z.literal(2048), z.literal(4096), z.literal(8192)]).optional(), LogSize: z.number().int().optional(), InodeSize: z.union([z.literal(256), z.literal(512)]).optional(), RcqSize: z.number().int().optional(), DLVersion: z.number().int().optional(), LargeFiles: z.boolean().optional(), MaxLinkSupport: z.boolean().optional(), ExtentDefragInprogress: z.boolean().optional(), SpaceDefragInprogress: z.boolean().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 }; /** * Get filesystem details * * GET /diskgroups/{DgId}/vsets/{VsetId}/filesystems/{FsId} */ export const getApiDiskgroupsDgIdVsetsVsetIdFilesystemsFsId = async (args: GetApiDiskgroupsDgIdVsetsVsetIdFilesystemsFsIdArgs, options: GetApiDiskgroupsDgIdVsetsVsetIdFilesystemsFsIdOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.nodename != null) query.append("nodename", String(args.nodename)) if (args.humanReadableFormat != null) query.append("humanReadableFormat", String(args.humanReadableFormat)) const url = `${baseUrl.replace(/\/+$/, '')}/diskgroups/${encodeURIComponent(String(args.DgId))}/vsets/${encodeURIComponent(String(args.VsetId))}/filesystems/${encodeURIComponent(String(args.FsId))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(filesystemInfo, await res.json()) };