cloudflare/cloudflare-typescript
Publicmirrored from https://github.com/cloudflare/cloudflare-typescriptAvailable
src/resources/accounts/roles.ts
55lines · modecode
| 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. |
| 2 | |
| 3 | import { APIResource } from '../../resource'; |
| 4 | import * as Core from '../../core'; |
| 5 | import * as Shared from '../shared'; |
| 6 | import { RolesV4PagePaginationArray } from '../shared'; |
| 7 | import { type V4PagePaginationArrayParams } from '../../pagination'; |
| 8 | |
| 9 | export class Roles extends APIResource { |
| 10 | /** |
| 11 | * Get all available roles for an account. |
| 12 | */ |
| 13 | list( |
| 14 | params: RoleListParams, |
| 15 | options?: Core.RequestOptions, |
| 16 | ): Core.PagePromise<RolesV4PagePaginationArray, Shared.Role> { |
| 17 | const { account_id, ...query } = params; |
| 18 | return this._client.getAPIList(`/accounts/${account_id}/roles`, RolesV4PagePaginationArray, { |
| 19 | query, |
| 20 | ...options, |
| 21 | }); |
| 22 | } |
| 23 | |
| 24 | /** |
| 25 | * Get information about a specific role for an account. |
| 26 | */ |
| 27 | get(roleId: string, params: RoleGetParams, options?: Core.RequestOptions): Core.APIPromise<Shared.Role> { |
| 28 | const { account_id } = params; |
| 29 | return ( |
| 30 | this._client.get(`/accounts/${account_id}/roles/${roleId}`, options) as Core.APIPromise<{ |
| 31 | result: Shared.Role; |
| 32 | }> |
| 33 | )._thenUnwrap((obj) => obj.result); |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | export interface RoleListParams extends V4PagePaginationArrayParams { |
| 38 | /** |
| 39 | * Path param: Account identifier tag. |
| 40 | */ |
| 41 | account_id: string; |
| 42 | } |
| 43 | |
| 44 | export interface RoleGetParams { |
| 45 | /** |
| 46 | * Account identifier tag. |
| 47 | */ |
| 48 | account_id: string; |
| 49 | } |
| 50 | |
| 51 | export declare namespace Roles { |
| 52 | export { type RoleListParams as RoleListParams, type RoleGetParams as RoleGetParams }; |
| 53 | } |
| 54 | |
| 55 | export { RolesV4PagePaginationArray }; |
| 56 | |