export type TokenCreateRequest = {name: string, expires_at?: (string | null) | undefined}; export type CreateApiApiV1TokensArgs = {body: TokenCreateRequest}; export type CreateApiApiV1TokensOptions = {baseUrl?: string | undefined, APIKeyHeader?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create Token * * POST /api/v1/tokens */ export const createApiApiV1Tokens = async (args: CreateApiApiV1TokensArgs, options?: CreateApiApiV1TokensOptions) => { const {baseUrl = "https://public-api.linearb.io", fetch: fetchFn = fetch, APIKeyHeader} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (APIKeyHeader !== undefined) headers.set("x-api-key", APIKeyHeader) const url = `${baseUrl.replace(/\/+$/, '')}/api/v1/tokens${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 };