export type AivenAclPermission = 'read' | 'write' | 'readwrite' | 'admin'; export type AivenAclCreatePayload = {permission: AivenAclPermission, topic: string}; export type AivenSchemaRegistryAclPermission = 'schema_registry_read' | 'schema_registry_write'; export type AivenSRAclCreatePayload = {permission: AivenSchemaRegistryAclPermission, resource: string}; export type AivenAclsCreateRequest = {acls?: Array | undefined, schemaRegistryAcls?: Array | undefined}; export type UpdateApiPublicV1ClustersClusterNameServiceAccountsAivenAivenSAUsernamePatternAclArgs = {clusterName: string, AivenSAUsernamePattern: string, body: AivenAclsCreateRequest}; export type UpdateApiPublicV1ClustersClusterNameServiceAccountsAivenAivenSAUsernamePatternAclOptions = {baseUrl: string, httpAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create (or update) acls for a given Aiven service account * * PUT /public/v1/clusters/{clusterName}/service-accounts-aiven/{AivenSAUsernamePattern}/acl */ export const updateApiPublicV1ClustersClusterNameServiceAccountsAivenAivenSAUsernamePatternAcl = async (args: UpdateApiPublicV1ClustersClusterNameServiceAccountsAivenAivenSAUsernamePatternAclArgs, options: UpdateApiPublicV1ClustersClusterNameServiceAccountsAivenAivenSAUsernamePatternAclOptions) => { const {baseUrl, fetch: fetchFn = fetch, httpAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (httpAuth !== undefined) headers.set('authorization', `Bearer ${httpAuth}`) const url = `${baseUrl.replace(/\/+$/, '')}/public/v1/clusters/${encodeURIComponent(String(args.clusterName))}/service-accounts-aiven/${encodeURIComponent(String(args.AivenSAUsernamePattern))}/acl${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 undefined };