import {z} from 'zod' export type GetApiClustersClusterNameServicegroupsArgs = {attributes?: string | undefined, ClusterName: string}; export type GetApiClustersClusterNameServicegroupsOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; export const readonlyattribute = z.object({Value: z.unknown(), Scope: z.enum(["global", "local"]).optional(), Type: z.enum(["scalar", "vector", "keylist", "associate"]).optional()}); export const servicegroupattribute = z.object({Value: z.unknown(), Scope: z.enum(["global", "local"]).optional(), Type: z.enum(["scalar", "vector", "keylist", "associate"]).optional()}); export const servicegroupdependency = z.object({GroupName: z.string(), DependencyType: z.enum(["online_local_firm", "online_local_soft", "online_local_hard", "online_global_firm", "online_global_soft", "online_global_hard", "online_remote_firm", "online_remote_soft", "online_remote_hard", "offline_local", "none"])}); export const servicegroupV2v0Dependency = z.object({Parents: z.array(servicegroupdependency).optional(), Children: z.array(servicegroupdependency)}); export const groupfreezeV2v0 = z.object({Frozen: z.boolean().optional(), Persistent: z.boolean().optional()}); export const groupstateV2v0 = z.object({System: z.string().optional(), State: z.string(), Propagate: z.boolean().optional(), Ifprobed: z.boolean().optional(), Force: z.boolean().optional()}); export const groupsystemV2v0 = z.object({System: z.string().optional(), Priority: z.number().int().optional()}); export const servicegrouplistElementV2v0 = z.object({ActiveCount: readonlyattribute.optional(), AdministratorGroups: servicegroupattribute.optional(), Administrators: servicegroupattribute.optional(), Authority: readonlyattribute.optional(), AutoClearCount: readonlyattribute.optional(), AutoClearInterval: servicegroupattribute.optional(), AutoClearLimit: servicegroupattribute.optional(), AutoDisabled: servicegroupattribute.optional(), AutoFailOver: servicegroupattribute.optional(), AutoRestart: servicegroupattribute.optional(), AutoStart: servicegroupattribute.optional(), AutoStartIfPartial: servicegroupattribute.optional(), AutoStartList: servicegroupattribute.optional(), AutoStartPolicy: servicegroupattribute.optional(), CapacityReserved: readonlyattribute.optional(), ClusterFailOverPolicy: servicegroupattribute.optional(), ClusterList: servicegroupattribute.optional(), ContainerInfo: servicegroupattribute.optional(), CurrentCount: readonlyattribute.optional(), DeferAutoStart: readonlyattribute.optional(), Dependency: servicegroupV2v0Dependency.optional(), DisableFaultMessages: servicegroupattribute.optional(), Enabled: servicegroupattribute.optional(), Evacuate: servicegroupattribute.optional(), Evacuating: readonlyattribute.optional(), EvacList: readonlyattribute.optional(), EvacuatingForGroup: readonlyattribute.optional(), Failover: readonlyattribute.optional(), FailOverPolicy: servicegroupattribute.optional(), FaultPropagation: servicegroupattribute.optional(), FromQ: readonlyattribute.optional(), Frozen: readonlyattribute.optional(), FrozenState: groupfreezeV2v0.optional(), GroupOwner: servicegroupattribute.optional(), GroupRecipients: servicegroupattribute.optional(), Guests: servicegroupattribute.optional(), IntentOnline: readonlyattribute.optional(), IntentionalOnlineList: readonlyattribute.optional(), LastSuccess: readonlyattribute.optional(), Load: servicegroupattribute.optional(), ManageFaults: servicegroupattribute.optional(), ManualOps: servicegroupattribute.optional(), MeterWeight: servicegroupattribute.optional(), MigrateQ: readonlyattribute.optional(), Name: z.string().optional(), NumRetries: readonlyattribute.optional(), OnlineAtUnfreeze: readonlyattribute.optional(), OnlineClearParent: servicegroupattribute.optional(), OnlineRetryInterval: servicegroupattribute.optional(), OnlineRetryLimit: servicegroupattribute.optional(), OperatorGroups: servicegroupattribute.optional(), Operators: servicegroupattribute.optional(), Parallel: servicegroupattribute.optional(), PathCount: readonlyattribute.optional(), PCVAllowOnline: readonlyattribute.optional(), PolicyIntention: readonlyattribute.optional(), PreOnline: servicegroupattribute.optional(), PreOnlining: readonlyattribute.optional(), PreonlineTimeout: servicegroupattribute.optional(), Prerequisites: servicegroupattribute.optional(), PreSwitch: servicegroupattribute.optional(), PreSwitching: readonlyattribute.optional(), PrintTree: servicegroupattribute.optional(), Priority: servicegroupattribute.optional(), Probed: readonlyattribute.optional(), ProbesPending: readonlyattribute.optional(), ProPCV: servicegroupattribute.optional(), Responding: readonlyattribute.optional(), SourceFile: servicegroupattribute.optional(), States: z.array(groupstateV2v0).optional(), SysDownPolicy: servicegroupattribute.optional(), SystemList: z.array(groupsystemV2v0).optional(), SystemZones: servicegroupattribute.optional(), Tag: readonlyattribute.optional(), TargetCount: readonlyattribute.optional(), TFrozen: servicegroupattribute.optional(), ToQ: readonlyattribute.optional(), TriggerPath: servicegroupattribute.optional(), TriggerResFault: servicegroupattribute.optional(), TriggerResRestart: servicegroupattribute.optional(), TriggerResStateChange: servicegroupattribute.optional(), TriggersEnabled: servicegroupattribute.optional(), TypeDependencies: servicegroupattribute.optional(), UnSteadyCount: servicegroupattribute.optional(), UserAssoc: servicegroupattribute.optional(), UserIntGlobal: servicegroupattribute.optional(), UserStrGlobal: servicegroupattribute.optional(), UserIntLocal: servicegroupattribute.optional(), UserStrLocal: servicegroupattribute.optional(), VCSi3Info: servicegroupattribute.optional()}); export const getApiClustersClusterNameServicegroupsResponse = z.array(servicegrouplistElementV2v0); 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 service group list * * GET /clusters/{ClusterName}/servicegroups */ export const getApiClustersClusterNameServicegroups = async (args: GetApiClustersClusterNameServicegroupsArgs, options: GetApiClustersClusterNameServicegroupsOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args.attributes != null) query.append("attributes", String(args.attributes)) const url = `${baseUrl.replace(/\/+$/, '')}/clusters/${encodeURIComponent(String(args.ClusterName))}/servicegroups${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(getApiClustersClusterNameServicegroupsResponse, await res.json()) };