export type TokenCreateRequest = {display_name?: string | undefined, entity_alias?: string | undefined, explicit_max_ttl?: string | undefined, id?: string | undefined, metadata?: Record | undefined, no_default_policy?: boolean | undefined, no_parent?: boolean | undefined, num_uses?: number | undefined, period?: string | undefined, policies?: Array | undefined, renewable?: boolean | undefined, ttl?: string | undefined, type?: string | undefined}; export type CreateApiAuthTokenCreateRoleNameArgs = {body: TokenCreateRequest}; export type CreateApiAuthTokenCreateRoleNameOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * This token create path is used to create new tokens adhering to the given role. * * POST /auth/token/create/{role_name} */ export const createApiAuthTokenCreateRoleName = async (args: CreateApiAuthTokenCreateRoleNameArgs, options: CreateApiAuthTokenCreateRoleNameOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/auth/token/create/${encodeURIComponent(String(args.role_name))}${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", 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 };