cloudflare/cloudflare-typescript
Publicmirrored fromhttps://github.com/cloudflare/cloudflare-typescriptAvailable
src/resources/access/custom-pages.ts
255lines · modecode
| 1 | // File generated from our OpenAPI spec by Stainless. |
| 2 | |
| 3 | import * as Core from 'cloudflare/core'; |
| 4 | import { APIResource } from 'cloudflare/resource'; |
| 5 | import * as CustomPagesAPI from 'cloudflare/resources/access/custom-pages'; |
| 6 | |
| 7 | export class CustomPages extends APIResource { |
| 8 | /** |
| 9 | * Create a custom page |
| 10 | */ |
| 11 | create( |
| 12 | identifier: string, |
| 13 | body: CustomPageCreateParams, |
| 14 | options?: Core.RequestOptions, |
| 15 | ): Core.APIPromise<CustomPageCreateResponse> { |
| 16 | return ( |
| 17 | this._client.post(`/accounts/${identifier}/access/custom_pages`, { |
| 18 | body, |
| 19 | ...options, |
| 20 | }) as Core.APIPromise<{ result: CustomPageCreateResponse }> |
| 21 | )._thenUnwrap((obj) => obj.result); |
| 22 | } |
| 23 | |
| 24 | /** |
| 25 | * Fetches a custom page and also returns its HTML. |
| 26 | */ |
| 27 | retrieve( |
| 28 | identifier: string, |
| 29 | uuid: string, |
| 30 | options?: Core.RequestOptions, |
| 31 | ): Core.APIPromise<CustomPageRetrieveResponse> { |
| 32 | return ( |
| 33 | this._client.get(`/accounts/${identifier}/access/custom_pages/${uuid}`, options) as Core.APIPromise<{ |
| 34 | result: CustomPageRetrieveResponse; |
| 35 | }> |
| 36 | )._thenUnwrap((obj) => obj.result); |
| 37 | } |
| 38 | |
| 39 | /** |
| 40 | * Update a custom page |
| 41 | */ |
| 42 | update( |
| 43 | identifier: string, |
| 44 | uuid: string, |
| 45 | body: CustomPageUpdateParams, |
| 46 | options?: Core.RequestOptions, |
| 47 | ): Core.APIPromise<CustomPageUpdateResponse> { |
| 48 | return ( |
| 49 | this._client.put(`/accounts/${identifier}/access/custom_pages/${uuid}`, { |
| 50 | body, |
| 51 | ...options, |
| 52 | }) as Core.APIPromise<{ result: CustomPageUpdateResponse }> |
| 53 | )._thenUnwrap((obj) => obj.result); |
| 54 | } |
| 55 | |
| 56 | /** |
| 57 | * List custom pages |
| 58 | */ |
| 59 | list(identifier: string, options?: Core.RequestOptions): Core.APIPromise<CustomPageListResponse | null> { |
| 60 | return ( |
| 61 | this._client.get(`/accounts/${identifier}/access/custom_pages`, options) as Core.APIPromise<{ |
| 62 | result: CustomPageListResponse | null; |
| 63 | }> |
| 64 | )._thenUnwrap((obj) => obj.result); |
| 65 | } |
| 66 | |
| 67 | /** |
| 68 | * Delete a custom page |
| 69 | */ |
| 70 | delete( |
| 71 | identifier: string, |
| 72 | uuid: string, |
| 73 | options?: Core.RequestOptions, |
| 74 | ): Core.APIPromise<CustomPageDeleteResponse> { |
| 75 | return ( |
| 76 | this._client.delete(`/accounts/${identifier}/access/custom_pages/${uuid}`, options) as Core.APIPromise<{ |
| 77 | result: CustomPageDeleteResponse; |
| 78 | }> |
| 79 | )._thenUnwrap((obj) => obj.result); |
| 80 | } |
| 81 | } |
| 82 | |
| 83 | export interface CustomPageCreateResponse { |
| 84 | /** |
| 85 | * Custom page name. |
| 86 | */ |
| 87 | name: string; |
| 88 | |
| 89 | /** |
| 90 | * Custom page type. |
| 91 | */ |
| 92 | type: 'identity_denied' | 'forbidden'; |
| 93 | |
| 94 | /** |
| 95 | * Number of apps the custom page is assigned to. |
| 96 | */ |
| 97 | app_count?: number; |
| 98 | |
| 99 | created_at?: string; |
| 100 | |
| 101 | /** |
| 102 | * UUID |
| 103 | */ |
| 104 | uid?: string; |
| 105 | |
| 106 | updated_at?: string; |
| 107 | } |
| 108 | |
| 109 | export interface CustomPageRetrieveResponse { |
| 110 | /** |
| 111 | * Custom page HTML. |
| 112 | */ |
| 113 | custom_html: string; |
| 114 | |
| 115 | /** |
| 116 | * Custom page name. |
| 117 | */ |
| 118 | name: string; |
| 119 | |
| 120 | /** |
| 121 | * Custom page type. |
| 122 | */ |
| 123 | type: 'identity_denied' | 'forbidden'; |
| 124 | |
| 125 | /** |
| 126 | * Number of apps the custom page is assigned to. |
| 127 | */ |
| 128 | app_count?: number; |
| 129 | |
| 130 | created_at?: string; |
| 131 | |
| 132 | /** |
| 133 | * UUID |
| 134 | */ |
| 135 | uid?: string; |
| 136 | |
| 137 | updated_at?: string; |
| 138 | } |
| 139 | |
| 140 | export interface CustomPageUpdateResponse { |
| 141 | /** |
| 142 | * Custom page name. |
| 143 | */ |
| 144 | name: string; |
| 145 | |
| 146 | /** |
| 147 | * Custom page type. |
| 148 | */ |
| 149 | type: 'identity_denied' | 'forbidden'; |
| 150 | |
| 151 | /** |
| 152 | * Number of apps the custom page is assigned to. |
| 153 | */ |
| 154 | app_count?: number; |
| 155 | |
| 156 | created_at?: string; |
| 157 | |
| 158 | /** |
| 159 | * UUID |
| 160 | */ |
| 161 | uid?: string; |
| 162 | |
| 163 | updated_at?: string; |
| 164 | } |
| 165 | |
| 166 | export type CustomPageListResponse = Array<CustomPageListResponse.CustomPageListResponseItem>; |
| 167 | |
| 168 | export namespace CustomPageListResponse { |
| 169 | export interface CustomPageListResponseItem { |
| 170 | /** |
| 171 | * Custom page name. |
| 172 | */ |
| 173 | name: string; |
| 174 | |
| 175 | /** |
| 176 | * Custom page type. |
| 177 | */ |
| 178 | type: 'identity_denied' | 'forbidden'; |
| 179 | |
| 180 | /** |
| 181 | * Number of apps the custom page is assigned to. |
| 182 | */ |
| 183 | app_count?: number; |
| 184 | |
| 185 | created_at?: string; |
| 186 | |
| 187 | /** |
| 188 | * UUID |
| 189 | */ |
| 190 | uid?: string; |
| 191 | |
| 192 | updated_at?: string; |
| 193 | } |
| 194 | } |
| 195 | |
| 196 | export interface CustomPageDeleteResponse { |
| 197 | /** |
| 198 | * UUID |
| 199 | */ |
| 200 | id?: string; |
| 201 | } |
| 202 | |
| 203 | export interface CustomPageCreateParams { |
| 204 | /** |
| 205 | * Custom page HTML. |
| 206 | */ |
| 207 | custom_html: string; |
| 208 | |
| 209 | /** |
| 210 | * Custom page name. |
| 211 | */ |
| 212 | name: string; |
| 213 | |
| 214 | /** |
| 215 | * Custom page type. |
| 216 | */ |
| 217 | type: 'identity_denied' | 'forbidden'; |
| 218 | |
| 219 | /** |
| 220 | * Number of apps the custom page is assigned to. |
| 221 | */ |
| 222 | app_count?: number; |
| 223 | } |
| 224 | |
| 225 | export interface CustomPageUpdateParams { |
| 226 | /** |
| 227 | * Custom page HTML. |
| 228 | */ |
| 229 | custom_html: string; |
| 230 | |
| 231 | /** |
| 232 | * Custom page name. |
| 233 | */ |
| 234 | name: string; |
| 235 | |
| 236 | /** |
| 237 | * Custom page type. |
| 238 | */ |
| 239 | type: 'identity_denied' | 'forbidden'; |
| 240 | |
| 241 | /** |
| 242 | * Number of apps the custom page is assigned to. |
| 243 | */ |
| 244 | app_count?: number; |
| 245 | } |
| 246 | |
| 247 | export namespace CustomPages { |
| 248 | export import CustomPageCreateResponse = CustomPagesAPI.CustomPageCreateResponse; |
| 249 | export import CustomPageRetrieveResponse = CustomPagesAPI.CustomPageRetrieveResponse; |
| 250 | export import CustomPageUpdateResponse = CustomPagesAPI.CustomPageUpdateResponse; |
| 251 | export import CustomPageListResponse = CustomPagesAPI.CustomPageListResponse; |
| 252 | export import CustomPageDeleteResponse = CustomPagesAPI.CustomPageDeleteResponse; |
| 253 | export import CustomPageCreateParams = CustomPagesAPI.CustomPageCreateParams; |
| 254 | export import CustomPageUpdateParams = CustomPagesAPI.CustomPageUpdateParams; |
| 255 | } |
| 256 | |