import {z} from 'zod' export type AuthenticationOidcProviderDTO = {name?: string | undefined, description?: string | undefined, vendorType?: ('GENERIC' | 'KEYCLOAK') | undefined, issuerUrl?: string | undefined, discoveryUrl?: string | undefined, autoDiscover?: boolean | undefined, tokenEndpoint?: string | undefined, introspectionEndpoint?: string | undefined, userInfoEndpoint?: string | undefined, jwksEndpoint?: string | undefined, endSessionEndpoint?: string | undefined, clientId?: string | undefined, clientSecret?: string | undefined, clientSecretSet?: boolean | undefined, clientAuthMethod?: ('CLIENT_SECRET_BASIC' | 'CLIENT_SECRET_POST' | 'PRIVATE_KEY_JWT') | undefined, validationMode?: ('OFFLINE' | 'ONLINE' | 'HYBRID') | undefined, jwksSourceMode?: ('DISCOVERY' | 'STATIC') | undefined, staticJwksJson?: string | undefined, certificateName?: string | undefined, jwksCacheTimeoutSeconds?: number | undefined, allowedSignatureAlgorithms?: Array | undefined, validateIssuer?: boolean | undefined, expectedIssuer?: string | undefined, validateAudience?: boolean | undefined, expectedAudience?: Array | undefined, maxClockSkewSeconds?: number | undefined, connectionTimeoutSeconds?: number | undefined, readTimeoutSeconds?: number | undefined, usernameClaimPath?: string | undefined, emailClaimPath?: string | undefined, fullNameClaimPath?: string | undefined, rolesClaimPath?: string | undefined, groupsClaimPath?: string | undefined, requireMatchingCredential?: boolean | undefined, roleSource?: ('TOKEN_CLAIM' | 'SYNCED_CREDENTIAL' | 'BOTH') | undefined, syncEnabled?: boolean | undefined, realm?: string | undefined, adminBaseUrl?: string | undefined, syncPageSize?: number | undefined, groupSyncEnabled?: boolean | undefined, roleSyncSource?: ('REALM_ROLES' | 'CLIENT_ROLES' | 'GROUPS') | undefined, syncClientId?: string | undefined}; export type UpdateApiApiopsProjectsProjectNameOidcProvidersNameArgs = {projectName: string, name: string, body: AuthenticationOidcProviderDTO}; export type UpdateApiApiopsProjectsProjectNameOidcProvidersNameOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; export const authenticationOidcProviderDTO = z.object({name: z.string().optional(), description: z.string().optional(), vendorType: z.enum(["GENERIC", "KEYCLOAK"]).optional(), issuerUrl: z.string().optional(), discoveryUrl: z.string().optional(), autoDiscover: z.boolean().optional(), tokenEndpoint: z.string().optional(), introspectionEndpoint: z.string().optional(), userInfoEndpoint: z.string().optional(), jwksEndpoint: z.string().optional(), endSessionEndpoint: z.string().optional(), clientId: z.string().optional(), clientSecret: z.string().optional(), clientSecretSet: z.boolean().optional(), clientAuthMethod: z.enum(["CLIENT_SECRET_BASIC", "CLIENT_SECRET_POST", "PRIVATE_KEY_JWT"]).optional(), validationMode: z.enum(["OFFLINE", "ONLINE", "HYBRID"]).optional(), jwksSourceMode: z.enum(["DISCOVERY", "STATIC"]).optional(), staticJwksJson: z.string().optional(), certificateName: z.string().optional(), jwksCacheTimeoutSeconds: z.number().int().optional(), allowedSignatureAlgorithms: z.array(z.string()).optional(), validateIssuer: z.boolean().optional(), expectedIssuer: z.string().optional(), validateAudience: z.boolean().optional(), expectedAudience: z.array(z.string()).optional(), maxClockSkewSeconds: z.number().int().optional(), connectionTimeoutSeconds: z.number().int().optional(), readTimeoutSeconds: z.number().int().optional(), usernameClaimPath: z.string().optional(), emailClaimPath: z.string().optional(), fullNameClaimPath: z.string().optional(), rolesClaimPath: z.string().optional(), groupsClaimPath: z.string().optional(), requireMatchingCredential: z.boolean().optional(), roleSource: z.enum(["TOKEN_CLAIM", "SYNCED_CREDENTIAL", "BOTH"]).optional(), syncEnabled: z.boolean().optional(), realm: z.string().optional(), adminBaseUrl: z.string().optional(), syncPageSize: z.number().int().optional(), groupSyncEnabled: z.boolean().optional(), roleSyncSource: z.enum(["REALM_ROLES", "CLIENT_ROLES", "GROUPS"]).optional(), syncClientId: 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 }; /** * Updates an OIDC identity provider by name. ABSENT vs EMPTY semantics apply to clientSecret (2026-08-04 decision, same as ApiOpsLlmProvider): omit the field entirely to PRESERVE the stored value; send it as an empty string to CLEAR it. It is never round-tripped through GET. * * PUT /apiops/projects/{projectName}/oidc-providers/{name}/ */ export const updateApiApiopsProjectsProjectNameOidcProvidersName = async (args: UpdateApiApiopsProjectsProjectNameOidcProvidersNameArgs, options?: UpdateApiApiopsProjectsProjectNameOidcProvidersNameOptions) => { const {baseUrl = "http://167.86.118.166:32080", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/apiops/projects/${encodeURIComponent(String(args.projectName))}/oidc-providers/${encodeURIComponent(String(args.name))}/${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(authenticationOidcProviderDTO, await res.json()) };