import {z} from 'zod' export type DeleteApiMqttBrokersPublicIdArgs = {'Api-Version': 2, 'Api-Application': string, 'Api-Company': string, 'Api-Branding'?: string | undefined, publicId: string}; export type DeleteApiMqttBrokersPublicIdOptions = {baseUrl?: string | undefined, bearerToken?: string | undefined, fetch?: typeof fetch | undefined}; export const deleteApiMqttBrokersPublicIdResponse = z.object({status: z.string(), type: z.string(), data: z.object({}).nullable()}); 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 }; /** * MqttBroker * * DELETE /mqtt-brokers/{publicId} */ export const deleteApiMqttBrokersPublicId = async (args: DeleteApiMqttBrokersPublicIdArgs, options?: DeleteApiMqttBrokersPublicIdOptions) => { const {baseUrl = "https://portal.ixon.cloud:443/api", fetch: fetchFn = fetch, bearerToken} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (args['Api-Version'] != null) headers.set("Api-Version", String(args['Api-Version'])) if (args['Api-Application'] != null) headers.set("Api-Application", String(args['Api-Application'])) if (args['Api-Company'] != null) headers.set("Api-Company", String(args['Api-Company'])) if (args['Api-Branding'] != null) headers.set("Api-Branding", String(args['Api-Branding'])) if (bearerToken !== undefined) headers.set('authorization', `Bearer ${bearerToken}`) const url = `${baseUrl.replace(/\/+$/, '')}/mqtt-brokers/${encodeURIComponent(String(args.publicId))}${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(deleteApiMqttBrokersPublicIdResponse, await res.json()) };