cloudflare/cloudflare-typescript
Publicmirrored from https://github.com/cloudflare/cloudflare-typescriptAvailable
src/resources/accounts/roles.ts
60lines · 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 RolesAPI from './roles'; |
| 6 | import * as Shared from '../shared'; |
| 7 | import { RolesSinglePage } from '../shared'; |
| 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<RolesSinglePage, Shared.Role> { |
| 17 | const { account_id } = params; |
| 18 | return this._client.getAPIList(`/accounts/${account_id}/roles`, RolesSinglePage, options); |
| 19 | } |
| 20 | |
| 21 | /** |
| 22 | * Get information about a specific role for an account. |
| 23 | */ |
| 24 | get( |
| 25 | roleId: unknown, |
| 26 | params: RoleGetParams, |
| 27 | options?: Core.RequestOptions, |
| 28 | ): Core.APIPromise<RoleGetResponse> { |
| 29 | const { account_id } = params; |
| 30 | return ( |
| 31 | this._client.get(`/accounts/${account_id}/roles/${roleId}`, options) as Core.APIPromise<{ |
| 32 | result: RoleGetResponse; |
| 33 | }> |
| 34 | )._thenUnwrap((obj) => obj.result); |
| 35 | } |
| 36 | } |
| 37 | |
| 38 | export type RoleGetResponse = unknown; |
| 39 | |
| 40 | export interface RoleListParams { |
| 41 | /** |
| 42 | * Account identifier tag. |
| 43 | */ |
| 44 | account_id: string; |
| 45 | } |
| 46 | |
| 47 | export interface RoleGetParams { |
| 48 | /** |
| 49 | * Account identifier tag. |
| 50 | */ |
| 51 | account_id: string; |
| 52 | } |
| 53 | |
| 54 | export namespace Roles { |
| 55 | export import RoleGetResponse = RolesAPI.RoleGetResponse; |
| 56 | export import RoleListParams = RolesAPI.RoleListParams; |
| 57 | export import RoleGetParams = RolesAPI.RoleGetParams; |
| 58 | } |
| 59 | |
| 60 | export { RolesSinglePage }; |
| 61 | |