cloudflare/cloudflare-typescript
Publicmirrored from https://github.com/cloudflare/cloudflare-typescriptAvailable
src/resources/accounts/roles.ts
74lines · modecode
| 1 | // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. |
| 2 | |
| 3 | import * as Core from 'cloudflare/core'; |
| 4 | import { APIResource } from 'cloudflare/resource'; |
| 5 | import * as RolesAPI from 'cloudflare/resources/accounts/roles'; |
| 6 | import { SinglePage } from 'cloudflare/pagination'; |
| 7 | |
| 8 | export class Roles extends APIResource { |
| 9 | /** |
| 10 | * Get all available roles for an account. |
| 11 | */ |
| 12 | list(params: RoleListParams, options?: Core.RequestOptions): Core.PagePromise<RolesSinglePage, Role> { |
| 13 | const { account_id } = params; |
| 14 | return this._client.getAPIList(`/accounts/${account_id}/roles`, RolesSinglePage, options); |
| 15 | } |
| 16 | |
| 17 | /** |
| 18 | * Get information about a specific role for an account. |
| 19 | */ |
| 20 | get( |
| 21 | roleId: unknown, |
| 22 | params: RoleGetParams, |
| 23 | options?: Core.RequestOptions, |
| 24 | ): Core.APIPromise<RoleGetResponse> { |
| 25 | const { account_id } = params; |
| 26 | return ( |
| 27 | this._client.get(`/accounts/${account_id}/roles/${roleId}`, options) as Core.APIPromise<{ |
| 28 | result: RoleGetResponse; |
| 29 | }> |
| 30 | )._thenUnwrap((obj) => obj.result); |
| 31 | } |
| 32 | } |
| 33 | |
| 34 | export class RolesSinglePage extends SinglePage<Role> {} |
| 35 | |
| 36 | export interface Role { |
| 37 | /** |
| 38 | * Role identifier tag. |
| 39 | */ |
| 40 | id: string; |
| 41 | |
| 42 | /** |
| 43 | * Description of role's permissions. |
| 44 | */ |
| 45 | description: string; |
| 46 | |
| 47 | /** |
| 48 | * Role Name. |
| 49 | */ |
| 50 | name: string; |
| 51 | |
| 52 | /** |
| 53 | * Access permissions for this User. |
| 54 | */ |
| 55 | permissions: Array<string>; |
| 56 | } |
| 57 | |
| 58 | export type RoleGetResponse = unknown | string | null; |
| 59 | |
| 60 | export interface RoleListParams { |
| 61 | account_id: unknown; |
| 62 | } |
| 63 | |
| 64 | export interface RoleGetParams { |
| 65 | account_id: unknown; |
| 66 | } |
| 67 | |
| 68 | export namespace Roles { |
| 69 | export import Role = RolesAPI.Role; |
| 70 | export import RoleGetResponse = RolesAPI.RoleGetResponse; |
| 71 | export import RolesSinglePage = RolesAPI.RolesSinglePage; |
| 72 | export import RoleListParams = RolesAPI.RoleListParams; |
| 73 | export import RoleGetParams = RolesAPI.RoleGetParams; |
| 74 | } |
| 75 | |