// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../../core/resource'; import * as Shared from '../shared'; import { RolesV4PagePaginationArray } from '../shared'; import { APIPromise } from '../../core/api-promise'; import { PagePromise, V4PagePaginationArray, type V4PagePaginationArrayParams } from '../../core/pagination'; import { RequestOptions } from '../../internal/request-options'; import { path } from '../../internal/utils/path'; export class BaseRoles extends APIResource { static override readonly _key: readonly ['accounts', 'roles'] = Object.freeze([ 'accounts', 'roles', ] as const); /** * Get all available roles for an account. * * @example * ```ts * // Automatically fetches more pages as needed. * for await (const role of client.accounts.roles.list({ * account_id: '023e105f4ecef8ad9ca31a8372d0c353', * })) { * // ... * } * ``` */ list( params: RoleListParams, options?: RequestOptions, ): PagePromise { const { account_id, ...query } = params; return this._client.getAPIList(path`/accounts/${account_id}/roles`, V4PagePaginationArray, { query, ...options, }); } /** * Get information about a specific role for an account. * * @example * ```ts * const role = await client.accounts.roles.get( * '3536bcfad5faccb999b47003c79917fb', * { account_id: '023e105f4ecef8ad9ca31a8372d0c353' }, * ); * ``` */ get(roleID: string, params: RoleGetParams, options?: RequestOptions): APIPromise { const { account_id } = params; return ( this._client.get(path`/accounts/${account_id}/roles/${roleID}`, options) as APIPromise<{ result: Shared.Role; }> )._thenUnwrap((obj) => obj.result); } } export class Roles extends BaseRoles {} export interface RoleListParams extends V4PagePaginationArrayParams { /** * Path param: Account identifier tag. */ account_id: string; } export interface RoleGetParams { /** * Account identifier tag. */ account_id: string; } export declare namespace Roles { export { type RoleListParams as RoleListParams, type RoleGetParams as RoleGetParams }; } export { type RolesV4PagePaginationArray };