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