import {z} from 'zod' export type UpdateApiV1betaTenantIdProfilesProfileIdArgs = {body: {name?: string | undefined, description?: string | undefined}}; export type UpdateApiV1betaTenantIdProfilesProfileIdOptions = {baseUrl?: string | undefined, basicAuth?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; export const dataStorageLoS = z.object({recoveryTimeObjective: z.number().int().optional(), provisioningPolicy: z.enum(["Thin", "Thick"]).optional(), compression: z.boolean().optional(), deduplication: z.boolean().optional(), characterCodeSet: z.string().optional(), maxFileNameLengthBytes: z.number().int().optional(), storageAccessCapability: z.array(z.enum(["Read", "Write", "Execute"])).optional()}); export const iOConnectivityLoS = z.object({accessProtocol: z.enum(["iscsi", "rbd", "fibre_channel", "nvmeof", "DSWare", "NFS"]).optional(), maxIOPS: z.number().int().optional(), minIOPS: z.number().int().optional(), maxBWS: z.number().int().optional(), minBWS: z.number().int().optional(), latency: z.number().int().optional()}); export const provisioningPropertiesSpec = z.object({dataStorage: dataStorageLoS.optional(), ioConnectivity: iOConnectivityLoS.optional()}); export const dataProtectionLoS = z.object({isIsolated: z.boolean().optional(), minLifetime: z.string().optional(), RecoveryGeographicObjective: z.enum(["Datacenter", "Rack", "RackGroup", "Region", "Row", "Server"]).optional(), RecoveryPointObjectiveTime: z.string().optional(), RecoveryTimeObjective: z.enum(["OnlineActive", "OnlinePassive", "Nearline", "Offline"]).optional(), ReplicaType: z.enum(["Clone", "Mirror", "Snapshot", "TokenizedClone"]).optional()}); export const replicationPropertiesSpec = z.object({dataProtection: dataProtectionLoS.optional(), replicaInfos: z.object({replicaUpdateMode: z.enum(["Active", "Adaptive", "Asynchronous", "Synchronous"]).optional(), replcationBandwidth: z.number().int().optional(), replicationPeriod: z.string().optional(), consistencyEnalbed: z.boolean().optional()}).optional()}); export const snapshotPropertiesSpec = z.object({schedule: z.object({datetime: z.string().optional(), occurrence: z.enum(["Daily", "Weekly", "Monthly"]).optional()}).optional(), retention: z.object({duration: z.number().int().optional(), number: z.number().int().optional()}).optional(), topology: z.object({bucket: z.string().optional()}).optional()}); export const dataProtectionPropertiesSpec = z.object({dataProtection: dataProtectionLoS.optional(), consistencyEnalbed: z.boolean().optional()}); export const customPropertiesSpec = z.record(z.string(), z.unknown()); export const profileRespSpec = z.object({id: z.string().optional(), createdAt: z.string().optional(), updatedAt: z.string().optional(), name: z.string().min(1).max(255).optional(), storageType: z.enum(["block", "file", "object"]).optional(), description: z.string().optional(), provisioningProperties: provisioningPropertiesSpec.optional(), replicationProperties: replicationPropertiesSpec.optional(), snapshotProperties: snapshotPropertiesSpec.optional(), dataProtectionProperties: dataProtectionPropertiesSpec.optional(), customProperties: customPropertiesSpec.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 }; /** * Updates a profile. * * PUT /v1beta/{tenantId}/profiles/{profileId} */ export const updateApiV1betaTenantIdProfilesProfileId = async (args: UpdateApiV1betaTenantIdProfilesProfileIdArgs, options?: UpdateApiV1betaTenantIdProfilesProfileIdOptions) => { const {baseUrl = "https://localhost:50040", fetch: fetchFn = fetch, basicAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") if (basicAuth !== undefined) headers.set('authorization', `Basic ${btoa(`${basicAuth.username}:${basicAuth.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/v1beta/${encodeURIComponent(String(args.tenantId))}/profiles/${encodeURIComponent(String(args.profileId))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", 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(profileRespSpec, await res.json()) };