From a24a64d25ec71027b6534d50d64ec611b7212f30 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 15 Nov 2024 09:49:17 +0000 Subject: [PATCH] feat(api): api update (#2137) --- .stats.yml | 4 +- api.md | 79 --- src/resources/filters.ts | 192 +----- src/resources/firewall/access-rules.ts | 469 +------------- src/resources/firewall/firewall.ts | 84 +-- src/resources/firewall/index.ts | 44 +- src/resources/firewall/lockdowns.ts | 245 +------ src/resources/firewall/rules.ts | 331 +--------- src/resources/firewall/ua-rules.ts | 241 +------ src/resources/firewall/waf/index.ts | 24 +- src/resources/firewall/waf/overrides.ts | 226 +------ src/resources/firewall/waf/packages/index.ts | 9 +- .../firewall/waf/packages/packages.ts | 105 --- src/resources/firewall/waf/waf.ts | 42 +- src/resources/rate-limits.ts | 601 +----------------- tests/api-resources/filters.test.ts | 122 ---- .../firewall/access-rules.test.ts | 54 -- .../api-resources/firewall/lockdowns.test.ts | 136 ---- tests/api-resources/firewall/rules.test.ts | 165 ----- tests/api-resources/firewall/ua-rules.test.ts | 122 ---- .../firewall/waf/overrides.test.ts | 129 ---- .../firewall/waf/packages/packages.test.ts | 58 -- tests/api-resources/rate-limits.test.ts | 151 ----- 23 files changed, 23 insertions(+), 3610 deletions(-) delete mode 100644 tests/api-resources/filters.test.ts delete mode 100644 tests/api-resources/firewall/lockdowns.test.ts delete mode 100644 tests/api-resources/firewall/rules.test.ts delete mode 100644 tests/api-resources/firewall/ua-rules.test.ts delete mode 100644 tests/api-resources/firewall/waf/overrides.test.ts delete mode 100644 tests/api-resources/firewall/waf/packages/packages.test.ts delete mode 100644 tests/api-resources/rate-limits.test.ts diff --git a/.stats.yml b/.stats.yml index 1ad5f850f7..3eace84bc2 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1,2 +1,2 @@ -configured_endpoints: 1417 -openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-2d63750bcbd8172347f67b96d9f915bb7a400716f6e6d2088e6c00bef8b1e0a8.yml +configured_endpoints: 1381 +openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-34e58184c8582fbfa6e469d190a541a701067980fa9d9158ed1ffc1eed88d681.yml diff --git a/api.md b/api.md index e8bffc51fa..f0edc64598 100644 --- a/api.md +++ b/api.md @@ -1223,15 +1223,6 @@ Methods: Types: - FirewallFilter -- FilterCreateResponse - -Methods: - -- client.filters.create({ ...params }) -> FilterCreateResponse | null -- client.filters.update(filterId, { ...params }) -> FirewallFilter -- client.filters.list({ ...params }) -> FirewallFiltersV4PagePaginationArray -- client.filters.delete(filterId, { ...params }) -> FirewallFilter -- client.filters.get(filterId, { ...params }) -> FirewallFilter # Firewall @@ -1244,15 +1235,6 @@ Types: - LockdownCIDRConfiguration - LockdownIPConfiguration - LockdownURL -- LockdownDeleteResponse - -Methods: - -- client.firewall.lockdowns.create({ ...params }) -> Lockdown -- client.firewall.lockdowns.update(lockDownsId, { ...params }) -> Lockdown -- client.firewall.lockdowns.list({ ...params }) -> LockdownsV4PagePaginationArray -- client.firewall.lockdowns.delete(lockDownsId, { ...params }) -> LockdownDeleteResponse -- client.firewall.lockdowns.get(lockDownsId, { ...params }) -> Lockdown ## Rules @@ -1261,17 +1243,6 @@ Types: - FirewallRule - Product - DeletedFilter -- RuleCreateResponse -- RuleEditResponse - -Methods: - -- client.firewall.rules.create({ ...params }) -> RuleCreateResponse | null -- client.firewall.rules.update(ruleId, { ...params }) -> FirewallRule -- client.firewall.rules.list({ ...params }) -> FirewallRulesV4PagePaginationArray -- client.firewall.rules.delete(ruleId, { ...params }) -> FirewallRule -- client.firewall.rules.edit(ruleId, { ...params }) -> RuleEditResponse | null -- client.firewall.rules.get(ruleId, { ...params }) -> FirewallRule ## AccessRules @@ -1284,36 +1255,14 @@ Types: - IPV6Configuration - AccessRuleCreateResponse - AccessRuleListResponse -- AccessRuleDeleteResponse -- AccessRuleEditResponse -- AccessRuleGetResponse Methods: - client.firewall.accessRules.create({ ...params }) -> AccessRuleCreateResponse - client.firewall.accessRules.list({ ...params }) -> AccessRuleListResponsesV4PagePaginationArray -- client.firewall.accessRules.delete(ruleId, { ...params }) -> AccessRuleDeleteResponse | null -- client.firewall.accessRules.edit(ruleId, { ...params }) -> AccessRuleEditResponse -- client.firewall.accessRules.get(ruleId, { ...params }) -> AccessRuleGetResponse ## UARules -Types: - -- UARuleCreateResponse -- UARuleUpdateResponse -- UARuleListResponse -- UARuleDeleteResponse -- UARuleGetResponse - -Methods: - -- client.firewall.uaRules.create({ ...params }) -> UARuleCreateResponse -- client.firewall.uaRules.update(uaRuleId, { ...params }) -> UARuleUpdateResponse -- client.firewall.uaRules.list({ ...params }) -> UARuleListResponsesV4PagePaginationArray -- client.firewall.uaRules.delete(uaRuleId, { ...params }) -> UARuleDeleteResponse -- client.firewall.uaRules.get(uaRuleId, { ...params }) -> UARuleGetResponse - ## WAF ### Overrides @@ -1324,28 +1273,9 @@ Types: - OverrideURL - RewriteAction - WAFRule -- OverrideDeleteResponse - -Methods: - -- client.firewall.waf.overrides.create({ ...params }) -> Override -- client.firewall.waf.overrides.update(overridesId, { ...params }) -> Override -- client.firewall.waf.overrides.list({ ...params }) -> OverridesV4PagePaginationArray -- client.firewall.waf.overrides.delete(overridesId, { ...params }) -> OverrideDeleteResponse -- client.firewall.waf.overrides.get(overridesId, { ...params }) -> Override ### Packages -Types: - -- PackageListResponse -- PackageGetResponse - -Methods: - -- client.firewall.waf.packages.list({ ...params }) -> PackageListResponsesV4PagePaginationArray -- client.firewall.waf.packages.get(packageId, { ...params }) -> PackageGetResponse - #### Groups Types: @@ -1654,15 +1584,6 @@ Types: - Action - Methods - RateLimit -- RateLimitDeleteResponse - -Methods: - -- client.rateLimits.create({ ...params }) -> RateLimit -- client.rateLimits.list({ ...params }) -> RateLimitsV4PagePaginationArray -- client.rateLimits.delete(rateLimitId, { ...params }) -> RateLimitDeleteResponse -- client.rateLimits.edit(rateLimitId, { ...params }) -> RateLimit -- client.rateLimits.get(rateLimitId, { ...params }) -> RateLimit # SecondaryDNS diff --git a/src/resources/filters.ts b/src/resources/filters.ts index e3c48cb821..3189252bf6 100644 --- a/src/resources/filters.ts +++ b/src/resources/filters.ts @@ -1,101 +1,8 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../resource'; -import * as Core from '../core'; -import { V4PagePaginationArray, type V4PagePaginationArrayParams } from '../pagination'; -export class Filters extends APIResource { - /** - * Creates one or more filters. - * - * @deprecated The Filters API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details. - */ - create( - params: FilterCreateParams, - options?: Core.RequestOptions, - ): Core.APIPromise { - const { zone_id, ...body } = params; - return ( - this._client.post(`/zones/${zone_id}/filters`, { body, ...options }) as Core.APIPromise<{ - result: FilterCreateResponse | null; - }> - )._thenUnwrap((obj) => obj.result); - } - - /** - * Updates an existing filter. - * - * @deprecated The Filters API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details. - */ - update( - filterId: string, - params: FilterUpdateParams, - options?: Core.RequestOptions, - ): Core.APIPromise { - const { zone_id, body } = params; - return ( - this._client.put(`/zones/${zone_id}/filters/${filterId}`, { - body: body, - ...options, - }) as Core.APIPromise<{ result: FirewallFilter }> - )._thenUnwrap((obj) => obj.result); - } - - /** - * Fetches filters in a zone. You can filter the results using several optional - * parameters. - * - * @deprecated The Filters API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details. - */ - list( - params: FilterListParams, - options?: Core.RequestOptions, - ): Core.PagePromise { - const { zone_id, ...query } = params; - return this._client.getAPIList(`/zones/${zone_id}/filters`, FirewallFiltersV4PagePaginationArray, { - query, - ...options, - }); - } - - /** - * Deletes an existing filter. - * - * @deprecated The Filters API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details. - */ - delete( - filterId: string, - params: FilterDeleteParams, - options?: Core.RequestOptions, - ): Core.APIPromise { - const { zone_id } = params; - return ( - this._client.delete(`/zones/${zone_id}/filters/${filterId}`, options) as Core.APIPromise<{ - result: FirewallFilter; - }> - )._thenUnwrap((obj) => obj.result); - } - - /** - * Fetches the details of a filter. - * - * @deprecated The Filters API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details. - */ - get( - filterId: string, - params: FilterGetParams, - options?: Core.RequestOptions, - ): Core.APIPromise { - const { zone_id } = params; - return ( - this._client.get(`/zones/${zone_id}/filters/${filterId}`, options) as Core.APIPromise<{ - result: FirewallFilter; - }> - )._thenUnwrap((obj) => obj.result); - } -} - -export class FirewallFiltersV4PagePaginationArray extends V4PagePaginationArray {} +export class Filters extends APIResource {} export interface FirewallFilter { /** @@ -124,100 +31,3 @@ export interface FirewallFilter { */ ref?: string; } - -export interface FirewallFilterParam { - /** - * An informative summary of the filter. - */ - description?: string; - - /** - * The filter expression. For more information, refer to - * [Expressions](https://developers.cloudflare.com/ruleset-engine/rules-language/expressions/). - */ - expression?: string; - - /** - * When true, indicates that the filter is currently paused. - */ - paused?: boolean; - - /** - * A short reference tag. Allows you to select related filters. - */ - ref?: string; -} - -export type FilterCreateResponse = Array; - -export interface FilterCreateParams { - /** - * Path param: Identifier - */ - zone_id: string; - - /** - * Body param: The filter expression. For more information, refer to - * [Expressions](https://developers.cloudflare.com/ruleset-engine/rules-language/expressions/). - */ - expression: string; -} - -export interface FilterUpdateParams { - /** - * Path param: Identifier - */ - zone_id: string; - - /** - * Body param: - */ - body: unknown; -} - -export interface FilterListParams extends V4PagePaginationArrayParams { - /** - * Path param: Identifier - */ - zone_id: string; - - /** - * Query param: The unique identifier of the filter. - */ - id?: string; - - /** - * Query param: A case-insensitive string to find in the description. - */ - description?: string; - - /** - * Query param: A case-insensitive string to find in the expression. - */ - expression?: string; - - /** - * Query param: When true, indicates that the filter is currently paused. - */ - paused?: boolean; - - /** - * Query param: The filter ref (a short reference tag) to search for. Must be an - * exact match. - */ - ref?: string; -} - -export interface FilterDeleteParams { - /** - * Identifier - */ - zone_id: string; -} - -export interface FilterGetParams { - /** - * Identifier - */ - zone_id: string; -} diff --git a/src/resources/firewall/access-rules.ts b/src/resources/firewall/access-rules.ts index edc662dd9c..d289eac678 100644 --- a/src/resources/firewall/access-rules.ts +++ b/src/resources/firewall/access-rules.ts @@ -85,127 +85,6 @@ export class AccessRules extends APIResource { { query, ...options }, ); } - - /** - * Deletes an existing IP Access rule defined. - * - * Note: This operation will affect all zones in the account or zone. - */ - delete( - ruleId: string, - params?: AccessRuleDeleteParams, - options?: Core.RequestOptions, - ): Core.APIPromise; - delete(ruleId: string, options?: Core.RequestOptions): Core.APIPromise; - delete( - ruleId: string, - params: AccessRuleDeleteParams | Core.RequestOptions = {}, - options?: Core.RequestOptions, - ): Core.APIPromise { - if (isRequestOptions(params)) { - return this.delete(ruleId, {}, params); - } - const { account_id, zone_id } = params; - if (!account_id && !zone_id) { - throw new CloudflareError('You must provide either account_id or zone_id.'); - } - if (account_id && zone_id) { - throw new CloudflareError('You cannot provide both account_id and zone_id.'); - } - const { accountOrZone, accountOrZoneId } = - account_id ? - { - accountOrZone: 'accounts', - accountOrZoneId: account_id, - } - : { - accountOrZone: 'zones', - accountOrZoneId: zone_id, - }; - return ( - this._client.delete( - `/${accountOrZone}/${accountOrZoneId}/firewall/access_rules/rules/${ruleId}`, - options, - ) as Core.APIPromise<{ result: AccessRuleDeleteResponse | null }> - )._thenUnwrap((obj) => obj.result); - } - - /** - * Updates an IP Access rule defined. - * - * Note: This operation will affect all zones in the account or zone. - */ - edit( - ruleId: string, - params: AccessRuleEditParams, - options?: Core.RequestOptions, - ): Core.APIPromise { - const { account_id, zone_id, ...body } = params; - if (!account_id && !zone_id) { - throw new CloudflareError('You must provide either account_id or zone_id.'); - } - if (account_id && zone_id) { - throw new CloudflareError('You cannot provide both account_id and zone_id.'); - } - const { accountOrZone, accountOrZoneId } = - account_id ? - { - accountOrZone: 'accounts', - accountOrZoneId: account_id, - } - : { - accountOrZone: 'zones', - accountOrZoneId: zone_id, - }; - return ( - this._client.patch(`/${accountOrZone}/${accountOrZoneId}/firewall/access_rules/rules/${ruleId}`, { - body, - ...options, - }) as Core.APIPromise<{ result: AccessRuleEditResponse }> - )._thenUnwrap((obj) => obj.result); - } - - /** - * Fetches the details of an IP Access rule defined. - */ - get( - ruleId: string, - params?: AccessRuleGetParams, - options?: Core.RequestOptions, - ): Core.APIPromise; - get(ruleId: string, options?: Core.RequestOptions): Core.APIPromise; - get( - ruleId: string, - params: AccessRuleGetParams | Core.RequestOptions = {}, - options?: Core.RequestOptions, - ): Core.APIPromise { - if (isRequestOptions(params)) { - return this.get(ruleId, {}, params); - } - const { account_id, zone_id } = params; - if (!account_id && !zone_id) { - throw new CloudflareError('You must provide either account_id or zone_id.'); - } - if (account_id && zone_id) { - throw new CloudflareError('You cannot provide both account_id and zone_id.'); - } - const { accountOrZone, accountOrZoneId } = - account_id ? - { - accountOrZone: 'accounts', - accountOrZoneId: account_id, - } - : { - accountOrZone: 'zones', - accountOrZoneId: zone_id, - }; - return ( - this._client.get( - `/${accountOrZone}/${accountOrZoneId}/firewall/access_rules/rules/${ruleId}`, - options, - ) as Core.APIPromise<{ result: AccessRuleGetResponse }> - )._thenUnwrap((obj) => obj.result); - } } export class AccessRuleListResponsesV4PagePaginationArray extends V4PagePaginationArray {} @@ -346,288 +225,9 @@ export interface IPV6ConfigurationParam { value?: string; } -export interface AccessRuleCreateResponse { - /** - * The unique identifier of the IP Access rule. - */ - id: string; - - /** - * The available actions that a rule can apply to a matched request. - */ - allowed_modes: Array<'block' | 'challenge' | 'whitelist' | 'js_challenge' | 'managed_challenge'>; - - /** - * The rule configuration. - */ - configuration: - | AccessRuleIPConfiguration - | IPV6Configuration - | AccessRuleCIDRConfiguration - | ASNConfiguration - | CountryConfiguration; - - /** - * The action to apply to a matched request. - */ - mode: 'block' | 'challenge' | 'whitelist' | 'js_challenge' | 'managed_challenge'; - - /** - * The timestamp of when the rule was created. - */ - created_on?: string; - - /** - * The timestamp of when the rule was last modified. - */ - modified_on?: string; - - /** - * An informative summary of the rule, typically used as a reminder or explanation. - */ - notes?: string; - - /** - * All zones owned by the user will have the rule applied. - */ - scope?: AccessRuleCreateResponse.Scope; -} - -export namespace AccessRuleCreateResponse { - /** - * All zones owned by the user will have the rule applied. - */ - export interface Scope { - /** - * Identifier - */ - id?: string; - - /** - * The contact email address of the user. - */ - email?: string; - - /** - * The scope of the rule. - */ - type?: 'user' | 'organization'; - } -} - -export interface AccessRuleListResponse { - /** - * The unique identifier of the IP Access rule. - */ - id: string; - - /** - * The available actions that a rule can apply to a matched request. - */ - allowed_modes: Array<'block' | 'challenge' | 'whitelist' | 'js_challenge' | 'managed_challenge'>; - - /** - * The rule configuration. - */ - configuration: - | AccessRuleIPConfiguration - | IPV6Configuration - | AccessRuleCIDRConfiguration - | ASNConfiguration - | CountryConfiguration; - - /** - * The action to apply to a matched request. - */ - mode: 'block' | 'challenge' | 'whitelist' | 'js_challenge' | 'managed_challenge'; - - /** - * The timestamp of when the rule was created. - */ - created_on?: string; - - /** - * The timestamp of when the rule was last modified. - */ - modified_on?: string; - - /** - * An informative summary of the rule, typically used as a reminder or explanation. - */ - notes?: string; - - /** - * All zones owned by the user will have the rule applied. - */ - scope?: AccessRuleListResponse.Scope; -} - -export namespace AccessRuleListResponse { - /** - * All zones owned by the user will have the rule applied. - */ - export interface Scope { - /** - * Identifier - */ - id?: string; - - /** - * The contact email address of the user. - */ - email?: string; - - /** - * The scope of the rule. - */ - type?: 'user' | 'organization'; - } -} - -export interface AccessRuleDeleteResponse { - /** - * Identifier - */ - id: string; -} - -export interface AccessRuleEditResponse { - /** - * The unique identifier of the IP Access rule. - */ - id: string; +export type AccessRuleCreateResponse = unknown | string | null; - /** - * The available actions that a rule can apply to a matched request. - */ - allowed_modes: Array<'block' | 'challenge' | 'whitelist' | 'js_challenge' | 'managed_challenge'>; - - /** - * The rule configuration. - */ - configuration: - | AccessRuleIPConfiguration - | IPV6Configuration - | AccessRuleCIDRConfiguration - | ASNConfiguration - | CountryConfiguration; - - /** - * The action to apply to a matched request. - */ - mode: 'block' | 'challenge' | 'whitelist' | 'js_challenge' | 'managed_challenge'; - - /** - * The timestamp of when the rule was created. - */ - created_on?: string; - - /** - * The timestamp of when the rule was last modified. - */ - modified_on?: string; - - /** - * An informative summary of the rule, typically used as a reminder or explanation. - */ - notes?: string; - - /** - * All zones owned by the user will have the rule applied. - */ - scope?: AccessRuleEditResponse.Scope; -} - -export namespace AccessRuleEditResponse { - /** - * All zones owned by the user will have the rule applied. - */ - export interface Scope { - /** - * Identifier - */ - id?: string; - - /** - * The contact email address of the user. - */ - email?: string; - - /** - * The scope of the rule. - */ - type?: 'user' | 'organization'; - } -} - -export interface AccessRuleGetResponse { - /** - * The unique identifier of the IP Access rule. - */ - id: string; - - /** - * The available actions that a rule can apply to a matched request. - */ - allowed_modes: Array<'block' | 'challenge' | 'whitelist' | 'js_challenge' | 'managed_challenge'>; - - /** - * The rule configuration. - */ - configuration: - | AccessRuleIPConfiguration - | IPV6Configuration - | AccessRuleCIDRConfiguration - | ASNConfiguration - | CountryConfiguration; - - /** - * The action to apply to a matched request. - */ - mode: 'block' | 'challenge' | 'whitelist' | 'js_challenge' | 'managed_challenge'; - - /** - * The timestamp of when the rule was created. - */ - created_on?: string; - - /** - * The timestamp of when the rule was last modified. - */ - modified_on?: string; - - /** - * An informative summary of the rule, typically used as a reminder or explanation. - */ - notes?: string; - - /** - * All zones owned by the user will have the rule applied. - */ - scope?: AccessRuleGetResponse.Scope; -} - -export namespace AccessRuleGetResponse { - /** - * All zones owned by the user will have the rule applied. - */ - export interface Scope { - /** - * Identifier - */ - id?: string; - - /** - * The contact email address of the user. - */ - email?: string; - - /** - * The scope of the rule. - */ - type?: 'user' | 'organization'; - } -} +export type AccessRuleListResponse = unknown; export interface AccessRuleCreateParams { /** @@ -728,65 +328,6 @@ export namespace AccessRuleListParams { } } -export interface AccessRuleDeleteParams { - /** - * The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - */ - account_id?: string; - - /** - * The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - */ - zone_id?: string; -} - -export interface AccessRuleEditParams { - /** - * Body param: The rule configuration. - */ - configuration: - | AccessRuleIPConfigurationParam - | IPV6ConfigurationParam - | AccessRuleCIDRConfigurationParam - | ASNConfigurationParam - | CountryConfigurationParam; - - /** - * Body param: The action to apply to a matched request. - */ - mode: 'block' | 'challenge' | 'whitelist' | 'js_challenge' | 'managed_challenge'; - - /** - * Path param: The Account ID to use for this endpoint. Mutually exclusive with the - * Zone ID. - */ - account_id?: string; - - /** - * Path param: The Zone ID to use for this endpoint. Mutually exclusive with the - * Account ID. - */ - zone_id?: string; - - /** - * Body param: An informative summary of the rule, typically used as a reminder or - * explanation. - */ - notes?: string; -} - -export interface AccessRuleGetParams { - /** - * The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. - */ - account_id?: string; - - /** - * The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. - */ - zone_id?: string; -} - AccessRules.AccessRuleListResponsesV4PagePaginationArray = AccessRuleListResponsesV4PagePaginationArray; export declare namespace AccessRules { @@ -798,14 +339,8 @@ export declare namespace AccessRules { type IPV6Configuration as IPV6Configuration, type AccessRuleCreateResponse as AccessRuleCreateResponse, type AccessRuleListResponse as AccessRuleListResponse, - type AccessRuleDeleteResponse as AccessRuleDeleteResponse, - type AccessRuleEditResponse as AccessRuleEditResponse, - type AccessRuleGetResponse as AccessRuleGetResponse, AccessRuleListResponsesV4PagePaginationArray as AccessRuleListResponsesV4PagePaginationArray, type AccessRuleCreateParams as AccessRuleCreateParams, type AccessRuleListParams as AccessRuleListParams, - type AccessRuleDeleteParams as AccessRuleDeleteParams, - type AccessRuleEditParams as AccessRuleEditParams, - type AccessRuleGetParams as AccessRuleGetParams, }; } diff --git a/src/resources/firewall/firewall.ts b/src/resources/firewall/firewall.ts index 657c011a1a..1b40cf7238 100644 --- a/src/resources/firewall/firewall.ts +++ b/src/resources/firewall/firewall.ts @@ -7,12 +7,6 @@ import { AccessRuleCIDRConfiguration, AccessRuleCreateParams, AccessRuleCreateResponse, - AccessRuleDeleteParams, - AccessRuleDeleteResponse, - AccessRuleEditParams, - AccessRuleEditResponse, - AccessRuleGetParams, - AccessRuleGetResponse, AccessRuleIPConfiguration, AccessRuleListParams, AccessRuleListResponse, @@ -26,48 +20,14 @@ import { Configuration, Lockdown, LockdownCIDRConfiguration, - LockdownCreateParams, - LockdownDeleteParams, - LockdownDeleteResponse, - LockdownGetParams, LockdownIPConfiguration, - LockdownListParams, LockdownURL, - LockdownUpdateParams, Lockdowns, - LockdownsV4PagePaginationArray, } from './lockdowns'; import * as RulesAPI from './rules'; -import { - DeletedFilter, - FirewallRule, - FirewallRulesV4PagePaginationArray, - Product, - RuleCreateParams, - RuleCreateResponse, - RuleDeleteParams, - RuleEditParams, - RuleEditResponse, - RuleGetParams, - RuleListParams, - RuleUpdateParams, - Rules, -} from './rules'; +import { DeletedFilter, FirewallRule, Product, Rules } from './rules'; import * as UARulesAPI from './ua-rules'; -import { - UARuleCreateParams, - UARuleCreateResponse, - UARuleDeleteParams, - UARuleDeleteResponse, - UARuleGetParams, - UARuleGetResponse, - UARuleListParams, - UARuleListResponse, - UARuleListResponsesV4PagePaginationArray, - UARuleUpdateParams, - UARuleUpdateResponse, - UARules, -} from './ua-rules'; +import { UARules } from './ua-rules'; import * as WAFAPI from './waf/waf'; import { WAF } from './waf/waf'; @@ -80,13 +40,10 @@ export class Firewall extends APIResource { } Firewall.Lockdowns = Lockdowns; -Firewall.LockdownsV4PagePaginationArray = LockdownsV4PagePaginationArray; Firewall.Rules = Rules; -Firewall.FirewallRulesV4PagePaginationArray = FirewallRulesV4PagePaginationArray; Firewall.AccessRules = AccessRules; Firewall.AccessRuleListResponsesV4PagePaginationArray = AccessRuleListResponsesV4PagePaginationArray; Firewall.UARules = UARules; -Firewall.UARuleListResponsesV4PagePaginationArray = UARuleListResponsesV4PagePaginationArray; Firewall.WAF = WAF; export declare namespace Firewall { @@ -97,13 +54,6 @@ export declare namespace Firewall { type LockdownCIDRConfiguration as LockdownCIDRConfiguration, type LockdownIPConfiguration as LockdownIPConfiguration, type LockdownURL as LockdownURL, - type LockdownDeleteResponse as LockdownDeleteResponse, - LockdownsV4PagePaginationArray as LockdownsV4PagePaginationArray, - type LockdownCreateParams as LockdownCreateParams, - type LockdownUpdateParams as LockdownUpdateParams, - type LockdownListParams as LockdownListParams, - type LockdownDeleteParams as LockdownDeleteParams, - type LockdownGetParams as LockdownGetParams, }; export { @@ -111,15 +61,6 @@ export declare namespace Firewall { type FirewallRule as FirewallRule, type Product as Product, type DeletedFilter as DeletedFilter, - type RuleCreateResponse as RuleCreateResponse, - type RuleEditResponse as RuleEditResponse, - FirewallRulesV4PagePaginationArray as FirewallRulesV4PagePaginationArray, - type RuleCreateParams as RuleCreateParams, - type RuleUpdateParams as RuleUpdateParams, - type RuleListParams as RuleListParams, - type RuleDeleteParams as RuleDeleteParams, - type RuleEditParams as RuleEditParams, - type RuleGetParams as RuleGetParams, }; export { @@ -131,31 +72,12 @@ export declare namespace Firewall { type IPV6Configuration as IPV6Configuration, type AccessRuleCreateResponse as AccessRuleCreateResponse, type AccessRuleListResponse as AccessRuleListResponse, - type AccessRuleDeleteResponse as AccessRuleDeleteResponse, - type AccessRuleEditResponse as AccessRuleEditResponse, - type AccessRuleGetResponse as AccessRuleGetResponse, AccessRuleListResponsesV4PagePaginationArray as AccessRuleListResponsesV4PagePaginationArray, type AccessRuleCreateParams as AccessRuleCreateParams, type AccessRuleListParams as AccessRuleListParams, - type AccessRuleDeleteParams as AccessRuleDeleteParams, - type AccessRuleEditParams as AccessRuleEditParams, - type AccessRuleGetParams as AccessRuleGetParams, }; - export { - UARules as UARules, - type UARuleCreateResponse as UARuleCreateResponse, - type UARuleUpdateResponse as UARuleUpdateResponse, - type UARuleListResponse as UARuleListResponse, - type UARuleDeleteResponse as UARuleDeleteResponse, - type UARuleGetResponse as UARuleGetResponse, - UARuleListResponsesV4PagePaginationArray as UARuleListResponsesV4PagePaginationArray, - type UARuleCreateParams as UARuleCreateParams, - type UARuleUpdateParams as UARuleUpdateParams, - type UARuleListParams as UARuleListParams, - type UARuleDeleteParams as UARuleDeleteParams, - type UARuleGetParams as UARuleGetParams, - }; + export { UARules as UARules }; export { WAF as WAF }; } diff --git a/src/resources/firewall/index.ts b/src/resources/firewall/index.ts index 3fb9e6a32f..cff35efe77 100644 --- a/src/resources/firewall/index.ts +++ b/src/resources/firewall/index.ts @@ -10,58 +10,18 @@ export { type IPV6Configuration, type AccessRuleCreateResponse, type AccessRuleListResponse, - type AccessRuleDeleteResponse, - type AccessRuleEditResponse, - type AccessRuleGetResponse, type AccessRuleCreateParams, type AccessRuleListParams, - type AccessRuleDeleteParams, - type AccessRuleEditParams, - type AccessRuleGetParams, } from './access-rules'; export { Firewall } from './firewall'; export { - FirewallRulesV4PagePaginationArray, - Rules, - type FirewallRule, - type Product, - type DeletedFilter, - type RuleCreateResponse, - type RuleEditResponse, - type RuleCreateParams, - type RuleUpdateParams, - type RuleListParams, - type RuleDeleteParams, - type RuleEditParams, - type RuleGetParams, -} from './rules'; -export { - LockdownsV4PagePaginationArray, Lockdowns, type Configuration, type Lockdown, type LockdownCIDRConfiguration, type LockdownIPConfiguration, type LockdownURL, - type LockdownDeleteResponse, - type LockdownCreateParams, - type LockdownUpdateParams, - type LockdownListParams, - type LockdownDeleteParams, - type LockdownGetParams, } from './lockdowns'; -export { - UARuleListResponsesV4PagePaginationArray, - UARules, - type UARuleCreateResponse, - type UARuleUpdateResponse, - type UARuleListResponse, - type UARuleDeleteResponse, - type UARuleGetResponse, - type UARuleCreateParams, - type UARuleUpdateParams, - type UARuleListParams, - type UARuleDeleteParams, - type UARuleGetParams, -} from './ua-rules'; +export { Rules, type FirewallRule, type Product, type DeletedFilter } from './rules'; +export { UARules } from './ua-rules'; export { WAF } from './waf/index'; diff --git a/src/resources/firewall/lockdowns.ts b/src/resources/firewall/lockdowns.ts index 72b1cd8a95..0bc0f64250 100644 --- a/src/resources/firewall/lockdowns.ts +++ b/src/resources/firewall/lockdowns.ts @@ -1,103 +1,15 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../../resource'; -import * as Core from '../../core'; -import * as OverridesAPI from './waf/overrides'; -import { V4PagePaginationArray, type V4PagePaginationArrayParams } from '../../pagination'; -export class Lockdowns extends APIResource { - /** - * Creates a new Zone Lockdown rule. - */ - create(params: LockdownCreateParams, options?: Core.RequestOptions): Core.APIPromise { - const { zone_id, ...body } = params; - return ( - this._client.post(`/zones/${zone_id}/firewall/lockdowns`, { body, ...options }) as Core.APIPromise<{ - result: Lockdown; - }> - )._thenUnwrap((obj) => obj.result); - } - - /** - * Updates an existing Zone Lockdown rule. - */ - update( - lockDownsId: string, - params: LockdownUpdateParams, - options?: Core.RequestOptions, - ): Core.APIPromise { - const { zone_id, ...body } = params; - return ( - this._client.put(`/zones/${zone_id}/firewall/lockdowns/${lockDownsId}`, { - body, - ...options, - }) as Core.APIPromise<{ result: Lockdown }> - )._thenUnwrap((obj) => obj.result); - } - - /** - * Fetches Zone Lockdown rules. You can filter the results using several optional - * parameters. - */ - list( - params: LockdownListParams, - options?: Core.RequestOptions, - ): Core.PagePromise { - const { zone_id, ...query } = params; - return this._client.getAPIList(`/zones/${zone_id}/firewall/lockdowns`, LockdownsV4PagePaginationArray, { - query, - ...options, - }); - } - - /** - * Deletes an existing Zone Lockdown rule. - */ - delete( - lockDownsId: string, - params: LockdownDeleteParams, - options?: Core.RequestOptions, - ): Core.APIPromise { - const { zone_id } = params; - return ( - this._client.delete(`/zones/${zone_id}/firewall/lockdowns/${lockDownsId}`, options) as Core.APIPromise<{ - result: LockdownDeleteResponse; - }> - )._thenUnwrap((obj) => obj.result); - } - - /** - * Fetches the details of a Zone Lockdown rule. - */ - get( - lockDownsId: string, - params: LockdownGetParams, - options?: Core.RequestOptions, - ): Core.APIPromise { - const { zone_id } = params; - return ( - this._client.get(`/zones/${zone_id}/firewall/lockdowns/${lockDownsId}`, options) as Core.APIPromise<{ - result: Lockdown; - }> - )._thenUnwrap((obj) => obj.result); - } -} - -export class LockdownsV4PagePaginationArray extends V4PagePaginationArray {} - -/** - * A list of IP addresses or CIDR ranges that will be allowed to access the URLs - * specified in the Zone Lockdown rule. You can include any number of `ip` or - * `ip_range` configurations. - */ -export type Configuration = Array; +export class Lockdowns extends APIResource {} /** * A list of IP addresses or CIDR ranges that will be allowed to access the URLs * specified in the Zone Lockdown rule. You can include any number of `ip` or * `ip_range` configurations. */ -export type ConfigurationParam = Array; +export type Configuration = LockdownIPConfiguration | LockdownCIDRConfiguration; export interface Lockdown { /** @@ -153,19 +65,6 @@ export interface LockdownCIDRConfiguration { value?: string; } -export interface LockdownCIDRConfigurationParam { - /** - * The configuration target. You must set the target to `ip_range` when specifying - * an IP address range in the Zone Lockdown rule. - */ - target?: 'ip_range'; - - /** - * The IP address range to match. You can only use prefix lengths `/16` and `/24`. - */ - value?: string; -} - export interface LockdownIPConfiguration { /** * The configuration target. You must set the target to `ip` when specifying an IP @@ -180,141 +79,8 @@ export interface LockdownIPConfiguration { value?: string; } -export interface LockdownIPConfigurationParam { - /** - * The configuration target. You must set the target to `ip` when specifying an IP - * address in the Zone Lockdown rule. - */ - target?: 'ip'; - - /** - * The IP address to match. This address will be compared to the IP address of - * incoming requests. - */ - value?: string; -} - export type LockdownURL = string; -export interface LockdownDeleteResponse { - /** - * The unique identifier of the Zone Lockdown rule. - */ - id?: string; -} - -export interface LockdownCreateParams { - /** - * Path param: Identifier - */ - zone_id: string; - - /** - * Body param: A list of IP addresses or CIDR ranges that will be allowed to access - * the URLs specified in the Zone Lockdown rule. You can include any number of `ip` - * or `ip_range` configurations. - */ - configurations: ConfigurationParam; - - /** - * Body param: The URLs to include in the current WAF override. You can use - * wildcards. Each entered URL will be escaped before use, which means you can only - * use simple wildcard patterns. - */ - urls: Array; -} - -export interface LockdownUpdateParams { - /** - * Path param: Identifier - */ - zone_id: string; - - /** - * Body param: A list of IP addresses or CIDR ranges that will be allowed to access - * the URLs specified in the Zone Lockdown rule. You can include any number of `ip` - * or `ip_range` configurations. - */ - configurations: ConfigurationParam; - - /** - * Body param: The URLs to include in the current WAF override. You can use - * wildcards. Each entered URL will be escaped before use, which means you can only - * use simple wildcard patterns. - */ - urls: Array; -} - -export interface LockdownListParams extends V4PagePaginationArrayParams { - /** - * Path param: Identifier - */ - zone_id: string; - - /** - * Query param: The timestamp of when the rule was created. - */ - created_on?: string; - - /** - * Query param: A string to search for in the description of existing rules. - */ - description?: string; - - /** - * Query param: A string to search for in the description of existing rules. - */ - description_search?: string; - - /** - * Query param: A single IP address to search for in existing rules. - */ - ip?: string; - - /** - * Query param: A single IP address range to search for in existing rules. - */ - ip_range_search?: string; - - /** - * Query param: A single IP address to search for in existing rules. - */ - ip_search?: string; - - /** - * Query param: The timestamp of when the rule was last modified. - */ - modified_on?: string; - - /** - * Query param: The priority of the rule to control the processing order. A lower - * number indicates higher priority. If not provided, any rules with a configured - * priority will be processed before rules without a priority. - */ - priority?: number; - - /** - * Query param: A single URI to search for in the list of URLs of existing rules. - */ - uri_search?: string; -} - -export interface LockdownDeleteParams { - /** - * Identifier - */ - zone_id: string; -} - -export interface LockdownGetParams { - /** - * Identifier - */ - zone_id: string; -} - -Lockdowns.LockdownsV4PagePaginationArray = LockdownsV4PagePaginationArray; - export declare namespace Lockdowns { export { type Configuration as Configuration, @@ -322,12 +88,5 @@ export declare namespace Lockdowns { type LockdownCIDRConfiguration as LockdownCIDRConfiguration, type LockdownIPConfiguration as LockdownIPConfiguration, type LockdownURL as LockdownURL, - type LockdownDeleteResponse as LockdownDeleteResponse, - LockdownsV4PagePaginationArray as LockdownsV4PagePaginationArray, - type LockdownCreateParams as LockdownCreateParams, - type LockdownUpdateParams as LockdownUpdateParams, - type LockdownListParams as LockdownListParams, - type LockdownDeleteParams as LockdownDeleteParams, - type LockdownGetParams as LockdownGetParams, }; } diff --git a/src/resources/firewall/rules.ts b/src/resources/firewall/rules.ts index a76148ce24..b5d21c0bff 100644 --- a/src/resources/firewall/rules.ts +++ b/src/resources/firewall/rules.ts @@ -1,119 +1,10 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../../resource'; -import * as Core from '../../core'; import * as FiltersAPI from '../filters'; import * as RateLimitsAPI from '../rate-limits'; -import { V4PagePaginationArray, type V4PagePaginationArrayParams } from '../../pagination'; -export class Rules extends APIResource { - /** - * Create one or more firewall rules. - * - * @deprecated The Firewall Rules API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details. - */ - create( - params: RuleCreateParams, - options?: Core.RequestOptions, - ): Core.APIPromise { - const { zone_id, ...body } = params; - return ( - this._client.post(`/zones/${zone_id}/firewall/rules`, { body, ...options }) as Core.APIPromise<{ - result: RuleCreateResponse | null; - }> - )._thenUnwrap((obj) => obj.result); - } - - /** - * Updates an existing firewall rule. - * - * @deprecated The Firewall Rules API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details. - */ - update( - ruleId: string, - params: RuleUpdateParams, - options?: Core.RequestOptions, - ): Core.APIPromise { - const { zone_id, ...body } = params; - return ( - this._client.put(`/zones/${zone_id}/firewall/rules/${ruleId}`, { - body, - ...options, - }) as Core.APIPromise<{ result: FirewallRule }> - )._thenUnwrap((obj) => obj.result); - } - - /** - * Fetches firewall rules in a zone. You can filter the results using several - * optional parameters. - * - * @deprecated The Firewall Rules API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details. - */ - list( - params: RuleListParams, - options?: Core.RequestOptions, - ): Core.PagePromise { - const { zone_id, ...query } = params; - return this._client.getAPIList(`/zones/${zone_id}/firewall/rules`, FirewallRulesV4PagePaginationArray, { - query, - ...options, - }); - } - - /** - * Deletes an existing firewall rule. - * - * @deprecated The Firewall Rules API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details. - */ - delete( - ruleId: string, - params: RuleDeleteParams, - options?: Core.RequestOptions, - ): Core.APIPromise { - const { zone_id } = params; - return ( - this._client.delete(`/zones/${zone_id}/firewall/rules/${ruleId}`, options) as Core.APIPromise<{ - result: FirewallRule; - }> - )._thenUnwrap((obj) => obj.result); - } - - /** - * Updates the priority of an existing firewall rule. - * - * @deprecated The Firewall Rules API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details. - */ - edit( - ruleId: string, - params: RuleEditParams, - options?: Core.RequestOptions, - ): Core.APIPromise { - const { zone_id, ...body } = params; - return ( - this._client.patch(`/zones/${zone_id}/firewall/rules/${ruleId}`, { - body, - ...options, - }) as Core.APIPromise<{ result: RuleEditResponse | null }> - )._thenUnwrap((obj) => obj.result); - } - - /** - * Fetches the details of a firewall rule. - * - * @deprecated The Firewall Rules API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#firewall-rules-api-and-filters-api for full details. - */ - get(ruleId: string, params: RuleGetParams, options?: Core.RequestOptions): Core.APIPromise { - const { zone_id, ...query } = params; - return ( - this._client.get(`/zones/${zone_id}/firewall/rules/${ruleId}`, { - query, - ...options, - }) as Core.APIPromise<{ result: FirewallRule }> - )._thenUnwrap((obj) => obj.result); - } -} - -export class FirewallRulesV4PagePaginationArray extends V4PagePaginationArray {} +export class Rules extends APIResource {} export interface FirewallRule { /** @@ -171,224 +62,6 @@ export interface DeletedFilter { deleted: boolean; } -export type RuleCreateResponse = Array; - -export type RuleEditResponse = Array; - -export interface RuleCreateParams { - /** - * Path param: Identifier - */ - zone_id: string; - - /** - * Body param: The action to perform when the threshold of matched traffic within - * the configured period is exceeded. - */ - action: RuleCreateParams.Action; - - /** - * Body param: - */ - filter: FiltersAPI.FirewallFilterParam; -} - -export namespace RuleCreateParams { - /** - * The action to perform when the threshold of matched traffic within the - * configured period is exceeded. - */ - export interface Action { - /** - * The action to perform. - */ - mode?: 'simulate' | 'ban' | 'challenge' | 'js_challenge' | 'managed_challenge'; - - /** - * A custom content type and reponse to return when the threshold is exceeded. The - * custom response configured in this object will override the custom error for the - * zone. This object is optional. Notes: If you omit this object, Cloudflare will - * use the default HTML error page. If "mode" is "challenge", "managed_challenge", - * or "js_challenge", Cloudflare will use the zone challenge pages and you should - * not provide the "response" object. - */ - response?: Action.Response; - - /** - * The time in seconds during which Cloudflare will perform the mitigation action. - * Must be an integer value greater than or equal to the period. Notes: If "mode" - * is "challenge", "managed_challenge", or "js_challenge", Cloudflare will use the - * zone's Challenge Passage time and you should not provide this value. - */ - timeout?: number; - } - - export namespace Action { - /** - * A custom content type and reponse to return when the threshold is exceeded. The - * custom response configured in this object will override the custom error for the - * zone. This object is optional. Notes: If you omit this object, Cloudflare will - * use the default HTML error page. If "mode" is "challenge", "managed_challenge", - * or "js_challenge", Cloudflare will use the zone challenge pages and you should - * not provide the "response" object. - */ - export interface Response { - /** - * The response body to return. The value must conform to the configured content - * type. - */ - body?: string; - - /** - * The content type of the body. Must be one of the following: `text/plain`, - * `text/xml`, or `application/json`. - */ - content_type?: string; - } - } -} - -export interface RuleUpdateParams { - /** - * Path param: Identifier - */ - zone_id: string; - - /** - * Body param: The action to perform when the threshold of matched traffic within - * the configured period is exceeded. - */ - action: RuleUpdateParams.Action; - - /** - * Body param: - */ - filter: FiltersAPI.FirewallFilterParam; -} - -export namespace RuleUpdateParams { - /** - * The action to perform when the threshold of matched traffic within the - * configured period is exceeded. - */ - export interface Action { - /** - * The action to perform. - */ - mode?: 'simulate' | 'ban' | 'challenge' | 'js_challenge' | 'managed_challenge'; - - /** - * A custom content type and reponse to return when the threshold is exceeded. The - * custom response configured in this object will override the custom error for the - * zone. This object is optional. Notes: If you omit this object, Cloudflare will - * use the default HTML error page. If "mode" is "challenge", "managed_challenge", - * or "js_challenge", Cloudflare will use the zone challenge pages and you should - * not provide the "response" object. - */ - response?: Action.Response; - - /** - * The time in seconds during which Cloudflare will perform the mitigation action. - * Must be an integer value greater than or equal to the period. Notes: If "mode" - * is "challenge", "managed_challenge", or "js_challenge", Cloudflare will use the - * zone's Challenge Passage time and you should not provide this value. - */ - timeout?: number; - } - - export namespace Action { - /** - * A custom content type and reponse to return when the threshold is exceeded. The - * custom response configured in this object will override the custom error for the - * zone. This object is optional. Notes: If you omit this object, Cloudflare will - * use the default HTML error page. If "mode" is "challenge", "managed_challenge", - * or "js_challenge", Cloudflare will use the zone challenge pages and you should - * not provide the "response" object. - */ - export interface Response { - /** - * The response body to return. The value must conform to the configured content - * type. - */ - body?: string; - - /** - * The content type of the body. Must be one of the following: `text/plain`, - * `text/xml`, or `application/json`. - */ - content_type?: string; - } - } -} - -export interface RuleListParams extends V4PagePaginationArrayParams { - /** - * Path param: Identifier - */ - zone_id: string; - - /** - * Query param: The unique identifier of the firewall rule. - */ - id?: string; - - /** - * Query param: The action to search for. Must be an exact match. - */ - action?: string; - - /** - * Query param: A case-insensitive string to find in the description. - */ - description?: string; - - /** - * Query param: When true, indicates that the firewall rule is currently paused. - */ - paused?: boolean; -} - -export interface RuleDeleteParams { - /** - * Identifier - */ - zone_id: string; -} - -export interface RuleEditParams { - /** - * Identifier - */ - zone_id: string; -} - -export interface RuleGetParams { - /** - * Path param: Identifier - */ - zone_id: string; - - /** - * Query param: The unique identifier of the firewall rule. - */ - id?: string; -} - -Rules.FirewallRulesV4PagePaginationArray = FirewallRulesV4PagePaginationArray; - export declare namespace Rules { - export { - type FirewallRule as FirewallRule, - type Product as Product, - type DeletedFilter as DeletedFilter, - type RuleCreateResponse as RuleCreateResponse, - type RuleEditResponse as RuleEditResponse, - FirewallRulesV4PagePaginationArray as FirewallRulesV4PagePaginationArray, - type RuleCreateParams as RuleCreateParams, - type RuleUpdateParams as RuleUpdateParams, - type RuleListParams as RuleListParams, - type RuleDeleteParams as RuleDeleteParams, - type RuleEditParams as RuleEditParams, - type RuleGetParams as RuleGetParams, - }; + export { type FirewallRule as FirewallRule, type Product as Product, type DeletedFilter as DeletedFilter }; } diff --git a/src/resources/firewall/ua-rules.ts b/src/resources/firewall/ua-rules.ts index 8c8a3d70c3..d8f2487f02 100644 --- a/src/resources/firewall/ua-rules.ts +++ b/src/resources/firewall/ua-rules.ts @@ -1,244 +1,5 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../../resource'; -import * as Core from '../../core'; -import * as AccessRulesAPI from './access-rules'; -import { V4PagePaginationArray, type V4PagePaginationArrayParams } from '../../pagination'; -export class UARules extends APIResource { - /** - * Creates a new User Agent Blocking rule in a zone. - */ - create(params: UARuleCreateParams, options?: Core.RequestOptions): Core.APIPromise { - const { zone_id, ...body } = params; - return ( - this._client.post(`/zones/${zone_id}/firewall/ua_rules`, { body, ...options }) as Core.APIPromise<{ - result: UARuleCreateResponse; - }> - )._thenUnwrap((obj) => obj.result); - } - - /** - * Updates an existing User Agent Blocking rule. - */ - update( - uaRuleId: string, - params: UARuleUpdateParams, - options?: Core.RequestOptions, - ): Core.APIPromise { - const { zone_id, ...body } = params; - return ( - this._client.put(`/zones/${zone_id}/firewall/ua_rules/${uaRuleId}`, { - body, - ...options, - }) as Core.APIPromise<{ result: UARuleUpdateResponse }> - )._thenUnwrap((obj) => obj.result); - } - - /** - * Fetches User Agent Blocking rules in a zone. You can filter the results using - * several optional parameters. - */ - list( - params: UARuleListParams, - options?: Core.RequestOptions, - ): Core.PagePromise { - const { zone_id, ...query } = params; - return this._client.getAPIList( - `/zones/${zone_id}/firewall/ua_rules`, - UARuleListResponsesV4PagePaginationArray, - { query, ...options }, - ); - } - - /** - * Deletes an existing User Agent Blocking rule. - */ - delete( - uaRuleId: string, - params: UARuleDeleteParams, - options?: Core.RequestOptions, - ): Core.APIPromise { - const { zone_id } = params; - return ( - this._client.delete(`/zones/${zone_id}/firewall/ua_rules/${uaRuleId}`, options) as Core.APIPromise<{ - result: UARuleDeleteResponse; - }> - )._thenUnwrap((obj) => obj.result); - } - - /** - * Fetches the details of a User Agent Blocking rule. - */ - get( - uaRuleId: string, - params: UARuleGetParams, - options?: Core.RequestOptions, - ): Core.APIPromise { - const { zone_id } = params; - return ( - this._client.get(`/zones/${zone_id}/firewall/ua_rules/${uaRuleId}`, options) as Core.APIPromise<{ - result: UARuleGetResponse; - }> - )._thenUnwrap((obj) => obj.result); - } -} - -export class UARuleListResponsesV4PagePaginationArray extends V4PagePaginationArray {} - -export type UARuleCreateResponse = unknown | string | null; - -export type UARuleUpdateResponse = unknown | string | null; - -export interface UARuleListResponse { - /** - * The unique identifier of the User Agent Blocking rule. - */ - id?: string; - - /** - * The configuration object for the current rule. - */ - configuration?: UARuleListResponse.Configuration; - - /** - * An informative summary of the rule. - */ - description?: string; - - /** - * The action to apply to a matched request. - */ - mode?: 'block' | 'challenge' | 'js_challenge' | 'managed_challenge'; - - /** - * When true, indicates that the rule is currently paused. - */ - paused?: boolean; -} - -export namespace UARuleListResponse { - /** - * The configuration object for the current rule. - */ - export interface Configuration { - /** - * The configuration target for this rule. You must set the target to `ua` for User - * Agent Blocking rules. - */ - target?: string; - - /** - * The exact user agent string to match. This value will be compared to the - * received `User-Agent` HTTP header value. - */ - value?: string; - } -} - -export interface UARuleDeleteResponse { - /** - * The unique identifier of the User Agent Blocking rule. - */ - id?: string; -} - -export type UARuleGetResponse = unknown | string | null; - -export interface UARuleCreateParams { - /** - * Path param: Identifier - */ - zone_id: string; - - /** - * Body param: The rule configuration. - */ - configuration: - | AccessRulesAPI.AccessRuleIPConfigurationParam - | AccessRulesAPI.IPV6ConfigurationParam - | AccessRulesAPI.AccessRuleCIDRConfigurationParam - | AccessRulesAPI.ASNConfigurationParam - | AccessRulesAPI.CountryConfigurationParam; - - /** - * Body param: The action to apply to a matched request. - */ - mode: 'block' | 'challenge' | 'whitelist' | 'js_challenge' | 'managed_challenge'; -} - -export interface UARuleUpdateParams { - /** - * Path param: Identifier - */ - zone_id: string; - - /** - * Body param: The rule configuration. - */ - configuration: - | AccessRulesAPI.AccessRuleIPConfigurationParam - | AccessRulesAPI.IPV6ConfigurationParam - | AccessRulesAPI.AccessRuleCIDRConfigurationParam - | AccessRulesAPI.ASNConfigurationParam - | AccessRulesAPI.CountryConfigurationParam; - - /** - * Body param: The action to apply to a matched request. - */ - mode: 'block' | 'challenge' | 'whitelist' | 'js_challenge' | 'managed_challenge'; -} - -export interface UARuleListParams extends V4PagePaginationArrayParams { - /** - * Path param: Identifier - */ - zone_id: string; - - /** - * Query param: A string to search for in the description of existing rules. - */ - description?: string; - - /** - * Query param: A string to search for in the description of existing rules. - */ - description_search?: string; - - /** - * Query param: A string to search for in the user agent values of existing rules. - */ - ua_search?: string; -} - -export interface UARuleDeleteParams { - /** - * Identifier - */ - zone_id: string; -} - -export interface UARuleGetParams { - /** - * Identifier - */ - zone_id: string; -} - -UARules.UARuleListResponsesV4PagePaginationArray = UARuleListResponsesV4PagePaginationArray; - -export declare namespace UARules { - export { - type UARuleCreateResponse as UARuleCreateResponse, - type UARuleUpdateResponse as UARuleUpdateResponse, - type UARuleListResponse as UARuleListResponse, - type UARuleDeleteResponse as UARuleDeleteResponse, - type UARuleGetResponse as UARuleGetResponse, - UARuleListResponsesV4PagePaginationArray as UARuleListResponsesV4PagePaginationArray, - type UARuleCreateParams as UARuleCreateParams, - type UARuleUpdateParams as UARuleUpdateParams, - type UARuleListParams as UARuleListParams, - type UARuleDeleteParams as UARuleDeleteParams, - type UARuleGetParams as UARuleGetParams, - }; -} +export class UARules extends APIResource {} diff --git a/src/resources/firewall/waf/index.ts b/src/resources/firewall/waf/index.ts index 7f47a8efe3..8739fa4604 100644 --- a/src/resources/firewall/waf/index.ts +++ b/src/resources/firewall/waf/index.ts @@ -1,25 +1,5 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. -export { - OverridesV4PagePaginationArray, - Overrides, - type Override, - type OverrideURL, - type RewriteAction, - type WAFRule, - type OverrideDeleteResponse, - type OverrideCreateParams, - type OverrideUpdateParams, - type OverrideListParams, - type OverrideDeleteParams, - type OverrideGetParams, -} from './overrides'; -export { - PackageListResponsesV4PagePaginationArray, - Packages, - type PackageListResponse, - type PackageGetResponse, - type PackageListParams, - type PackageGetParams, -} from './packages/index'; +export { Overrides, type Override, type OverrideURL, type RewriteAction, type WAFRule } from './overrides'; +export { Packages } from './packages/index'; export { WAF } from './waf'; diff --git a/src/resources/firewall/waf/overrides.ts b/src/resources/firewall/waf/overrides.ts index f54c8195b5..92c4feaf84 100644 --- a/src/resources/firewall/waf/overrides.ts +++ b/src/resources/firewall/waf/overrides.ts @@ -1,105 +1,8 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../../../resource'; -import * as Core from '../../../core'; -import { V4PagePaginationArray, type V4PagePaginationArrayParams } from '../../../pagination'; -export class Overrides extends APIResource { - /** - * Creates a URI-based WAF override for a zone. - * - * **Note:** Applies only to the - * [previous version of WAF managed rules](https://developers.cloudflare.com/support/firewall/managed-rules-web-application-firewall-waf/understanding-waf-managed-rules-web-application-firewall/). - */ - create(params: OverrideCreateParams, options?: Core.RequestOptions): Core.APIPromise { - const { zone_id, ...body } = params; - return ( - this._client.post(`/zones/${zone_id}/firewall/waf/overrides`, { body, ...options }) as Core.APIPromise<{ - result: Override; - }> - )._thenUnwrap((obj) => obj.result); - } - - /** - * Updates an existing URI-based WAF override. - * - * **Note:** Applies only to the - * [previous version of WAF managed rules](https://developers.cloudflare.com/support/firewall/managed-rules-web-application-firewall-waf/understanding-waf-managed-rules-web-application-firewall/). - */ - update( - overridesId: string, - params: OverrideUpdateParams, - options?: Core.RequestOptions, - ): Core.APIPromise { - const { zone_id, ...body } = params; - return ( - this._client.put(`/zones/${zone_id}/firewall/waf/overrides/${overridesId}`, { - body, - ...options, - }) as Core.APIPromise<{ result: Override }> - )._thenUnwrap((obj) => obj.result); - } - - /** - * Fetches the URI-based WAF overrides in a zone. - * - * **Note:** Applies only to the - * [previous version of WAF managed rules](https://developers.cloudflare.com/support/firewall/managed-rules-web-application-firewall-waf/understanding-waf-managed-rules-web-application-firewall/). - */ - list( - params: OverrideListParams, - options?: Core.RequestOptions, - ): Core.PagePromise { - const { zone_id, ...query } = params; - return this._client.getAPIList( - `/zones/${zone_id}/firewall/waf/overrides`, - OverridesV4PagePaginationArray, - { query, ...options }, - ); - } - - /** - * Deletes an existing URI-based WAF override. - * - * **Note:** Applies only to the - * [previous version of WAF managed rules](https://developers.cloudflare.com/support/firewall/managed-rules-web-application-firewall-waf/understanding-waf-managed-rules-web-application-firewall/). - */ - delete( - overridesId: string, - params: OverrideDeleteParams, - options?: Core.RequestOptions, - ): Core.APIPromise { - const { zone_id } = params; - return ( - this._client.delete( - `/zones/${zone_id}/firewall/waf/overrides/${overridesId}`, - options, - ) as Core.APIPromise<{ result: OverrideDeleteResponse }> - )._thenUnwrap((obj) => obj.result); - } - - /** - * Fetches the details of a URI-based WAF override. - * - * **Note:** Applies only to the - * [previous version of WAF managed rules](https://developers.cloudflare.com/support/firewall/managed-rules-web-application-firewall-waf/understanding-waf-managed-rules-web-application-firewall/). - */ - get( - overridesId: string, - params: OverrideGetParams, - options?: Core.RequestOptions, - ): Core.APIPromise { - const { zone_id } = params; - return ( - this._client.get( - `/zones/${zone_id}/firewall/waf/overrides/${overridesId}`, - options, - ) as Core.APIPromise<{ result: Override }> - )._thenUnwrap((obj) => obj.result); - } -} - -export class OverridesV4PagePaginationArray extends V4PagePaginationArray {} +export class Overrides extends APIResource {} export interface Override { /** @@ -158,8 +61,6 @@ export interface Override { export type OverrideURL = string; -export type OverrideURLParam = string; - /** * Specifies that, when a WAF rule matches, its configured action will be replaced * by the action configured in this object. @@ -191,37 +92,6 @@ export interface RewriteAction { simulate?: 'challenge' | 'block' | 'simulate' | 'disable' | 'default'; } -/** - * Specifies that, when a WAF rule matches, its configured action will be replaced - * by the action configured in this object. - */ -export interface RewriteActionParam { - /** - * The WAF rule action to apply. - */ - block?: 'challenge' | 'block' | 'simulate' | 'disable' | 'default'; - - /** - * The WAF rule action to apply. - */ - challenge?: 'challenge' | 'block' | 'simulate' | 'disable' | 'default'; - - /** - * The WAF rule action to apply. - */ - default?: 'challenge' | 'block' | 'simulate' | 'disable' | 'default'; - - /** - * The WAF rule action to apply. - */ - disable?: 'challenge' | 'block' | 'simulate' | 'disable' | 'default'; - - /** - * The WAF rule action to apply. - */ - simulate?: 'challenge' | 'block' | 'simulate' | 'disable' | 'default'; -} - /** * An object that allows you to override the action of specific WAF rules. Each key * of this object must be the ID of a WAF rule, and each value must be a valid WAF @@ -231,105 +101,11 @@ export interface RewriteActionParam { */ export type WAFRule = Record; -/** - * An object that allows you to override the action of specific WAF rules. Each key - * of this object must be the ID of a WAF rule, and each value must be a valid WAF - * action. Unless you are disabling a rule, ensure that you also enable the rule - * group that this WAF rule belongs to. When creating a new URI-based WAF override, - * you must provide a `groups` object or a `rules` object. - */ -export type WAFRuleParam = Record; - -export interface OverrideDeleteResponse { - /** - * The unique identifier of the WAF override. - */ - id?: string; -} - -export interface OverrideCreateParams { - /** - * Path param: Identifier - */ - zone_id: string; - - /** - * Body param: The URLs to include in the current WAF override. You can use - * wildcards. Each entered URL will be escaped before use, which means you can only - * use simple wildcard patterns. - */ - urls: Array; -} - -export interface OverrideUpdateParams { - /** - * Path param: Identifier - */ - zone_id: string; - - /** - * Body param: Identifier - */ - id: string; - - /** - * Body param: Specifies that, when a WAF rule matches, its configured action will - * be replaced by the action configured in this object. - */ - rewrite_action: RewriteActionParam; - - /** - * Body param: An object that allows you to override the action of specific WAF - * rules. Each key of this object must be the ID of a WAF rule, and each value must - * be a valid WAF action. Unless you are disabling a rule, ensure that you also - * enable the rule group that this WAF rule belongs to. When creating a new - * URI-based WAF override, you must provide a `groups` object or a `rules` object. - */ - rules: WAFRuleParam; - - /** - * Body param: The URLs to include in the current WAF override. You can use - * wildcards. Each entered URL will be escaped before use, which means you can only - * use simple wildcard patterns. - */ - urls: Array; -} - -export interface OverrideListParams extends V4PagePaginationArrayParams { - /** - * Path param: Identifier - */ - zone_id: string; -} - -export interface OverrideDeleteParams { - /** - * Identifier - */ - zone_id: string; -} - -export interface OverrideGetParams { - /** - * Identifier - */ - zone_id: string; -} - -Overrides.OverridesV4PagePaginationArray = OverridesV4PagePaginationArray; - export declare namespace Overrides { export { type Override as Override, type OverrideURL as OverrideURL, type RewriteAction as RewriteAction, type WAFRule as WAFRule, - type OverrideDeleteResponse as OverrideDeleteResponse, - OverridesV4PagePaginationArray as OverridesV4PagePaginationArray, - type OverrideCreateParams as OverrideCreateParams, - type OverrideUpdateParams as OverrideUpdateParams, - type OverrideListParams as OverrideListParams, - type OverrideDeleteParams as OverrideDeleteParams, - type OverrideGetParams as OverrideGetParams, }; } diff --git a/src/resources/firewall/waf/packages/index.ts b/src/resources/firewall/waf/packages/index.ts index 0e20a4f731..00c9ae0d8a 100644 --- a/src/resources/firewall/waf/packages/index.ts +++ b/src/resources/firewall/waf/packages/index.ts @@ -10,14 +10,7 @@ export { type GroupEditParams, type GroupGetParams, } from './groups'; -export { - PackageListResponsesV4PagePaginationArray, - Packages, - type PackageListResponse, - type PackageGetResponse, - type PackageListParams, - type PackageGetParams, -} from './packages'; +export { Packages } from './packages'; export { RuleListResponsesV4PagePaginationArray, Rules, diff --git a/src/resources/firewall/waf/packages/packages.ts b/src/resources/firewall/waf/packages/packages.ts index bab75abe14..09c70583c2 100644 --- a/src/resources/firewall/waf/packages/packages.ts +++ b/src/resources/firewall/waf/packages/packages.ts @@ -1,8 +1,6 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../../../../resource'; -import * as Core from '../../../../core'; -import * as Shared from '../../../shared'; import * as GroupsAPI from './groups'; import { Group, @@ -27,121 +25,18 @@ import { Rules, WAFRuleGroup, } from './rules'; -import { V4PagePaginationArray, type V4PagePaginationArrayParams } from '../../../../pagination'; export class Packages extends APIResource { groups: GroupsAPI.Groups = new GroupsAPI.Groups(this._client); rules: RulesAPI.Rules = new RulesAPI.Rules(this._client); - - /** - * Fetches WAF packages for a zone. - * - * **Note:** Applies only to the - * [previous version of WAF managed rules](https://developers.cloudflare.com/support/firewall/managed-rules-web-application-firewall-waf/understanding-waf-managed-rules-web-application-firewall/). - */ - list( - params: PackageListParams, - options?: Core.RequestOptions, - ): Core.PagePromise { - const { zone_id, ...query } = params; - return this._client.getAPIList( - `/zones/${zone_id}/firewall/waf/packages`, - PackageListResponsesV4PagePaginationArray, - { query, ...options }, - ); - } - - /** - * Fetches the details of a WAF package. - * - * **Note:** Applies only to the - * [previous version of WAF managed rules](https://developers.cloudflare.com/support/firewall/managed-rules-web-application-firewall-waf/understanding-waf-managed-rules-web-application-firewall/). - */ - get( - packageId: string, - params: PackageGetParams, - options?: Core.RequestOptions, - ): Core.APIPromise { - const { zone_id } = params; - return this._client.get(`/zones/${zone_id}/firewall/waf/packages/${packageId}`, options); - } -} - -export class PackageListResponsesV4PagePaginationArray extends V4PagePaginationArray {} - -export type PackageListResponse = unknown; - -export type PackageGetResponse = PackageGetResponse.FirewallAPIResponseSingle | PackageGetResponse.Result; - -export namespace PackageGetResponse { - export interface FirewallAPIResponseSingle { - errors: Array; - - messages: Array; - - result: unknown | string | null; - - /** - * Whether the API call was successful - */ - success: true; - } - - export interface Result { - result?: unknown; - } } -export interface PackageListParams extends V4PagePaginationArrayParams { - /** - * Path param: Identifier - */ - zone_id: string; - - /** - * Query param: The direction used to sort returned packages. - */ - direction?: 'asc' | 'desc'; - - /** - * Query param: When set to `all`, all the search requirements must match. When set - * to `any`, only one of the search requirements has to match. - */ - match?: 'any' | 'all'; - - /** - * Query param: The name of the WAF package. - */ - name?: string; - - /** - * Query param: The field used to sort returned packages. - */ - order?: 'name'; -} - -export interface PackageGetParams { - /** - * Identifier - */ - zone_id: string; -} - -Packages.PackageListResponsesV4PagePaginationArray = PackageListResponsesV4PagePaginationArray; Packages.Groups = Groups; Packages.GroupsV4PagePaginationArray = GroupsV4PagePaginationArray; Packages.Rules = Rules; Packages.RuleListResponsesV4PagePaginationArray = RuleListResponsesV4PagePaginationArray; export declare namespace Packages { - export { - type PackageListResponse as PackageListResponse, - type PackageGetResponse as PackageGetResponse, - PackageListResponsesV4PagePaginationArray as PackageListResponsesV4PagePaginationArray, - type PackageListParams as PackageListParams, - type PackageGetParams as PackageGetParams, - }; - export { Groups as Groups, type Group as Group, diff --git a/src/resources/firewall/waf/waf.ts b/src/resources/firewall/waf/waf.ts index f16358ba96..d8604b9db6 100644 --- a/src/resources/firewall/waf/waf.ts +++ b/src/resources/firewall/waf/waf.ts @@ -2,29 +2,9 @@ import { APIResource } from '../../../resource'; import * as OverridesAPI from './overrides'; -import { - Override, - OverrideCreateParams, - OverrideDeleteParams, - OverrideDeleteResponse, - OverrideGetParams, - OverrideListParams, - OverrideURL, - OverrideUpdateParams, - Overrides, - OverridesV4PagePaginationArray, - RewriteAction, - WAFRule, -} from './overrides'; +import { Override, OverrideURL, Overrides, RewriteAction, WAFRule } from './overrides'; import * as PackagesAPI from './packages/packages'; -import { - PackageGetParams, - PackageGetResponse, - PackageListParams, - PackageListResponse, - PackageListResponsesV4PagePaginationArray, - Packages, -} from './packages/packages'; +import { Packages } from './packages/packages'; export class WAF extends APIResource { overrides: OverridesAPI.Overrides = new OverridesAPI.Overrides(this._client); @@ -32,9 +12,7 @@ export class WAF extends APIResource { } WAF.Overrides = Overrides; -WAF.OverridesV4PagePaginationArray = OverridesV4PagePaginationArray; WAF.Packages = Packages; -WAF.PackageListResponsesV4PagePaginationArray = PackageListResponsesV4PagePaginationArray; export declare namespace WAF { export { @@ -43,21 +21,7 @@ export declare namespace WAF { type OverrideURL as OverrideURL, type RewriteAction as RewriteAction, type WAFRule as WAFRule, - type OverrideDeleteResponse as OverrideDeleteResponse, - OverridesV4PagePaginationArray as OverridesV4PagePaginationArray, - type OverrideCreateParams as OverrideCreateParams, - type OverrideUpdateParams as OverrideUpdateParams, - type OverrideListParams as OverrideListParams, - type OverrideDeleteParams as OverrideDeleteParams, - type OverrideGetParams as OverrideGetParams, }; - export { - Packages as Packages, - type PackageListResponse as PackageListResponse, - type PackageGetResponse as PackageGetResponse, - PackageListResponsesV4PagePaginationArray as PackageListResponsesV4PagePaginationArray, - type PackageListParams as PackageListParams, - type PackageGetParams as PackageGetParams, - }; + export { Packages as Packages }; } diff --git a/src/resources/rate-limits.ts b/src/resources/rate-limits.ts index bb572da598..bfccbe5c86 100644 --- a/src/resources/rate-limits.ts +++ b/src/resources/rate-limits.ts @@ -1,99 +1,9 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../resource'; -import * as Core from '../core'; import * as RateLimitsAPI from './rate-limits'; -import { V4PagePaginationArray, type V4PagePaginationArrayParams } from '../pagination'; -export class RateLimits extends APIResource { - /** - * Creates a new rate limit for a zone. Refer to the object definition for a list - * of required attributes. - * - * @deprecated Rate limiting API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#rate-limiting-api-previous-version for full details. - */ - create(params: RateLimitCreateParams, options?: Core.RequestOptions): Core.APIPromise { - const { zone_id, ...body } = params; - return ( - this._client.post(`/zones/${zone_id}/rate_limits`, { body, ...options }) as Core.APIPromise<{ - result: RateLimit; - }> - )._thenUnwrap((obj) => obj.result); - } - - /** - * Fetches the rate limits for a zone. - * - * @deprecated Rate limiting API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#rate-limiting-api-previous-version for full details. - */ - list( - params: RateLimitListParams, - options?: Core.RequestOptions, - ): Core.PagePromise { - const { zone_id, ...query } = params; - return this._client.getAPIList(`/zones/${zone_id}/rate_limits`, RateLimitsV4PagePaginationArray, { - query, - ...options, - }); - } - - /** - * Deletes an existing rate limit. - * - * @deprecated Rate limiting API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#rate-limiting-api-previous-version for full details. - */ - delete( - rateLimitId: string, - params: RateLimitDeleteParams, - options?: Core.RequestOptions, - ): Core.APIPromise { - const { zone_id } = params; - return ( - this._client.delete(`/zones/${zone_id}/rate_limits/${rateLimitId}`, options) as Core.APIPromise<{ - result: RateLimitDeleteResponse; - }> - )._thenUnwrap((obj) => obj.result); - } - - /** - * Updates an existing rate limit. - * - * @deprecated Rate limiting API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#rate-limiting-api-previous-version for full details. - */ - edit( - rateLimitId: string, - params: RateLimitEditParams, - options?: Core.RequestOptions, - ): Core.APIPromise { - const { zone_id, ...body } = params; - return ( - this._client.put(`/zones/${zone_id}/rate_limits/${rateLimitId}`, { - body, - ...options, - }) as Core.APIPromise<{ result: RateLimit }> - )._thenUnwrap((obj) => obj.result); - } - - /** - * Fetches the details of a rate limit. - * - * @deprecated Rate limiting API is deprecated in favour of using the Ruleset Engine. See https://developers.cloudflare.com/fundamentals/api/reference/deprecations/#rate-limiting-api-previous-version for full details. - */ - get( - rateLimitId: string, - params: RateLimitGetParams, - options?: Core.RequestOptions, - ): Core.APIPromise { - const { zone_id } = params; - return ( - this._client.get(`/zones/${zone_id}/rate_limits/${rateLimitId}`, options) as Core.APIPromise<{ - result: RateLimit; - }> - )._thenUnwrap((obj) => obj.result); - } -} - -export class RateLimitsV4PagePaginationArray extends V4PagePaginationArray {} +export class RateLimits extends APIResource {} /** * The action to apply to a matched request. The `log` action is only available on @@ -113,11 +23,6 @@ export type Action = */ export type Methods = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | '_ALL_'; -/** - * An HTTP method or `_ALL_` to indicate all methods. - */ -export type MethodsParam = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | '_ALL_'; - export interface RateLimit { /** * The unique identifier of the rate limit. @@ -294,507 +199,3 @@ export namespace RateLimit { } } } - -export interface RateLimitDeleteResponse { - /** - * The unique identifier of the rate limit. - */ - id?: string; - - /** - * The action to perform when the threshold of matched traffic within the - * configured period is exceeded. - */ - action?: RateLimitDeleteResponse.Action; - - /** - * Criteria specifying when the current rate limit should be bypassed. You can - * specify that the rate limit should not apply to one or more URLs. - */ - bypass?: Array; - - /** - * An informative summary of the rate limit. This value is sanitized and any tags - * will be removed. - */ - description?: string; - - /** - * When true, indicates that the rate limit is currently disabled. - */ - disabled?: boolean; - - /** - * Determines which traffic the rate limit counts towards the threshold. - */ - match?: RateLimitDeleteResponse.Match; - - /** - * The time in seconds (an integer value) to count matching traffic. If the count - * exceeds the configured threshold within this period, Cloudflare will perform the - * configured action. - */ - period?: number; - - /** - * The threshold that will trigger the configured mitigation action. Configure this - * value along with the `period` property to establish a threshold per period. - */ - threshold?: number; -} - -export namespace RateLimitDeleteResponse { - /** - * The action to perform when the threshold of matched traffic within the - * configured period is exceeded. - */ - export interface Action { - /** - * The action to perform. - */ - mode?: 'simulate' | 'ban' | 'challenge' | 'js_challenge' | 'managed_challenge'; - - /** - * A custom content type and reponse to return when the threshold is exceeded. The - * custom response configured in this object will override the custom error for the - * zone. This object is optional. Notes: If you omit this object, Cloudflare will - * use the default HTML error page. If "mode" is "challenge", "managed_challenge", - * or "js_challenge", Cloudflare will use the zone challenge pages and you should - * not provide the "response" object. - */ - response?: Action.Response; - - /** - * The time in seconds during which Cloudflare will perform the mitigation action. - * Must be an integer value greater than or equal to the period. Notes: If "mode" - * is "challenge", "managed_challenge", or "js_challenge", Cloudflare will use the - * zone's Challenge Passage time and you should not provide this value. - */ - timeout?: number; - } - - export namespace Action { - /** - * A custom content type and reponse to return when the threshold is exceeded. The - * custom response configured in this object will override the custom error for the - * zone. This object is optional. Notes: If you omit this object, Cloudflare will - * use the default HTML error page. If "mode" is "challenge", "managed_challenge", - * or "js_challenge", Cloudflare will use the zone challenge pages and you should - * not provide the "response" object. - */ - export interface Response { - /** - * The response body to return. The value must conform to the configured content - * type. - */ - body?: string; - - /** - * The content type of the body. Must be one of the following: `text/plain`, - * `text/xml`, or `application/json`. - */ - content_type?: string; - } - } - - export interface Bypass { - name?: 'url'; - - /** - * The URL to bypass. - */ - value?: string; - } - - /** - * Determines which traffic the rate limit counts towards the threshold. - */ - export interface Match { - headers?: Array; - - request?: Match.Request; - - response?: Match.Response; - } - - export namespace Match { - export interface Header { - /** - * The name of the response header to match. - */ - name?: string; - - /** - * The operator used when matching: `eq` means "equal" and `ne` means "not equal". - */ - op?: 'eq' | 'ne'; - - /** - * The value of the response header, which must match exactly. - */ - value?: string; - } - - export interface Request { - /** - * The HTTP methods to match. You can specify a subset (for example, - * `['POST','PUT']`) or all methods (`['_ALL_']`). This field is optional when - * creating a rate limit. - */ - methods?: Array; - - /** - * The HTTP schemes to match. You can specify one scheme (`['HTTPS']`), both - * schemes (`['HTTP','HTTPS']`), or all schemes (`['_ALL_']`). This field is - * optional. - */ - schemes?: Array; - - /** - * The URL pattern to match, composed of a host and a path such as - * `example.org/path*`. Normalization is applied before the pattern is matched. `*` - * wildcards are expanded to match applicable traffic. Query strings are not - * matched. Set the value to `*` to match all traffic to your zone. - */ - url?: string; - } - - export interface Response { - /** - * When true, only the uncached traffic served from your origin servers will count - * towards rate limiting. In this case, any cached traffic served by Cloudflare - * will not count towards rate limiting. This field is optional. Notes: This field - * is deprecated. Instead, use response headers and set "origin_traffic" to "false" - * to avoid legacy behaviour interacting with the "response_headers" property. - */ - origin_traffic?: boolean; - } - } -} - -export interface RateLimitCreateParams { - /** - * Path param: Identifier - */ - zone_id: string; - - /** - * Body param: The action to perform when the threshold of matched traffic within - * the configured period is exceeded. - */ - action: RateLimitCreateParams.Action; - - /** - * Body param: Determines which traffic the rate limit counts towards the - * threshold. - */ - match: RateLimitCreateParams.Match; - - /** - * Body param: The time in seconds (an integer value) to count matching traffic. If - * the count exceeds the configured threshold within this period, Cloudflare will - * perform the configured action. - */ - period: number; - - /** - * Body param: The threshold that will trigger the configured mitigation action. - * Configure this value along with the `period` property to establish a threshold - * per period. - */ - threshold: number; -} - -export namespace RateLimitCreateParams { - /** - * The action to perform when the threshold of matched traffic within the - * configured period is exceeded. - */ - export interface Action { - /** - * The action to perform. - */ - mode?: 'simulate' | 'ban' | 'challenge' | 'js_challenge' | 'managed_challenge'; - - /** - * A custom content type and reponse to return when the threshold is exceeded. The - * custom response configured in this object will override the custom error for the - * zone. This object is optional. Notes: If you omit this object, Cloudflare will - * use the default HTML error page. If "mode" is "challenge", "managed_challenge", - * or "js_challenge", Cloudflare will use the zone challenge pages and you should - * not provide the "response" object. - */ - response?: Action.Response; - - /** - * The time in seconds during which Cloudflare will perform the mitigation action. - * Must be an integer value greater than or equal to the period. Notes: If "mode" - * is "challenge", "managed_challenge", or "js_challenge", Cloudflare will use the - * zone's Challenge Passage time and you should not provide this value. - */ - timeout?: number; - } - - export namespace Action { - /** - * A custom content type and reponse to return when the threshold is exceeded. The - * custom response configured in this object will override the custom error for the - * zone. This object is optional. Notes: If you omit this object, Cloudflare will - * use the default HTML error page. If "mode" is "challenge", "managed_challenge", - * or "js_challenge", Cloudflare will use the zone challenge pages and you should - * not provide the "response" object. - */ - export interface Response { - /** - * The response body to return. The value must conform to the configured content - * type. - */ - body?: string; - - /** - * The content type of the body. Must be one of the following: `text/plain`, - * `text/xml`, or `application/json`. - */ - content_type?: string; - } - } - - /** - * Determines which traffic the rate limit counts towards the threshold. - */ - export interface Match { - headers?: Array; - - request?: Match.Request; - - response?: Match.Response; - } - - export namespace Match { - export interface Header { - /** - * The name of the response header to match. - */ - name?: string; - - /** - * The operator used when matching: `eq` means "equal" and `ne` means "not equal". - */ - op?: 'eq' | 'ne'; - - /** - * The value of the response header, which must match exactly. - */ - value?: string; - } - - export interface Request { - /** - * The HTTP methods to match. You can specify a subset (for example, - * `['POST','PUT']`) or all methods (`['_ALL_']`). This field is optional when - * creating a rate limit. - */ - methods?: Array; - - /** - * The HTTP schemes to match. You can specify one scheme (`['HTTPS']`), both - * schemes (`['HTTP','HTTPS']`), or all schemes (`['_ALL_']`). This field is - * optional. - */ - schemes?: Array; - - /** - * The URL pattern to match, composed of a host and a path such as - * `example.org/path*`. Normalization is applied before the pattern is matched. `*` - * wildcards are expanded to match applicable traffic. Query strings are not - * matched. Set the value to `*` to match all traffic to your zone. - */ - url?: string; - } - - export interface Response { - /** - * When true, only the uncached traffic served from your origin servers will count - * towards rate limiting. In this case, any cached traffic served by Cloudflare - * will not count towards rate limiting. This field is optional. Notes: This field - * is deprecated. Instead, use response headers and set "origin_traffic" to "false" - * to avoid legacy behaviour interacting with the "response_headers" property. - */ - origin_traffic?: boolean; - } - } -} - -export interface RateLimitListParams extends V4PagePaginationArrayParams { - /** - * Path param: Identifier - */ - zone_id: string; -} - -export interface RateLimitDeleteParams { - /** - * Identifier - */ - zone_id: string; -} - -export interface RateLimitEditParams { - /** - * Path param: Identifier - */ - zone_id: string; - - /** - * Body param: The action to perform when the threshold of matched traffic within - * the configured period is exceeded. - */ - action: RateLimitEditParams.Action; - - /** - * Body param: Determines which traffic the rate limit counts towards the - * threshold. - */ - match: RateLimitEditParams.Match; - - /** - * Body param: The time in seconds (an integer value) to count matching traffic. If - * the count exceeds the configured threshold within this period, Cloudflare will - * perform the configured action. - */ - period: number; - - /** - * Body param: The threshold that will trigger the configured mitigation action. - * Configure this value along with the `period` property to establish a threshold - * per period. - */ - threshold: number; -} - -export namespace RateLimitEditParams { - /** - * The action to perform when the threshold of matched traffic within the - * configured period is exceeded. - */ - export interface Action { - /** - * The action to perform. - */ - mode?: 'simulate' | 'ban' | 'challenge' | 'js_challenge' | 'managed_challenge'; - - /** - * A custom content type and reponse to return when the threshold is exceeded. The - * custom response configured in this object will override the custom error for the - * zone. This object is optional. Notes: If you omit this object, Cloudflare will - * use the default HTML error page. If "mode" is "challenge", "managed_challenge", - * or "js_challenge", Cloudflare will use the zone challenge pages and you should - * not provide the "response" object. - */ - response?: Action.Response; - - /** - * The time in seconds during which Cloudflare will perform the mitigation action. - * Must be an integer value greater than or equal to the period. Notes: If "mode" - * is "challenge", "managed_challenge", or "js_challenge", Cloudflare will use the - * zone's Challenge Passage time and you should not provide this value. - */ - timeout?: number; - } - - export namespace Action { - /** - * A custom content type and reponse to return when the threshold is exceeded. The - * custom response configured in this object will override the custom error for the - * zone. This object is optional. Notes: If you omit this object, Cloudflare will - * use the default HTML error page. If "mode" is "challenge", "managed_challenge", - * or "js_challenge", Cloudflare will use the zone challenge pages and you should - * not provide the "response" object. - */ - export interface Response { - /** - * The response body to return. The value must conform to the configured content - * type. - */ - body?: string; - - /** - * The content type of the body. Must be one of the following: `text/plain`, - * `text/xml`, or `application/json`. - */ - content_type?: string; - } - } - - /** - * Determines which traffic the rate limit counts towards the threshold. - */ - export interface Match { - headers?: Array; - - request?: Match.Request; - - response?: Match.Response; - } - - export namespace Match { - export interface Header { - /** - * The name of the response header to match. - */ - name?: string; - - /** - * The operator used when matching: `eq` means "equal" and `ne` means "not equal". - */ - op?: 'eq' | 'ne'; - - /** - * The value of the response header, which must match exactly. - */ - value?: string; - } - - export interface Request { - /** - * The HTTP methods to match. You can specify a subset (for example, - * `['POST','PUT']`) or all methods (`['_ALL_']`). This field is optional when - * creating a rate limit. - */ - methods?: Array; - - /** - * The HTTP schemes to match. You can specify one scheme (`['HTTPS']`), both - * schemes (`['HTTP','HTTPS']`), or all schemes (`['_ALL_']`). This field is - * optional. - */ - schemes?: Array; - - /** - * The URL pattern to match, composed of a host and a path such as - * `example.org/path*`. Normalization is applied before the pattern is matched. `*` - * wildcards are expanded to match applicable traffic. Query strings are not - * matched. Set the value to `*` to match all traffic to your zone. - */ - url?: string; - } - - export interface Response { - /** - * When true, only the uncached traffic served from your origin servers will count - * towards rate limiting. In this case, any cached traffic served by Cloudflare - * will not count towards rate limiting. This field is optional. Notes: This field - * is deprecated. Instead, use response headers and set "origin_traffic" to "false" - * to avoid legacy behaviour interacting with the "response_headers" property. - */ - origin_traffic?: boolean; - } - } -} - -export interface RateLimitGetParams { - /** - * Identifier - */ - zone_id: string; -} diff --git a/tests/api-resources/filters.test.ts b/tests/api-resources/filters.test.ts deleted file mode 100644 index 8da6641e4d..0000000000 --- a/tests/api-resources/filters.test.ts +++ /dev/null @@ -1,122 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -import Cloudflare from 'cloudflare'; -import { Response } from 'node-fetch'; - -const client = new Cloudflare({ - apiKey: '144c9defac04969c7bfad8efaa8ea194', - apiEmail: 'user@example.com', - baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', -}); - -describe('resource filters', () => { - // TODO: investigate broken test - test.skip('create: only required params', async () => { - const responsePromise = client.filters.create({ - zone_id: '023e105f4ecef8ad9ca31a8372d0c353', - expression: - '(http.request.uri.path ~ ".*wp-login.php" or http.request.uri.path ~ ".*xmlrpc.php") and ip.addr ne 172.16.22.155', - }); - const rawResponse = await responsePromise.asResponse(); - expect(rawResponse).toBeInstanceOf(Response); - const response = await responsePromise; - expect(response).not.toBeInstanceOf(Response); - const dataAndResponse = await responsePromise.withResponse(); - expect(dataAndResponse.data).toBe(response); - expect(dataAndResponse.response).toBe(rawResponse); - }); - - // TODO: investigate broken test - test.skip('create: required and optional params', async () => { - const response = await client.filters.create({ - zone_id: '023e105f4ecef8ad9ca31a8372d0c353', - expression: - '(http.request.uri.path ~ ".*wp-login.php" or http.request.uri.path ~ ".*xmlrpc.php") and ip.addr ne 172.16.22.155', - }); - }); - - // TODO: investigate broken test - test.skip('update: only required params', async () => { - const responsePromise = client.filters.update('372e67954025e0ba6aaa6d586b9e0b61', { - zone_id: '023e105f4ecef8ad9ca31a8372d0c353', - body: {}, - }); - const rawResponse = await responsePromise.asResponse(); - expect(rawResponse).toBeInstanceOf(Response); - const response = await responsePromise; - expect(response).not.toBeInstanceOf(Response); - const dataAndResponse = await responsePromise.withResponse(); - expect(dataAndResponse.data).toBe(response); - expect(dataAndResponse.response).toBe(rawResponse); - }); - - // TODO: investigate broken test - test.skip('update: required and optional params', async () => { - const response = await client.filters.update('372e67954025e0ba6aaa6d586b9e0b61', { - zone_id: '023e105f4ecef8ad9ca31a8372d0c353', - body: {}, - }); - }); - - test('list: only required params', async () => { - const responsePromise = client.filters.list({ zone_id: '023e105f4ecef8ad9ca31a8372d0c353' }); - const rawResponse = await responsePromise.asResponse(); - expect(rawResponse).toBeInstanceOf(Response); - const response = await responsePromise; - expect(response).not.toBeInstanceOf(Response); - const dataAndResponse = await responsePromise.withResponse(); - expect(dataAndResponse.data).toBe(response); - expect(dataAndResponse.response).toBe(rawResponse); - }); - - test('list: required and optional params', async () => { - const response = await client.filters.list({ - zone_id: '023e105f4ecef8ad9ca31a8372d0c353', - id: '372e67954025e0ba6aaa6d586b9e0b61', - description: 'browsers', - expression: 'php', - page: 1, - paused: false, - per_page: 5, - ref: 'FIL-100', - }); - }); - - test('delete: only required params', async () => { - const responsePromise = client.filters.delete('372e67954025e0ba6aaa6d586b9e0b61', { - zone_id: '023e105f4ecef8ad9ca31a8372d0c353', - }); - const rawResponse = await responsePromise.asResponse(); - expect(rawResponse).toBeInstanceOf(Response); - const response = await responsePromise; - expect(response).not.toBeInstanceOf(Response); - const dataAndResponse = await responsePromise.withResponse(); - expect(dataAndResponse.data).toBe(response); - expect(dataAndResponse.response).toBe(rawResponse); - }); - - test('delete: required and optional params', async () => { - const response = await client.filters.delete('372e67954025e0ba6aaa6d586b9e0b61', { - zone_id: '023e105f4ecef8ad9ca31a8372d0c353', - }); - }); - - test('get: only required params', async () => { - const responsePromise = client.filters.get('372e67954025e0ba6aaa6d586b9e0b61', { - zone_id: '023e105f4ecef8ad9ca31a8372d0c353', - }); - const rawResponse = await responsePromise.asResponse(); - expect(rawResponse).toBeInstanceOf(Response); - const response = await responsePromise; - expect(response).not.toBeInstanceOf(Response); - const dataAndResponse = await responsePromise.withResponse(); - expect(dataAndResponse.data).toBe(response); - expect(dataAndResponse.response).toBe(rawResponse); - }); - - test('get: required and optional params', async () => { - const response = await client.filters.get('372e67954025e0ba6aaa6d586b9e0b61', { - zone_id: '023e105f4ecef8ad9ca31a8372d0c353', - }); - }); -}); diff --git a/tests/api-resources/firewall/access-rules.test.ts b/tests/api-resources/firewall/access-rules.test.ts index d74b626157..cf1f23f825 100644 --- a/tests/api-resources/firewall/access-rules.test.ts +++ b/tests/api-resources/firewall/access-rules.test.ts @@ -47,58 +47,4 @@ describe('resource accessRules', () => { expect(dataAndResponse.data).toBe(response); expect(dataAndResponse.response).toBe(rawResponse); }); - - // TODO: investigate broken test - test.skip('delete', async () => { - const responsePromise = client.firewall.accessRules.delete('023e105f4ecef8ad9ca31a8372d0c353', { - account_id: 'account_id', - }); - const rawResponse = await responsePromise.asResponse(); - expect(rawResponse).toBeInstanceOf(Response); - const response = await responsePromise; - expect(response).not.toBeInstanceOf(Response); - const dataAndResponse = await responsePromise.withResponse(); - expect(dataAndResponse.data).toBe(response); - expect(dataAndResponse.response).toBe(rawResponse); - }); - - // TODO: investigate broken test - test.skip('edit: only required params', async () => { - const responsePromise = client.firewall.accessRules.edit('023e105f4ecef8ad9ca31a8372d0c353', { - configuration: {}, - mode: 'block', - account_id: 'account_id', - }); - const rawResponse = await responsePromise.asResponse(); - expect(rawResponse).toBeInstanceOf(Response); - const response = await responsePromise; - expect(response).not.toBeInstanceOf(Response); - const dataAndResponse = await responsePromise.withResponse(); - expect(dataAndResponse.data).toBe(response); - expect(dataAndResponse.response).toBe(rawResponse); - }); - - // TODO: investigate broken test - test.skip('edit: required and optional params', async () => { - const response = await client.firewall.accessRules.edit('023e105f4ecef8ad9ca31a8372d0c353', { - configuration: { target: 'ip', value: '198.51.100.4' }, - mode: 'block', - account_id: 'account_id', - notes: 'This rule is enabled because of an event that occurred on date X.', - }); - }); - - // TODO: investigate broken test - test.skip('get', async () => { - const responsePromise = client.firewall.accessRules.get('023e105f4ecef8ad9ca31a8372d0c353', { - account_id: 'account_id', - }); - const rawResponse = await responsePromise.asResponse(); - expect(rawResponse).toBeInstanceOf(Response); - const response = await responsePromise; - expect(response).not.toBeInstanceOf(Response); - const dataAndResponse = await responsePromise.withResponse(); - expect(dataAndResponse.data).toBe(response); - expect(dataAndResponse.response).toBe(rawResponse); - }); }); diff --git a/tests/api-resources/firewall/lockdowns.test.ts b/tests/api-resources/firewall/lockdowns.test.ts deleted file mode 100644 index 1ceeffa961..0000000000 --- a/tests/api-resources/firewall/lockdowns.test.ts +++ /dev/null @@ -1,136 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -import Cloudflare from 'cloudflare'; -import { Response } from 'node-fetch'; - -const client = new Cloudflare({ - apiKey: '144c9defac04969c7bfad8efaa8ea194', - apiEmail: 'user@example.com', - baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', -}); - -describe('resource lockdowns', () => { - // TODO: investigate broken test - test.skip('create: only required params', async () => { - const responsePromise = client.firewall.lockdowns.create({ - zone_id: '023e105f4ecef8ad9ca31a8372d0c353', - configurations: [{}, {}, {}], - urls: ['shop.example.com/*', 'shop.example.com/*', 'shop.example.com/*'], - }); - const rawResponse = await responsePromise.asResponse(); - expect(rawResponse).toBeInstanceOf(Response); - const response = await responsePromise; - expect(response).not.toBeInstanceOf(Response); - const dataAndResponse = await responsePromise.withResponse(); - expect(dataAndResponse.data).toBe(response); - expect(dataAndResponse.response).toBe(rawResponse); - }); - - // TODO: investigate broken test - test.skip('create: required and optional params', async () => { - const response = await client.firewall.lockdowns.create({ - zone_id: '023e105f4ecef8ad9ca31a8372d0c353', - configurations: [ - { target: 'ip', value: '198.51.100.4' }, - { target: 'ip', value: '198.51.100.4' }, - { target: 'ip', value: '198.51.100.4' }, - ], - urls: ['shop.example.com/*', 'shop.example.com/*', 'shop.example.com/*'], - }); - }); - - // TODO: investigate broken test - test.skip('update: only required params', async () => { - const responsePromise = client.firewall.lockdowns.update('372e67954025e0ba6aaa6d586b9e0b59', { - zone_id: '023e105f4ecef8ad9ca31a8372d0c353', - configurations: [{}, {}, {}], - urls: ['shop.example.com/*', 'shop.example.com/*', 'shop.example.com/*'], - }); - const rawResponse = await responsePromise.asResponse(); - expect(rawResponse).toBeInstanceOf(Response); - const response = await responsePromise; - expect(response).not.toBeInstanceOf(Response); - const dataAndResponse = await responsePromise.withResponse(); - expect(dataAndResponse.data).toBe(response); - expect(dataAndResponse.response).toBe(rawResponse); - }); - - // TODO: investigate broken test - test.skip('update: required and optional params', async () => { - const response = await client.firewall.lockdowns.update('372e67954025e0ba6aaa6d586b9e0b59', { - zone_id: '023e105f4ecef8ad9ca31a8372d0c353', - configurations: [ - { target: 'ip', value: '198.51.100.4' }, - { target: 'ip', value: '198.51.100.4' }, - { target: 'ip', value: '198.51.100.4' }, - ], - urls: ['shop.example.com/*', 'shop.example.com/*', 'shop.example.com/*'], - }); - }); - - test('list: only required params', async () => { - const responsePromise = client.firewall.lockdowns.list({ zone_id: '023e105f4ecef8ad9ca31a8372d0c353' }); - const rawResponse = await responsePromise.asResponse(); - expect(rawResponse).toBeInstanceOf(Response); - const response = await responsePromise; - expect(response).not.toBeInstanceOf(Response); - const dataAndResponse = await responsePromise.withResponse(); - expect(dataAndResponse.data).toBe(response); - expect(dataAndResponse.response).toBe(rawResponse); - }); - - test('list: required and optional params', async () => { - const response = await client.firewall.lockdowns.list({ - zone_id: '023e105f4ecef8ad9ca31a8372d0c353', - created_on: '2014-01-01T05:20:00.12345Z', - description: 'endpoints', - description_search: 'endpoints', - ip: '1.2.3.4', - ip_range_search: '1.2.3.0/16', - ip_search: '1.2.3.4', - modified_on: '2014-01-01T05:20:00.12345Z', - page: 1, - per_page: 1, - priority: 5, - uri_search: '/some/path', - }); - }); - - test('delete: only required params', async () => { - const responsePromise = client.firewall.lockdowns.delete('372e67954025e0ba6aaa6d586b9e0b59', { - zone_id: '023e105f4ecef8ad9ca31a8372d0c353', - }); - const rawResponse = await responsePromise.asResponse(); - expect(rawResponse).toBeInstanceOf(Response); - const response = await responsePromise; - expect(response).not.toBeInstanceOf(Response); - const dataAndResponse = await responsePromise.withResponse(); - expect(dataAndResponse.data).toBe(response); - expect(dataAndResponse.response).toBe(rawResponse); - }); - - test('delete: required and optional params', async () => { - const response = await client.firewall.lockdowns.delete('372e67954025e0ba6aaa6d586b9e0b59', { - zone_id: '023e105f4ecef8ad9ca31a8372d0c353', - }); - }); - - test('get: only required params', async () => { - const responsePromise = client.firewall.lockdowns.get('372e67954025e0ba6aaa6d586b9e0b59', { - zone_id: '023e105f4ecef8ad9ca31a8372d0c353', - }); - const rawResponse = await responsePromise.asResponse(); - expect(rawResponse).toBeInstanceOf(Response); - const response = await responsePromise; - expect(response).not.toBeInstanceOf(Response); - const dataAndResponse = await responsePromise.withResponse(); - expect(dataAndResponse.data).toBe(response); - expect(dataAndResponse.response).toBe(rawResponse); - }); - - test('get: required and optional params', async () => { - const response = await client.firewall.lockdowns.get('372e67954025e0ba6aaa6d586b9e0b59', { - zone_id: '023e105f4ecef8ad9ca31a8372d0c353', - }); - }); -}); diff --git a/tests/api-resources/firewall/rules.test.ts b/tests/api-resources/firewall/rules.test.ts deleted file mode 100644 index 8e31e2aeeb..0000000000 --- a/tests/api-resources/firewall/rules.test.ts +++ /dev/null @@ -1,165 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -import Cloudflare from 'cloudflare'; -import { Response } from 'node-fetch'; - -const client = new Cloudflare({ - apiKey: '144c9defac04969c7bfad8efaa8ea194', - apiEmail: 'user@example.com', - baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', -}); - -describe('resource rules', () => { - // TODO: investigate broken test - test.skip('create: only required params', async () => { - const responsePromise = client.firewall.rules.create({ - zone_id: '023e105f4ecef8ad9ca31a8372d0c353', - action: {}, - filter: {}, - }); - const rawResponse = await responsePromise.asResponse(); - expect(rawResponse).toBeInstanceOf(Response); - const response = await responsePromise; - expect(response).not.toBeInstanceOf(Response); - const dataAndResponse = await responsePromise.withResponse(); - expect(dataAndResponse.data).toBe(response); - expect(dataAndResponse.response).toBe(rawResponse); - }); - - // TODO: investigate broken test - test.skip('create: required and optional params', async () => { - const response = await client.firewall.rules.create({ - zone_id: '023e105f4ecef8ad9ca31a8372d0c353', - action: { - mode: 'simulate', - response: { body: 'This request has been rate-limited.', content_type: 'text/xml' }, - timeout: 86400, - }, - filter: { - description: 'Restrict access from these browsers on this address range.', - expression: - '(http.request.uri.path ~ ".*wp-login.php" or http.request.uri.path ~ ".*xmlrpc.php") and ip.addr ne 172.16.22.155', - paused: false, - ref: 'FIL-100', - }, - }); - }); - - // TODO: investigate broken test - test.skip('update: only required params', async () => { - const responsePromise = client.firewall.rules.update('372e67954025e0ba6aaa6d586b9e0b60', { - zone_id: '023e105f4ecef8ad9ca31a8372d0c353', - action: {}, - filter: {}, - }); - const rawResponse = await responsePromise.asResponse(); - expect(rawResponse).toBeInstanceOf(Response); - const response = await responsePromise; - expect(response).not.toBeInstanceOf(Response); - const dataAndResponse = await responsePromise.withResponse(); - expect(dataAndResponse.data).toBe(response); - expect(dataAndResponse.response).toBe(rawResponse); - }); - - // TODO: investigate broken test - test.skip('update: required and optional params', async () => { - const response = await client.firewall.rules.update('372e67954025e0ba6aaa6d586b9e0b60', { - zone_id: '023e105f4ecef8ad9ca31a8372d0c353', - action: { - mode: 'simulate', - response: { body: 'This request has been rate-limited.', content_type: 'text/xml' }, - timeout: 86400, - }, - filter: { - description: 'Restrict access from these browsers on this address range.', - expression: - '(http.request.uri.path ~ ".*wp-login.php" or http.request.uri.path ~ ".*xmlrpc.php") and ip.addr ne 172.16.22.155', - paused: false, - ref: 'FIL-100', - }, - }); - }); - - test('list: only required params', async () => { - const responsePromise = client.firewall.rules.list({ zone_id: '023e105f4ecef8ad9ca31a8372d0c353' }); - const rawResponse = await responsePromise.asResponse(); - expect(rawResponse).toBeInstanceOf(Response); - const response = await responsePromise; - expect(response).not.toBeInstanceOf(Response); - const dataAndResponse = await responsePromise.withResponse(); - expect(dataAndResponse.data).toBe(response); - expect(dataAndResponse.response).toBe(rawResponse); - }); - - test('list: required and optional params', async () => { - const response = await client.firewall.rules.list({ - zone_id: '023e105f4ecef8ad9ca31a8372d0c353', - id: '372e67954025e0ba6aaa6d586b9e0b60', - action: 'block', - description: 'mir', - page: 1, - paused: false, - per_page: 5, - }); - }); - - test('delete: only required params', async () => { - const responsePromise = client.firewall.rules.delete('372e67954025e0ba6aaa6d586b9e0b60', { - zone_id: '023e105f4ecef8ad9ca31a8372d0c353', - }); - const rawResponse = await responsePromise.asResponse(); - expect(rawResponse).toBeInstanceOf(Response); - const response = await responsePromise; - expect(response).not.toBeInstanceOf(Response); - const dataAndResponse = await responsePromise.withResponse(); - expect(dataAndResponse.data).toBe(response); - expect(dataAndResponse.response).toBe(rawResponse); - }); - - test('delete: required and optional params', async () => { - const response = await client.firewall.rules.delete('372e67954025e0ba6aaa6d586b9e0b60', { - zone_id: '023e105f4ecef8ad9ca31a8372d0c353', - }); - }); - - // TODO: investigate broken test - test.skip('edit: only required params', async () => { - const responsePromise = client.firewall.rules.edit('372e67954025e0ba6aaa6d586b9e0b60', { - zone_id: '023e105f4ecef8ad9ca31a8372d0c353', - }); - const rawResponse = await responsePromise.asResponse(); - expect(rawResponse).toBeInstanceOf(Response); - const response = await responsePromise; - expect(response).not.toBeInstanceOf(Response); - const dataAndResponse = await responsePromise.withResponse(); - expect(dataAndResponse.data).toBe(response); - expect(dataAndResponse.response).toBe(rawResponse); - }); - - // TODO: investigate broken test - test.skip('edit: required and optional params', async () => { - const response = await client.firewall.rules.edit('372e67954025e0ba6aaa6d586b9e0b60', { - zone_id: '023e105f4ecef8ad9ca31a8372d0c353', - }); - }); - - test('get: only required params', async () => { - const responsePromise = client.firewall.rules.get('372e67954025e0ba6aaa6d586b9e0b60', { - zone_id: '023e105f4ecef8ad9ca31a8372d0c353', - }); - const rawResponse = await responsePromise.asResponse(); - expect(rawResponse).toBeInstanceOf(Response); - const response = await responsePromise; - expect(response).not.toBeInstanceOf(Response); - const dataAndResponse = await responsePromise.withResponse(); - expect(dataAndResponse.data).toBe(response); - expect(dataAndResponse.response).toBe(rawResponse); - }); - - test('get: required and optional params', async () => { - const response = await client.firewall.rules.get('372e67954025e0ba6aaa6d586b9e0b60', { - zone_id: '023e105f4ecef8ad9ca31a8372d0c353', - id: '372e67954025e0ba6aaa6d586b9e0b60', - }); - }); -}); diff --git a/tests/api-resources/firewall/ua-rules.test.ts b/tests/api-resources/firewall/ua-rules.test.ts deleted file mode 100644 index 19ac730ea9..0000000000 --- a/tests/api-resources/firewall/ua-rules.test.ts +++ /dev/null @@ -1,122 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -import Cloudflare from 'cloudflare'; -import { Response } from 'node-fetch'; - -const client = new Cloudflare({ - apiKey: '144c9defac04969c7bfad8efaa8ea194', - apiEmail: 'user@example.com', - baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', -}); - -describe('resource uaRules', () => { - // TODO: investigate broken test - test.skip('create: only required params', async () => { - const responsePromise = client.firewall.uaRules.create({ - zone_id: '023e105f4ecef8ad9ca31a8372d0c353', - configuration: {}, - mode: 'block', - }); - const rawResponse = await responsePromise.asResponse(); - expect(rawResponse).toBeInstanceOf(Response); - const response = await responsePromise; - expect(response).not.toBeInstanceOf(Response); - const dataAndResponse = await responsePromise.withResponse(); - expect(dataAndResponse.data).toBe(response); - expect(dataAndResponse.response).toBe(rawResponse); - }); - - // TODO: investigate broken test - test.skip('create: required and optional params', async () => { - const response = await client.firewall.uaRules.create({ - zone_id: '023e105f4ecef8ad9ca31a8372d0c353', - configuration: { target: 'ip', value: '198.51.100.4' }, - mode: 'block', - }); - }); - - // TODO: investigate broken test - test.skip('update: only required params', async () => { - const responsePromise = client.firewall.uaRules.update('372e67954025e0ba6aaa6d586b9e0b59', { - zone_id: '023e105f4ecef8ad9ca31a8372d0c353', - configuration: {}, - mode: 'block', - }); - const rawResponse = await responsePromise.asResponse(); - expect(rawResponse).toBeInstanceOf(Response); - const response = await responsePromise; - expect(response).not.toBeInstanceOf(Response); - const dataAndResponse = await responsePromise.withResponse(); - expect(dataAndResponse.data).toBe(response); - expect(dataAndResponse.response).toBe(rawResponse); - }); - - // TODO: investigate broken test - test.skip('update: required and optional params', async () => { - const response = await client.firewall.uaRules.update('372e67954025e0ba6aaa6d586b9e0b59', { - zone_id: '023e105f4ecef8ad9ca31a8372d0c353', - configuration: { target: 'ip', value: '198.51.100.4' }, - mode: 'block', - }); - }); - - test('list: only required params', async () => { - const responsePromise = client.firewall.uaRules.list({ zone_id: '023e105f4ecef8ad9ca31a8372d0c353' }); - const rawResponse = await responsePromise.asResponse(); - expect(rawResponse).toBeInstanceOf(Response); - const response = await responsePromise; - expect(response).not.toBeInstanceOf(Response); - const dataAndResponse = await responsePromise.withResponse(); - expect(dataAndResponse.data).toBe(response); - expect(dataAndResponse.response).toBe(rawResponse); - }); - - test('list: required and optional params', async () => { - const response = await client.firewall.uaRules.list({ - zone_id: '023e105f4ecef8ad9ca31a8372d0c353', - description: 'abusive', - description_search: 'abusive', - page: 1, - per_page: 1, - ua_search: 'Safari', - }); - }); - - test('delete: only required params', async () => { - const responsePromise = client.firewall.uaRules.delete('372e67954025e0ba6aaa6d586b9e0b59', { - zone_id: '023e105f4ecef8ad9ca31a8372d0c353', - }); - const rawResponse = await responsePromise.asResponse(); - expect(rawResponse).toBeInstanceOf(Response); - const response = await responsePromise; - expect(response).not.toBeInstanceOf(Response); - const dataAndResponse = await responsePromise.withResponse(); - expect(dataAndResponse.data).toBe(response); - expect(dataAndResponse.response).toBe(rawResponse); - }); - - test('delete: required and optional params', async () => { - const response = await client.firewall.uaRules.delete('372e67954025e0ba6aaa6d586b9e0b59', { - zone_id: '023e105f4ecef8ad9ca31a8372d0c353', - }); - }); - - test('get: only required params', async () => { - const responsePromise = client.firewall.uaRules.get('372e67954025e0ba6aaa6d586b9e0b59', { - zone_id: '023e105f4ecef8ad9ca31a8372d0c353', - }); - const rawResponse = await responsePromise.asResponse(); - expect(rawResponse).toBeInstanceOf(Response); - const response = await responsePromise; - expect(response).not.toBeInstanceOf(Response); - const dataAndResponse = await responsePromise.withResponse(); - expect(dataAndResponse.data).toBe(response); - expect(dataAndResponse.response).toBe(rawResponse); - }); - - test('get: required and optional params', async () => { - const response = await client.firewall.uaRules.get('372e67954025e0ba6aaa6d586b9e0b59', { - zone_id: '023e105f4ecef8ad9ca31a8372d0c353', - }); - }); -}); diff --git a/tests/api-resources/firewall/waf/overrides.test.ts b/tests/api-resources/firewall/waf/overrides.test.ts deleted file mode 100644 index ebfcc5a1c3..0000000000 --- a/tests/api-resources/firewall/waf/overrides.test.ts +++ /dev/null @@ -1,129 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -import Cloudflare from 'cloudflare'; -import { Response } from 'node-fetch'; - -const client = new Cloudflare({ - apiKey: '144c9defac04969c7bfad8efaa8ea194', - apiEmail: 'user@example.com', - baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', -}); - -describe('resource overrides', () => { - // TODO: investigate broken test - test.skip('create: only required params', async () => { - const responsePromise = client.firewall.waf.overrides.create({ - zone_id: '023e105f4ecef8ad9ca31a8372d0c353', - urls: ['shop.example.com/*', 'shop.example.com/*', 'shop.example.com/*'], - }); - const rawResponse = await responsePromise.asResponse(); - expect(rawResponse).toBeInstanceOf(Response); - const response = await responsePromise; - expect(response).not.toBeInstanceOf(Response); - const dataAndResponse = await responsePromise.withResponse(); - expect(dataAndResponse.data).toBe(response); - expect(dataAndResponse.response).toBe(rawResponse); - }); - - // TODO: investigate broken test - test.skip('create: required and optional params', async () => { - const response = await client.firewall.waf.overrides.create({ - zone_id: '023e105f4ecef8ad9ca31a8372d0c353', - urls: ['shop.example.com/*', 'shop.example.com/*', 'shop.example.com/*'], - }); - }); - - // TODO: investigate broken test - test.skip('update: only required params', async () => { - const responsePromise = client.firewall.waf.overrides.update('de677e5818985db1285d0e80225f06e5', { - zone_id: '023e105f4ecef8ad9ca31a8372d0c353', - id: '023e105f4ecef8ad9ca31a8372d0c353', - rewrite_action: {}, - rules: { '100015': 'challenge' }, - urls: ['shop.example.com/*', 'shop.example.com/*', 'shop.example.com/*'], - }); - const rawResponse = await responsePromise.asResponse(); - expect(rawResponse).toBeInstanceOf(Response); - const response = await responsePromise; - expect(response).not.toBeInstanceOf(Response); - const dataAndResponse = await responsePromise.withResponse(); - expect(dataAndResponse.data).toBe(response); - expect(dataAndResponse.response).toBe(rawResponse); - }); - - // TODO: investigate broken test - test.skip('update: required and optional params', async () => { - const response = await client.firewall.waf.overrides.update('de677e5818985db1285d0e80225f06e5', { - zone_id: '023e105f4ecef8ad9ca31a8372d0c353', - id: '023e105f4ecef8ad9ca31a8372d0c353', - rewrite_action: { - block: 'challenge', - challenge: 'challenge', - default: 'challenge', - disable: 'challenge', - simulate: 'challenge', - }, - rules: { '100015': 'challenge' }, - urls: ['shop.example.com/*', 'shop.example.com/*', 'shop.example.com/*'], - }); - }); - - test('list: only required params', async () => { - const responsePromise = client.firewall.waf.overrides.list({ - zone_id: '023e105f4ecef8ad9ca31a8372d0c353', - }); - const rawResponse = await responsePromise.asResponse(); - expect(rawResponse).toBeInstanceOf(Response); - const response = await responsePromise; - expect(response).not.toBeInstanceOf(Response); - const dataAndResponse = await responsePromise.withResponse(); - expect(dataAndResponse.data).toBe(response); - expect(dataAndResponse.response).toBe(rawResponse); - }); - - test('list: required and optional params', async () => { - const response = await client.firewall.waf.overrides.list({ - zone_id: '023e105f4ecef8ad9ca31a8372d0c353', - page: 1, - per_page: 5, - }); - }); - - test('delete: only required params', async () => { - const responsePromise = client.firewall.waf.overrides.delete('de677e5818985db1285d0e80225f06e5', { - zone_id: '023e105f4ecef8ad9ca31a8372d0c353', - }); - const rawResponse = await responsePromise.asResponse(); - expect(rawResponse).toBeInstanceOf(Response); - const response = await responsePromise; - expect(response).not.toBeInstanceOf(Response); - const dataAndResponse = await responsePromise.withResponse(); - expect(dataAndResponse.data).toBe(response); - expect(dataAndResponse.response).toBe(rawResponse); - }); - - test('delete: required and optional params', async () => { - const response = await client.firewall.waf.overrides.delete('de677e5818985db1285d0e80225f06e5', { - zone_id: '023e105f4ecef8ad9ca31a8372d0c353', - }); - }); - - test('get: only required params', async () => { - const responsePromise = client.firewall.waf.overrides.get('de677e5818985db1285d0e80225f06e5', { - zone_id: '023e105f4ecef8ad9ca31a8372d0c353', - }); - const rawResponse = await responsePromise.asResponse(); - expect(rawResponse).toBeInstanceOf(Response); - const response = await responsePromise; - expect(response).not.toBeInstanceOf(Response); - const dataAndResponse = await responsePromise.withResponse(); - expect(dataAndResponse.data).toBe(response); - expect(dataAndResponse.response).toBe(rawResponse); - }); - - test('get: required and optional params', async () => { - const response = await client.firewall.waf.overrides.get('de677e5818985db1285d0e80225f06e5', { - zone_id: '023e105f4ecef8ad9ca31a8372d0c353', - }); - }); -}); diff --git a/tests/api-resources/firewall/waf/packages/packages.test.ts b/tests/api-resources/firewall/waf/packages/packages.test.ts deleted file mode 100644 index 635987a357..0000000000 --- a/tests/api-resources/firewall/waf/packages/packages.test.ts +++ /dev/null @@ -1,58 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -import Cloudflare from 'cloudflare'; -import { Response } from 'node-fetch'; - -const client = new Cloudflare({ - apiKey: '144c9defac04969c7bfad8efaa8ea194', - apiEmail: 'user@example.com', - baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', -}); - -describe('resource packages', () => { - // TODO: investigate broken test - test.skip('list: only required params', async () => { - const responsePromise = client.firewall.waf.packages.list({ - zone_id: '023e105f4ecef8ad9ca31a8372d0c353', - }); - const rawResponse = await responsePromise.asResponse(); - expect(rawResponse).toBeInstanceOf(Response); - const response = await responsePromise; - expect(response).not.toBeInstanceOf(Response); - const dataAndResponse = await responsePromise.withResponse(); - expect(dataAndResponse.data).toBe(response); - expect(dataAndResponse.response).toBe(rawResponse); - }); - - // TODO: investigate broken test - test.skip('list: required and optional params', async () => { - const response = await client.firewall.waf.packages.list({ - zone_id: '023e105f4ecef8ad9ca31a8372d0c353', - direction: 'asc', - match: 'any', - name: 'USER', - order: 'name', - page: 1, - per_page: 5, - }); - }); - - test('get: only required params', async () => { - const responsePromise = client.firewall.waf.packages.get('023e105f4ecef8ad9ca31a8372d0c353', { - zone_id: '023e105f4ecef8ad9ca31a8372d0c353', - }); - const rawResponse = await responsePromise.asResponse(); - expect(rawResponse).toBeInstanceOf(Response); - const response = await responsePromise; - expect(response).not.toBeInstanceOf(Response); - const dataAndResponse = await responsePromise.withResponse(); - expect(dataAndResponse.data).toBe(response); - expect(dataAndResponse.response).toBe(rawResponse); - }); - - test('get: required and optional params', async () => { - const response = await client.firewall.waf.packages.get('023e105f4ecef8ad9ca31a8372d0c353', { - zone_id: '023e105f4ecef8ad9ca31a8372d0c353', - }); - }); -}); diff --git a/tests/api-resources/rate-limits.test.ts b/tests/api-resources/rate-limits.test.ts deleted file mode 100644 index a2bf00d006..0000000000 --- a/tests/api-resources/rate-limits.test.ts +++ /dev/null @@ -1,151 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -import Cloudflare from 'cloudflare'; -import { Response } from 'node-fetch'; - -const client = new Cloudflare({ - apiKey: '144c9defac04969c7bfad8efaa8ea194', - apiEmail: 'user@example.com', - baseURL: process.env['TEST_API_BASE_URL'] ?? 'http://127.0.0.1:4010', -}); - -describe('resource rateLimits', () => { - // TODO: investigate broken test - test.skip('create: only required params', async () => { - const responsePromise = client.rateLimits.create({ - zone_id: '023e105f4ecef8ad9ca31a8372d0c353', - action: {}, - match: {}, - period: 900, - threshold: 60, - }); - const rawResponse = await responsePromise.asResponse(); - expect(rawResponse).toBeInstanceOf(Response); - const response = await responsePromise; - expect(response).not.toBeInstanceOf(Response); - const dataAndResponse = await responsePromise.withResponse(); - expect(dataAndResponse.data).toBe(response); - expect(dataAndResponse.response).toBe(rawResponse); - }); - - // TODO: investigate broken test - test.skip('create: required and optional params', async () => { - const response = await client.rateLimits.create({ - zone_id: '023e105f4ecef8ad9ca31a8372d0c353', - action: { - mode: 'simulate', - response: { body: 'This request has been rate-limited.', content_type: 'text/xml' }, - timeout: 86400, - }, - match: { - headers: [ - { name: 'Cf-Cache-Status', op: 'eq', value: 'HIT' }, - { name: 'Cf-Cache-Status', op: 'eq', value: 'HIT' }, - { name: 'Cf-Cache-Status', op: 'eq', value: 'HIT' }, - ], - request: { methods: ['GET', 'POST'], schemes: ['HTTP', 'HTTPS'], url: '*.example.org/path*' }, - response: { origin_traffic: true }, - }, - period: 900, - threshold: 60, - }); - }); - - test('list: only required params', async () => { - const responsePromise = client.rateLimits.list({ zone_id: '023e105f4ecef8ad9ca31a8372d0c353' }); - const rawResponse = await responsePromise.asResponse(); - expect(rawResponse).toBeInstanceOf(Response); - const response = await responsePromise; - expect(response).not.toBeInstanceOf(Response); - const dataAndResponse = await responsePromise.withResponse(); - expect(dataAndResponse.data).toBe(response); - expect(dataAndResponse.response).toBe(rawResponse); - }); - - test('list: required and optional params', async () => { - const response = await client.rateLimits.list({ - zone_id: '023e105f4ecef8ad9ca31a8372d0c353', - page: 1, - per_page: 1, - }); - }); - - test('delete: only required params', async () => { - const responsePromise = client.rateLimits.delete('372e67954025e0ba6aaa6d586b9e0b59', { - zone_id: '023e105f4ecef8ad9ca31a8372d0c353', - }); - const rawResponse = await responsePromise.asResponse(); - expect(rawResponse).toBeInstanceOf(Response); - const response = await responsePromise; - expect(response).not.toBeInstanceOf(Response); - const dataAndResponse = await responsePromise.withResponse(); - expect(dataAndResponse.data).toBe(response); - expect(dataAndResponse.response).toBe(rawResponse); - }); - - test('delete: required and optional params', async () => { - const response = await client.rateLimits.delete('372e67954025e0ba6aaa6d586b9e0b59', { - zone_id: '023e105f4ecef8ad9ca31a8372d0c353', - }); - }); - - // TODO: investigate broken test - test.skip('edit: only required params', async () => { - const responsePromise = client.rateLimits.edit('372e67954025e0ba6aaa6d586b9e0b59', { - zone_id: '023e105f4ecef8ad9ca31a8372d0c353', - action: {}, - match: {}, - period: 900, - threshold: 60, - }); - const rawResponse = await responsePromise.asResponse(); - expect(rawResponse).toBeInstanceOf(Response); - const response = await responsePromise; - expect(response).not.toBeInstanceOf(Response); - const dataAndResponse = await responsePromise.withResponse(); - expect(dataAndResponse.data).toBe(response); - expect(dataAndResponse.response).toBe(rawResponse); - }); - - // TODO: investigate broken test - test.skip('edit: required and optional params', async () => { - const response = await client.rateLimits.edit('372e67954025e0ba6aaa6d586b9e0b59', { - zone_id: '023e105f4ecef8ad9ca31a8372d0c353', - action: { - mode: 'simulate', - response: { body: 'This request has been rate-limited.', content_type: 'text/xml' }, - timeout: 86400, - }, - match: { - headers: [ - { name: 'Cf-Cache-Status', op: 'eq', value: 'HIT' }, - { name: 'Cf-Cache-Status', op: 'eq', value: 'HIT' }, - { name: 'Cf-Cache-Status', op: 'eq', value: 'HIT' }, - ], - request: { methods: ['GET', 'POST'], schemes: ['HTTP', 'HTTPS'], url: '*.example.org/path*' }, - response: { origin_traffic: true }, - }, - period: 900, - threshold: 60, - }); - }); - - test('get: only required params', async () => { - const responsePromise = client.rateLimits.get('372e67954025e0ba6aaa6d586b9e0b59', { - zone_id: '023e105f4ecef8ad9ca31a8372d0c353', - }); - const rawResponse = await responsePromise.asResponse(); - expect(rawResponse).toBeInstanceOf(Response); - const response = await responsePromise; - expect(response).not.toBeInstanceOf(Response); - const dataAndResponse = await responsePromise.withResponse(); - expect(dataAndResponse.data).toBe(response); - expect(dataAndResponse.response).toBe(rawResponse); - }); - - test('get: required and optional params', async () => { - const response = await client.rateLimits.get('372e67954025e0ba6aaa6d586b9e0b59', { - zone_id: '023e105f4ecef8ad9ca31a8372d0c353', - }); - }); -});