export type AclPrincipal = {type: string, name: string}; export type ResourceTypeForResourcePattern = 'Unknown' | 'Topic' | 'Group' | 'Cluster' | 'TransactionalId' | 'DelegationToken' | 'User'; export type PatternTypeForResourcePattern = 'Literal' | 'Prefixed'; export type ResourcePattern = {resourceType: ResourceTypeForResourcePattern, name: string, patternType: PatternTypeForResourcePattern}; export type AclPermissionTypeForAccessControlEntry = 'Deny' | 'Allow'; export type OperationStates = {Unknown?: AclPermissionTypeForAccessControlEntry | undefined, All?: AclPermissionTypeForAccessControlEntry | undefined, Read?: AclPermissionTypeForAccessControlEntry | undefined, Write?: AclPermissionTypeForAccessControlEntry | undefined, Create?: AclPermissionTypeForAccessControlEntry | undefined, Delete?: AclPermissionTypeForAccessControlEntry | undefined, Alter?: AclPermissionTypeForAccessControlEntry | undefined, Describe?: AclPermissionTypeForAccessControlEntry | undefined, ClusterAction?: AclPermissionTypeForAccessControlEntry | undefined, DescribeConfigs?: AclPermissionTypeForAccessControlEntry | undefined, AlterConfigs?: AclPermissionTypeForAccessControlEntry | undefined, IdempotentWrite?: AclPermissionTypeForAccessControlEntry | undefined, CreateTokens?: AclPermissionTypeForAccessControlEntry | undefined, DescribeTokens?: AclPermissionTypeForAccessControlEntry | undefined, TwoPhaseCommit?: AclPermissionTypeForAccessControlEntry | undefined} | {[key: string]: AclPermissionTypeForAccessControlEntry}; export type AclForResourceAndHost = {pattern: ResourcePattern, host: string, operationStates: OperationStates}; export type AllAclForPrincipal = {aclPrincipal: AclPrincipal, acls?: Array | undefined}; export type UpdateApiPublicV1ClustersClusterNameServiceAccountsArgs = {clusterName: string, body: AllAclForPrincipal}; export type UpdateApiPublicV1ClustersClusterNameServiceAccountsOptions = {baseUrl: string, httpAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Put acl for a given service account * * PUT /public/v1/clusters/{clusterName}/service-accounts */ export const updateApiPublicV1ClustersClusterNameServiceAccounts = async (args: UpdateApiPublicV1ClustersClusterNameServiceAccountsArgs, options: UpdateApiPublicV1ClustersClusterNameServiceAccountsOptions) => { 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${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 };