cloudflare/cloudflare-typescript
Publicmirrored from https://github.com/cloudflare/cloudflare-typescriptAvailable
src/resources/argo/tiered-caching.ts
143lines · 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 | |
| 6 | export class TieredCaching extends APIResource { |
| 7 | /** |
| 8 | * Tiered Cache works by dividing Cloudflare's data centers into a hierarchy of |
| 9 | * lower-tiers and upper-tiers. If content is not cached in lower-tier data centers |
| 10 | * (generally the ones closest to a visitor), the lower-tier must ask an upper-tier |
| 11 | * to see if it has the content. If the upper-tier does not have the content, only |
| 12 | * the upper-tier can ask the origin for content. This practice improves bandwidth |
| 13 | * efficiency by limiting the number of data centers that can ask the origin for |
| 14 | * content, which reduces origin load and makes websites more cost-effective to |
| 15 | * operate. Additionally, Tiered Cache concentrates connections to origin servers |
| 16 | * so they come from a small number of data centers rather than the full set of |
| 17 | * network locations. This results in fewer open connections using server |
| 18 | * resources. |
| 19 | * |
| 20 | * @example |
| 21 | * ```ts |
| 22 | * const response = await client.argo.tieredCaching.edit({ |
| 23 | * zone_id: '023e105f4ecef8ad9ca31a8372d0c353', |
| 24 | * value: 'on', |
| 25 | * }); |
| 26 | * ``` |
| 27 | */ |
| 28 | edit( |
| 29 | params: TieredCachingEditParams, |
| 30 | options?: Core.RequestOptions, |
| 31 | ): Core.APIPromise<TieredCachingEditResponse> { |
| 32 | const { zone_id, ...body } = params; |
| 33 | return ( |
| 34 | this._client.patch(`/zones/${zone_id}/argo/tiered_caching`, { body, ...options }) as Core.APIPromise<{ |
| 35 | result: TieredCachingEditResponse; |
| 36 | }> |
| 37 | )._thenUnwrap((obj) => obj.result); |
| 38 | } |
| 39 | |
| 40 | /** |
| 41 | * Tiered Cache works by dividing Cloudflare's data centers into a hierarchy of |
| 42 | * lower-tiers and upper-tiers. If content is not cached in lower-tier data centers |
| 43 | * (generally the ones closest to a visitor), the lower-tier must ask an upper-tier |
| 44 | * to see if it has the content. If the upper-tier does not have the content, only |
| 45 | * the upper-tier can ask the origin for content. This practice improves bandwidth |
| 46 | * efficiency by limiting the number of data centers that can ask the origin for |
| 47 | * content, which reduces origin load and makes websites more cost-effective to |
| 48 | * operate. Additionally, Tiered Cache concentrates connections to origin servers |
| 49 | * so they come from a small number of data centers rather than the full set of |
| 50 | * network locations. This results in fewer open connections using server |
| 51 | * resources. |
| 52 | * |
| 53 | * @example |
| 54 | * ```ts |
| 55 | * const tieredCaching = await client.argo.tieredCaching.get({ |
| 56 | * zone_id: '023e105f4ecef8ad9ca31a8372d0c353', |
| 57 | * }); |
| 58 | * ``` |
| 59 | */ |
| 60 | get( |
| 61 | params: TieredCachingGetParams, |
| 62 | options?: Core.RequestOptions, |
| 63 | ): Core.APIPromise<TieredCachingGetResponse> { |
| 64 | const { zone_id } = params; |
| 65 | return ( |
| 66 | this._client.get(`/zones/${zone_id}/argo/tiered_caching`, options) as Core.APIPromise<{ |
| 67 | result: TieredCachingGetResponse; |
| 68 | }> |
| 69 | )._thenUnwrap((obj) => obj.result); |
| 70 | } |
| 71 | } |
| 72 | |
| 73 | export interface TieredCachingEditResponse { |
| 74 | /** |
| 75 | * The identifier of the caching setting. |
| 76 | */ |
| 77 | id: 'tiered_caching'; |
| 78 | |
| 79 | /** |
| 80 | * Whether the setting is editable. |
| 81 | */ |
| 82 | editable: boolean; |
| 83 | |
| 84 | /** |
| 85 | * Value of the Tiered Cache zone setting. |
| 86 | */ |
| 87 | value: 'on' | 'off'; |
| 88 | |
| 89 | /** |
| 90 | * Last time this setting was modified. |
| 91 | */ |
| 92 | modified_on?: string | null; |
| 93 | } |
| 94 | |
| 95 | export interface TieredCachingGetResponse { |
| 96 | /** |
| 97 | * The identifier of the caching setting. |
| 98 | */ |
| 99 | id: 'tiered_caching'; |
| 100 | |
| 101 | /** |
| 102 | * Whether the setting is editable. |
| 103 | */ |
| 104 | editable: boolean; |
| 105 | |
| 106 | /** |
| 107 | * Value of the Tiered Cache zone setting. |
| 108 | */ |
| 109 | value: 'on' | 'off'; |
| 110 | |
| 111 | /** |
| 112 | * Last time this setting was modified. |
| 113 | */ |
| 114 | modified_on?: string | null; |
| 115 | } |
| 116 | |
| 117 | export interface TieredCachingEditParams { |
| 118 | /** |
| 119 | * Path param: Identifier. |
| 120 | */ |
| 121 | zone_id: string; |
| 122 | |
| 123 | /** |
| 124 | * Body param: Enables Tiered Caching. |
| 125 | */ |
| 126 | value: 'on' | 'off'; |
| 127 | } |
| 128 | |
| 129 | export interface TieredCachingGetParams { |
| 130 | /** |
| 131 | * Identifier. |
| 132 | */ |
| 133 | zone_id: string; |
| 134 | } |
| 135 | |
| 136 | export declare namespace TieredCaching { |
| 137 | export { |
| 138 | type TieredCachingEditResponse as TieredCachingEditResponse, |
| 139 | type TieredCachingGetResponse as TieredCachingGetResponse, |
| 140 | type TieredCachingEditParams as TieredCachingEditParams, |
| 141 | type TieredCachingGetParams as TieredCachingGetParams, |
| 142 | }; |
| 143 | } |
| 144 | |