import {z} from 'zod' export type GetApiApiV1ServicePrincipalsServicePrincipalIdTrustsArgs = {service_principal_id: string}; export type GetApiApiV1ServicePrincipalsServicePrincipalIdTrustsOptions = {baseUrl?: string | undefined, bearerAuth?: string | undefined, oauth?: string | undefined, fetch?: typeof fetch | undefined}; export const c1ApiWorkloadFederationV1C1EdgeService = z.object({appId: z.string().optional(), resourceId: z.string().optional(), resourceKind: z.enum(["C1_EDGE_RESOURCE_KIND_UNSPECIFIED", "C1_EDGE_RESOURCE_KIND_EDGE", "C1_EDGE_RESOURCE_KIND_AUTHZEN_SERVER"]).optional()}); export const c1ApiWorkloadFederationV1WorkloadFederationTrust = z.object({allowSourceCidrs: z.array(z.string()).nullable().optional(), c1EdgeService: c1ApiWorkloadFederationV1C1EdgeService.nullable().optional(), clientId: z.string().optional(), conditionExpression: z.string().optional(), createdAt: z.string().nullable().optional(), description: z.string().optional(), disabled: z.boolean().optional(), displayName: z.string().optional(), passthroughClaims: z.array(z.string()).nullable().optional(), providerId: z.string().optional(), scopedRoleIds: z.array(z.string()).nullable().optional(), servicePrincipalId: z.string().optional(), updatedAt: z.string().nullable().optional()}); export const c1ApiWorkloadFederationV1WorkloadFederationServiceListTrustsResponse = z.object({list: z.array(c1ApiWorkloadFederationV1WorkloadFederationTrust).nullable().optional(), nextPageToken: z.string().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 }; /** * List Trusts * * GET /api/v1/service_principals/{service_principal_id}/trusts */ export const getApiApiV1ServicePrincipalsServicePrincipalIdTrusts = async (args: GetApiApiV1ServicePrincipalsServicePrincipalIdTrustsArgs, options?: GetApiApiV1ServicePrincipalsServicePrincipalIdTrustsOptions) => { const {baseUrl = "https://example.conductor.one", fetch: fetchFn = fetch, bearerAuth, oauth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/json") if (bearerAuth !== undefined) headers.set('authorization', `Bearer ${bearerAuth}`) if (oauth !== undefined) headers.set('authorization', `Bearer ${oauth}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/service_principals/${encodeURIComponent(String(args.service_principal_id))}/trusts${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(c1ApiWorkloadFederationV1WorkloadFederationServiceListTrustsResponse, await res.json()) };