import {z} from 'zod' export type DeleteApiV2OrganizationsOrganizationClustersClusterArgs = {organization: string, cluster: string}; export type DeleteApiV2OrganizationsOrganizationClustersClusterOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; export const deleteApiV2OrganizationsOrganizationClustersClusterResponse = z.object({}); 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 }; /** * Unregisters a cluster from the platform. * Deleting a cluster will unregister it from the management plane, and the agents will stop receiving * configuration updates. Agent tokens for the cluster are revoked as well, so agents that are still * running will fail to report back cluster status to the management plane. * Note that unregistering the cluster is a management plane only operation. This does not uninstall * the agents from the local cluster. Agents will continue running and the services that are deployed * in that cluster will be able to continue operating with the last applied configuration. * Unregistering a cluster from the management plane should not generate downtime to services that are * running on that cluster. * * DELETE /v2/organizations/{organization}/clusters/{cluster} */ export const deleteApiV2OrganizationsOrganizationClustersCluster = async (args: DeleteApiV2OrganizationsOrganizationClustersClusterArgs, options: DeleteApiV2OrganizationsOrganizationClustersClusterOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/v2/organizations/${encodeURIComponent(String(args.organization))}/clusters/${encodeURIComponent(String(args.cluster))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "DELETE", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return validateResponse(deleteApiV2OrganizationsOrganizationClustersClusterResponse, await res.json()) };