|
| 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 { V4PagePaginationArray, type V4PagePaginationArrayParams } from '../../../pagination'; |
| 6 | + |
| 7 | +export class HostnameRoutes extends APIResource { |
| 8 | + /** |
| 9 | + * Create a hostname route. |
| 10 | + * |
| 11 | + * @example |
| 12 | + * ```ts |
| 13 | + * const hostnameRoute = |
| 14 | + * await client.zeroTrust.networks.hostnameRoutes.create({ |
| 15 | + * account_id: '699d98642c564d2e855e9661899b7252', |
| 16 | + * }); |
| 17 | + * ``` |
| 18 | + */ |
| 19 | + create(params: HostnameRouteCreateParams, options?: Core.RequestOptions): Core.APIPromise<HostnameRoute> { |
| 20 | + const { account_id, ...body } = params; |
| 21 | + return ( |
| 22 | + this._client.post(`/accounts/${account_id}/zerotrust/routes/hostname`, { |
| 23 | + body, |
| 24 | + ...options, |
| 25 | + }) as Core.APIPromise<{ result: HostnameRoute }> |
| 26 | + )._thenUnwrap((obj) => obj.result); |
| 27 | + } |
| 28 | + |
| 29 | + /** |
| 30 | + * Lists and filters hostname routes in an account. |
| 31 | + * |
| 32 | + * @example |
| 33 | + * ```ts |
| 34 | + * // Automatically fetches more pages as needed. |
| 35 | + * for await (const hostnameRoute of client.zeroTrust.networks.hostnameRoutes.list( |
| 36 | + * { account_id: '699d98642c564d2e855e9661899b7252' }, |
| 37 | + * )) { |
| 38 | + * // ... |
| 39 | + * } |
| 40 | + * ``` |
| 41 | + */ |
| 42 | + list( |
| 43 | + params: HostnameRouteListParams, |
| 44 | + options?: Core.RequestOptions, |
| 45 | + ): Core.PagePromise<HostnameRoutesV4PagePaginationArray, HostnameRoute> { |
| 46 | + const { account_id, ...query } = params; |
| 47 | + return this._client.getAPIList( |
| 48 | + `/accounts/${account_id}/zerotrust/routes/hostname`, |
| 49 | + HostnameRoutesV4PagePaginationArray, |
| 50 | + { query, ...options }, |
| 51 | + ); |
| 52 | + } |
| 53 | + |
| 54 | + /** |
| 55 | + * Delete a hostname route. |
| 56 | + * |
| 57 | + * @example |
| 58 | + * ```ts |
| 59 | + * const hostnameRoute = |
| 60 | + * await client.zeroTrust.networks.hostnameRoutes.delete( |
| 61 | + * 'f70ff985-a4ef-4643-bbbc-4a0ed4fc8415', |
| 62 | + * { account_id: '699d98642c564d2e855e9661899b7252' }, |
| 63 | + * ); |
| 64 | + * ``` |
| 65 | + */ |
| 66 | + delete( |
| 67 | + hostnameRouteId: string, |
| 68 | + params: HostnameRouteDeleteParams, |
| 69 | + options?: Core.RequestOptions, |
| 70 | + ): Core.APIPromise<HostnameRoute> { |
| 71 | + const { account_id } = params; |
| 72 | + return ( |
| 73 | + this._client.delete( |
| 74 | + `/accounts/${account_id}/zerotrust/routes/hostname/${hostnameRouteId}`, |
| 75 | + options, |
| 76 | + ) as Core.APIPromise<{ result: HostnameRoute }> |
| 77 | + )._thenUnwrap((obj) => obj.result); |
| 78 | + } |
| 79 | + |
| 80 | + /** |
| 81 | + * Updates a hostname route. |
| 82 | + * |
| 83 | + * @example |
| 84 | + * ```ts |
| 85 | + * const hostnameRoute = |
| 86 | + * await client.zeroTrust.networks.hostnameRoutes.edit( |
| 87 | + * 'f70ff985-a4ef-4643-bbbc-4a0ed4fc8415', |
| 88 | + * { account_id: '699d98642c564d2e855e9661899b7252' }, |
| 89 | + * ); |
| 90 | + * ``` |
| 91 | + */ |
| 92 | + edit( |
| 93 | + hostnameRouteId: string, |
| 94 | + params: HostnameRouteEditParams, |
| 95 | + options?: Core.RequestOptions, |
| 96 | + ): Core.APIPromise<HostnameRoute> { |
| 97 | + const { account_id, ...body } = params; |
| 98 | + return ( |
| 99 | + this._client.patch(`/accounts/${account_id}/zerotrust/routes/hostname/${hostnameRouteId}`, { |
| 100 | + body, |
| 101 | + ...options, |
| 102 | + }) as Core.APIPromise<{ result: HostnameRoute }> |
| 103 | + )._thenUnwrap((obj) => obj.result); |
| 104 | + } |
| 105 | + |
| 106 | + /** |
| 107 | + * Get a hostname route. |
| 108 | + * |
| 109 | + * @example |
| 110 | + * ```ts |
| 111 | + * const hostnameRoute = |
| 112 | + * await client.zeroTrust.networks.hostnameRoutes.get( |
| 113 | + * 'f70ff985-a4ef-4643-bbbc-4a0ed4fc8415', |
| 114 | + * { account_id: '699d98642c564d2e855e9661899b7252' }, |
| 115 | + * ); |
| 116 | + * ``` |
| 117 | + */ |
| 118 | + get( |
| 119 | + hostnameRouteId: string, |
| 120 | + params: HostnameRouteGetParams, |
| 121 | + options?: Core.RequestOptions, |
| 122 | + ): Core.APIPromise<HostnameRoute> { |
| 123 | + const { account_id } = params; |
| 124 | + return ( |
| 125 | + this._client.get( |
| 126 | + `/accounts/${account_id}/zerotrust/routes/hostname/${hostnameRouteId}`, |
| 127 | + options, |
| 128 | + ) as Core.APIPromise<{ result: HostnameRoute }> |
| 129 | + )._thenUnwrap((obj) => obj.result); |
| 130 | + } |
| 131 | +} |
| 132 | + |
| 133 | +export class HostnameRoutesV4PagePaginationArray extends V4PagePaginationArray<HostnameRoute> {} |
| 134 | + |
| 135 | +export interface HostnameRoute { |
| 136 | + /** |
| 137 | + * The hostname route ID. |
| 138 | + */ |
| 139 | + id?: string; |
| 140 | + |
| 141 | + /** |
| 142 | + * An optional description of the hostname route. |
| 143 | + */ |
| 144 | + comment?: string; |
| 145 | + |
| 146 | + /** |
| 147 | + * Timestamp of when the resource was created. |
| 148 | + */ |
| 149 | + created_at?: string; |
| 150 | + |
| 151 | + /** |
| 152 | + * Timestamp of when the resource was deleted. If `null`, the resource has not been |
| 153 | + * deleted. |
| 154 | + */ |
| 155 | + deleted_at?: string; |
| 156 | + |
| 157 | + /** |
| 158 | + * The hostname of the route. |
| 159 | + */ |
| 160 | + hostname?: string; |
| 161 | + |
| 162 | + /** |
| 163 | + * UUID of the tunnel. |
| 164 | + */ |
| 165 | + tunnel_id?: string; |
| 166 | + |
| 167 | + /** |
| 168 | + * A user-friendly name for a tunnel. |
| 169 | + */ |
| 170 | + tunnel_name?: string; |
| 171 | +} |
| 172 | + |
| 173 | +export interface HostnameRouteCreateParams { |
| 174 | + /** |
| 175 | + * Path param: Cloudflare account ID |
| 176 | + */ |
| 177 | + account_id: string; |
| 178 | + |
| 179 | + /** |
| 180 | + * Body param: An optional description of the hostname route. |
| 181 | + */ |
| 182 | + comment?: string; |
| 183 | + |
| 184 | + /** |
| 185 | + * Body param: The hostname of the route. |
| 186 | + */ |
| 187 | + hostname?: string; |
| 188 | + |
| 189 | + /** |
| 190 | + * Body param: UUID of the tunnel. |
| 191 | + */ |
| 192 | + tunnel_id?: string; |
| 193 | +} |
| 194 | + |
| 195 | +export interface HostnameRouteListParams extends V4PagePaginationArrayParams { |
| 196 | + /** |
| 197 | + * Path param: Cloudflare account ID |
| 198 | + */ |
| 199 | + account_id: string; |
| 200 | + |
| 201 | + /** |
| 202 | + * Query param: The hostname route ID. |
| 203 | + */ |
| 204 | + id?: string; |
| 205 | + |
| 206 | + /** |
| 207 | + * Query param: If set, only list hostname routes with the given comment. |
| 208 | + */ |
| 209 | + comment?: string; |
| 210 | + |
| 211 | + /** |
| 212 | + * Query param: If provided, include only resources that were created (and not |
| 213 | + * deleted) before this time. URL encoded. |
| 214 | + */ |
| 215 | + existed_at?: string; |
| 216 | + |
| 217 | + /** |
| 218 | + * Query param: If set, only list hostname routes that contain a substring of the |
| 219 | + * given value, the filter is case-insensitive. |
| 220 | + */ |
| 221 | + hostname?: string; |
| 222 | + |
| 223 | + /** |
| 224 | + * Query param: If `true`, only return deleted hostname routes. If `false`, exclude |
| 225 | + * deleted hostname routes. |
| 226 | + */ |
| 227 | + is_deleted?: boolean; |
| 228 | + |
| 229 | + /** |
| 230 | + * Query param: If set, only list hostname routes that point to a specific tunnel. |
| 231 | + */ |
| 232 | + tunnel_id?: string; |
| 233 | +} |
| 234 | + |
| 235 | +export interface HostnameRouteDeleteParams { |
| 236 | + /** |
| 237 | + * Cloudflare account ID |
| 238 | + */ |
| 239 | + account_id: string; |
| 240 | +} |
| 241 | + |
| 242 | +export interface HostnameRouteEditParams { |
| 243 | + /** |
| 244 | + * Path param: Cloudflare account ID |
| 245 | + */ |
| 246 | + account_id: string; |
| 247 | + |
| 248 | + /** |
| 249 | + * Body param: An optional description of the hostname route. |
| 250 | + */ |
| 251 | + comment?: string; |
| 252 | + |
| 253 | + /** |
| 254 | + * Body param: The hostname of the route. |
| 255 | + */ |
| 256 | + hostname?: string; |
| 257 | + |
| 258 | + /** |
| 259 | + * Body param: UUID of the tunnel. |
| 260 | + */ |
| 261 | + tunnel_id?: string; |
| 262 | +} |
| 263 | + |
| 264 | +export interface HostnameRouteGetParams { |
| 265 | + /** |
| 266 | + * Cloudflare account ID |
| 267 | + */ |
| 268 | + account_id: string; |
| 269 | +} |
| 270 | + |
| 271 | +HostnameRoutes.HostnameRoutesV4PagePaginationArray = HostnameRoutesV4PagePaginationArray; |
| 272 | + |
| 273 | +export declare namespace HostnameRoutes { |
| 274 | + export { |
| 275 | + type HostnameRoute as HostnameRoute, |
| 276 | + HostnameRoutesV4PagePaginationArray as HostnameRoutesV4PagePaginationArray, |
| 277 | + type HostnameRouteCreateParams as HostnameRouteCreateParams, |
| 278 | + type HostnameRouteListParams as HostnameRouteListParams, |
| 279 | + type HostnameRouteDeleteParams as HostnameRouteDeleteParams, |
| 280 | + type HostnameRouteEditParams as HostnameRouteEditParams, |
| 281 | + type HostnameRouteGetParams as HostnameRouteGetParams, |
| 282 | + }; |
| 283 | +} |
0 commit comments