diff --git a/api.md b/api.md index 51164b176c..46562dd343 100644 --- a/api.md +++ b/api.md @@ -151,17 +151,15 @@ Methods: Types: -- AccessRuleCreateResponse -- AccessRuleListResponse +- FirewallRule - AccessRuleDeleteResponse -- AccessRuleEditResponse Methods: -- client.user.firewall.accessRules.create({ ...params }) -> AccessRuleCreateResponse -- client.user.firewall.accessRules.list({ ...params }) -> AccessRuleListResponsesV4PagePaginationArray +- client.user.firewall.accessRules.create({ ...params }) -> FirewallRule +- client.user.firewall.accessRules.list({ ...params }) -> FirewallRulesV4PagePaginationArray - client.user.firewall.accessRules.delete(identifier, { ...params }) -> AccessRuleDeleteResponse -- client.user.firewall.accessRules.edit(identifier, { ...params }) -> AccessRuleEditResponse +- client.user.firewall.accessRules.edit(identifier, { ...params }) -> FirewallRule ## Invites @@ -1339,6 +1337,7 @@ Methods: Types: - CustomHostname +- CustomMetadata - UnnamedSchemaRef16aca57bde2963201c7e6e895436c1c1 - UnnamedSchemaRef78adb375f06c6d462dd92b99e2ecf510 - UnnamedSchemaRef9a9935a9a770967bb604ae41a81e42e1 @@ -1569,19 +1568,16 @@ Methods: Types: +- Filter - FilterCreateResponse -- FilterUpdateResponse -- FilterListResponse -- FilterDeleteResponse -- FilterGetResponse Methods: - client.filters.create(zoneIdentifier, { ...params }) -> FilterCreateResponse | null -- client.filters.update(zoneIdentifier, id, { ...params }) -> FilterUpdateResponse -- client.filters.list(zoneIdentifier, { ...params }) -> FilterListResponsesV4PagePaginationArray -- client.filters.delete(zoneIdentifier, id, { ...params }) -> FilterDeleteResponse -- client.filters.get(zoneIdentifier, id) -> FilterGetResponse +- client.filters.update(zoneIdentifier, id, { ...params }) -> Filter +- client.filters.list(zoneIdentifier, { ...params }) -> FiltersV4PagePaginationArray +- client.filters.delete(zoneIdentifier, id, { ...params }) -> Filter +- client.filters.get(zoneIdentifier, id) -> Filter # Firewall @@ -1627,6 +1623,11 @@ Methods: Types: +- ASNConfiguration +- CIDRConfiguration +- CountryConfiguration +- IPConfiguration +- IPV6Configuration - AccessRuleListResponse - AccessRuleDeleteResponse @@ -1701,6 +1702,7 @@ Methods: Types: +- AllowedModesAnomaly - Rule - UnnamedSchemaRef532d8b97684c9032dd36bae8acddebf5 - RuleEditResponse @@ -1976,13 +1978,15 @@ Methods: Types: -- RateLimitListResponse +- Action +- Methods +- RateLimit - RateLimitDeleteResponse Methods: - client.rateLimits.create(zoneIdentifier, { ...params }) -> UnnamedSchemaRef9444735ca60712dbcf8afd832eb5716a -- client.rateLimits.list(zoneIdentifier, { ...params }) -> RateLimitListResponsesV4PagePaginationArray +- client.rateLimits.list(zoneIdentifier, { ...params }) -> RateLimitsV4PagePaginationArray - client.rateLimits.delete(zoneIdentifier, id, { ...params }) -> RateLimitDeleteResponse - client.rateLimits.edit(zoneIdentifier, id, { ...params }) -> UnnamedSchemaRef9444735ca60712dbcf8afd832eb5716a - client.rateLimits.get(zoneIdentifier, id) -> UnnamedSchemaRef9444735ca60712dbcf8afd832eb5716a @@ -2130,21 +2134,16 @@ Types: - Event - UnnamedSchemaRef229c159575bc68a9c21f5a1615629cf6 -- EventCreateResponse -- EventUpdateResponse -- EventListResponse - EventDeleteResponse -- EventEditResponse -- EventGetResponse Methods: -- client.waitingRooms.events.create(waitingRoomId, { ...params }) -> EventCreateResponse -- client.waitingRooms.events.update(waitingRoomId, eventId, { ...params }) -> EventUpdateResponse -- client.waitingRooms.events.list(waitingRoomId, { ...params }) -> EventListResponsesSinglePage +- client.waitingRooms.events.create(waitingRoomId, { ...params }) -> Event +- client.waitingRooms.events.update(waitingRoomId, eventId, { ...params }) -> Event +- client.waitingRooms.events.list(waitingRoomId, { ...params }) -> EventsSinglePage - client.waitingRooms.events.delete(waitingRoomId, eventId, { ...params }) -> EventDeleteResponse -- client.waitingRooms.events.edit(waitingRoomId, eventId, { ...params }) -> EventEditResponse -- client.waitingRooms.events.get(waitingRoomId, eventId, { ...params }) -> EventGetResponse +- client.waitingRooms.events.edit(waitingRoomId, eventId, { ...params }) -> Event +- client.waitingRooms.events.get(waitingRoomId, eventId, { ...params }) -> Event ### Details @@ -2172,7 +2171,7 @@ Methods: - client.waitingRooms.rules.create(waitingRoomId, { ...params }) -> RuleCreateResponse | null - client.waitingRooms.rules.update(waitingRoomId, [ ...body ]) -> RuleUpdateResponse | null -- client.waitingRooms.rules.list(waitingRoomId, { ...params }) -> EventsSinglePage +- client.waitingRooms.rules.list(waitingRoomId, { ...params }) -> RulesSinglePage - client.waitingRooms.rules.delete(waitingRoomId, ruleId, { ...params }) -> RuleDeleteResponse | null - client.waitingRooms.rules.edit(waitingRoomId, ruleId, { ...params }) -> RuleEditResponse | null diff --git a/src/resources/custom-hostnames/custom-hostnames.ts b/src/resources/custom-hostnames/custom-hostnames.ts index e8bc41479b..798fb0c9ed 100644 --- a/src/resources/custom-hostnames/custom-hostnames.ts +++ b/src/resources/custom-hostnames/custom-hostnames.ts @@ -111,7 +111,7 @@ export interface CustomHostname { /** * These are per-hostname (customer) settings. */ - custom_metadata?: CustomHostname.CustomMetadata; + custom_metadata?: CustomMetadata; /** * a valid hostname that’s been added to your DNS zone as an A, AAAA, or CNAME @@ -177,16 +177,6 @@ export interface CustomHostname { } export namespace CustomHostname { - /** - * These are per-hostname (customer) settings. - */ - export interface CustomMetadata { - /** - * Unique metadata for this hostname. - */ - key?: string; - } - /** * This is a record which can be placed to activate a hostname. */ @@ -422,6 +412,16 @@ export namespace CustomHostname { } } +/** + * These are per-hostname (customer) settings. + */ +export interface CustomMetadata { + /** + * Unique metadata for this hostname. + */ + key?: string; +} + /** * A ubiquitous bundle has the highest probability of being verified everywhere, * even by clients using outdated or unusual trust stores. An optimal bundle uses @@ -465,7 +465,7 @@ export interface UnnamedSchemaRefD2a16d7ee1ad3a888dd5821c918d51fd { /** * These are per-hostname (customer) settings. */ - custom_metadata?: UnnamedSchemaRefD2a16d7ee1ad3a888dd5821c918d51fd.CustomMetadata; + custom_metadata?: CustomMetadata; /** * a valid hostname that’s been added to your DNS zone as an A, AAAA, or CNAME @@ -718,16 +718,6 @@ export namespace UnnamedSchemaRefD2a16d7ee1ad3a888dd5821c918d51fd { } } - /** - * These are per-hostname (customer) settings. - */ - export interface CustomMetadata { - /** - * Unique metadata for this hostname. - */ - key?: string; - } - /** * This is a record which can be placed to activate a hostname. */ @@ -785,7 +775,7 @@ export interface CustomHostnameCreateParams { /** * Body param: These are per-hostname (customer) settings. */ - custom_metadata?: CustomHostnameCreateParams.CustomMetadata; + custom_metadata?: CustomMetadata; } export namespace CustomHostnameCreateParams { @@ -870,16 +860,6 @@ export namespace CustomHostnameCreateParams { tls_1_3?: 'on' | 'off'; } } - - /** - * These are per-hostname (customer) settings. - */ - export interface CustomMetadata { - /** - * Unique metadata for this hostname. - */ - key?: string; - } } export interface CustomHostnameListParams extends V4PagePaginationArrayParams { @@ -938,7 +918,7 @@ export interface CustomHostnameEditParams { /** * Body param: These are per-hostname (customer) settings. */ - custom_metadata?: CustomHostnameEditParams.CustomMetadata; + custom_metadata?: CustomMetadata; /** * Body param: a valid hostname that’s been added to your DNS zone as an A, AAAA, @@ -962,16 +942,6 @@ export interface CustomHostnameEditParams { } export namespace CustomHostnameEditParams { - /** - * These are per-hostname (customer) settings. - */ - export interface CustomMetadata { - /** - * Unique metadata for this hostname. - */ - key?: string; - } - /** * SSL properties used when creating the custom hostname. */ diff --git a/src/resources/filters.ts b/src/resources/filters.ts index 44fa78b7ea..0a8f9200f7 100644 --- a/src/resources/filters.ts +++ b/src/resources/filters.ts @@ -29,10 +29,10 @@ export class Filters extends APIResource { id: string, body: FilterUpdateParams, options?: Core.RequestOptions, - ): Core.APIPromise { + ): Core.APIPromise { return ( this._client.put(`/zones/${zoneIdentifier}/filters/${id}`, { body, ...options }) as Core.APIPromise<{ - result: FilterUpdateResponse; + result: Filter; }> )._thenUnwrap((obj) => obj.result); } @@ -45,24 +45,23 @@ export class Filters extends APIResource { zoneIdentifier: string, query?: FilterListParams, options?: Core.RequestOptions, - ): Core.PagePromise; + ): Core.PagePromise; list( zoneIdentifier: string, options?: Core.RequestOptions, - ): Core.PagePromise; + ): Core.PagePromise; list( zoneIdentifier: string, query: FilterListParams | Core.RequestOptions = {}, options?: Core.RequestOptions, - ): Core.PagePromise { + ): Core.PagePromise { if (isRequestOptions(query)) { return this.list(zoneIdentifier, {}, query); } - return this._client.getAPIList( - `/zones/${zoneIdentifier}/filters`, - FilterListResponsesV4PagePaginationArray, - { query, ...options }, - ); + return this._client.getAPIList(`/zones/${zoneIdentifier}/filters`, FiltersV4PagePaginationArray, { + query, + ...options, + }); } /** @@ -73,10 +72,10 @@ export class Filters extends APIResource { id: string, body: FilterDeleteParams, options?: Core.RequestOptions, - ): Core.APIPromise { + ): Core.APIPromise { return ( this._client.delete(`/zones/${zoneIdentifier}/filters/${id}`, { body, ...options }) as Core.APIPromise<{ - result: FilterDeleteResponse; + result: Filter; }> )._thenUnwrap((obj) => obj.result); } @@ -84,50 +83,18 @@ export class Filters extends APIResource { /** * Fetches the details of a filter. */ - get(zoneIdentifier: string, id: string, options?: Core.RequestOptions): Core.APIPromise { + get(zoneIdentifier: string, id: string, options?: Core.RequestOptions): Core.APIPromise { return ( this._client.get(`/zones/${zoneIdentifier}/filters/${id}`, options) as Core.APIPromise<{ - result: FilterGetResponse; + result: Filter; }> )._thenUnwrap((obj) => obj.result); } } -export class FilterListResponsesV4PagePaginationArray extends V4PagePaginationArray {} +export class FiltersV4PagePaginationArray extends V4PagePaginationArray {} -export type FilterCreateResponse = Array; - -export namespace FilterCreateResponse { - export interface FilterCreateResponseItem { - /** - * The unique identifier of the filter. - */ - id: 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; - - /** - * An informative summary of the filter. - */ - description?: string; - - /** - * A short reference tag. Allows you to select related filters. - */ - ref?: string; - } -} - -export interface FilterUpdateResponse { +export interface Filter { /** * The unique identifier of the filter. */ @@ -155,89 +122,7 @@ export interface FilterUpdateResponse { ref?: string; } -export interface FilterListResponse { - /** - * The unique identifier of the filter. - */ - id: 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; - - /** - * An informative summary of the filter. - */ - description?: string; - - /** - * A short reference tag. Allows you to select related filters. - */ - ref?: string; -} - -export interface FilterDeleteResponse { - /** - * The unique identifier of the filter. - */ - id: string; - - /** - * 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 interface FilterGetResponse { - /** - * The unique identifier of the filter. - */ - id?: string; - - /** - * 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 type FilterCreateParams = unknown; diff --git a/src/resources/firewall/access-rules.ts b/src/resources/firewall/access-rules.ts index 5a5bade2df..1d33561822 100644 --- a/src/resources/firewall/access-rules.ts +++ b/src/resources/firewall/access-rules.ts @@ -206,6 +206,74 @@ export class AccessRules extends APIResource { export class AccessRuleListResponsesV4PagePaginationArray extends V4PagePaginationArray {} +export interface ASNConfiguration { + /** + * The configuration target. You must set the target to `asn` when specifying an + * Autonomous System Number (ASN) in the rule. + */ + target?: 'asn'; + + /** + * The AS number to match. + */ + value?: string; +} + +export interface CIDRConfiguration { + /** + * The configuration target. You must set the target to `ip_range` when specifying + * an IP address range in the rule. + */ + target?: 'ip_range'; + + /** + * The IP address range to match. You can only use prefix lengths `/16` and `/24` + * for IPv4 ranges, and prefix lengths `/32`, `/48`, and `/64` for IPv6 ranges. + */ + value?: string; +} + +export interface CountryConfiguration { + /** + * The configuration target. You must set the target to `country` when specifying a + * country code in the rule. + */ + target?: 'country'; + + /** + * The two-letter ISO-3166-1 alpha-2 code to match. For more information, refer to + * [IP Access rules: Parameters](https://developers.cloudflare.com/waf/tools/ip-access-rules/parameters/#country). + */ + value?: string; +} + +export interface IPConfiguration { + /** + * The configuration target. You must set the target to `ip` when specifying an IP + * address in the rule. + */ + target?: 'ip'; + + /** + * The IP address to match. This address will be compared to the IP address of + * incoming requests. + */ + value?: string; +} + +export interface IPV6Configuration { + /** + * The configuration target. You must set the target to `ip6` when specifying an + * IPv6 address in the rule. + */ + target?: 'ip6'; + + /** + * The IPv6 address to match. + */ + value?: string; +} + export type AccessRuleListResponse = unknown; export interface AccessRuleDeleteResponse { @@ -220,11 +288,11 @@ export interface AccessRuleCreateParams { * Body param: The rule configuration. */ configuration: - | AccessRuleCreateParams.FirewallIPConfiguration - | AccessRuleCreateParams.FirewallIPV6Configuration - | AccessRuleCreateParams.FirewallCIDRConfiguration - | AccessRuleCreateParams.FirewallASNConfiguration - | AccessRuleCreateParams.FirewallCountryConfiguration; + | IPConfiguration + | IPV6Configuration + | CIDRConfiguration + | ASNConfiguration + | CountryConfiguration; /** * Body param: The action to apply to a matched request. @@ -250,76 +318,6 @@ export interface AccessRuleCreateParams { notes?: string; } -export namespace AccessRuleCreateParams { - export interface FirewallIPConfiguration { - /** - * The configuration target. You must set the target to `ip` when specifying an IP - * address in the rule. - */ - target?: 'ip'; - - /** - * The IP address to match. This address will be compared to the IP address of - * incoming requests. - */ - value?: string; - } - - export interface FirewallIPV6Configuration { - /** - * The configuration target. You must set the target to `ip6` when specifying an - * IPv6 address in the rule. - */ - target?: 'ip6'; - - /** - * The IPv6 address to match. - */ - value?: string; - } - - export interface FirewallCIDRConfiguration { - /** - * The configuration target. You must set the target to `ip_range` when specifying - * an IP address range in the rule. - */ - target?: 'ip_range'; - - /** - * The IP address range to match. You can only use prefix lengths `/16` and `/24` - * for IPv4 ranges, and prefix lengths `/32`, `/48`, and `/64` for IPv6 ranges. - */ - value?: string; - } - - export interface FirewallASNConfiguration { - /** - * The configuration target. You must set the target to `asn` when specifying an - * Autonomous System Number (ASN) in the rule. - */ - target?: 'asn'; - - /** - * The AS number to match. - */ - value?: string; - } - - export interface FirewallCountryConfiguration { - /** - * The configuration target. You must set the target to `country` when specifying a - * country code in the rule. - */ - target?: 'country'; - - /** - * The two-letter ISO-3166-1 alpha-2 code to match. For more information, refer to - * [IP Access rules: Parameters](https://developers.cloudflare.com/waf/tools/ip-access-rules/parameters/#country). - */ - value?: string; - } -} - export interface AccessRuleListParams extends V4PagePaginationArrayParams { /** * Path param: The Account ID to use for this endpoint. Mutually exclusive with the @@ -432,11 +430,11 @@ export interface AccessRuleEditParams { * Body param: The rule configuration. */ configuration: - | AccessRuleEditParams.FirewallIPConfiguration - | AccessRuleEditParams.FirewallIPV6Configuration - | AccessRuleEditParams.FirewallCIDRConfiguration - | AccessRuleEditParams.FirewallASNConfiguration - | AccessRuleEditParams.FirewallCountryConfiguration; + | IPConfiguration + | IPV6Configuration + | CIDRConfiguration + | ASNConfiguration + | CountryConfiguration; /** * Body param: The action to apply to a matched request. @@ -462,76 +460,6 @@ export interface AccessRuleEditParams { notes?: string; } -export namespace AccessRuleEditParams { - export interface FirewallIPConfiguration { - /** - * The configuration target. You must set the target to `ip` when specifying an IP - * address in the rule. - */ - target?: 'ip'; - - /** - * The IP address to match. This address will be compared to the IP address of - * incoming requests. - */ - value?: string; - } - - export interface FirewallIPV6Configuration { - /** - * The configuration target. You must set the target to `ip6` when specifying an - * IPv6 address in the rule. - */ - target?: 'ip6'; - - /** - * The IPv6 address to match. - */ - value?: string; - } - - export interface FirewallCIDRConfiguration { - /** - * The configuration target. You must set the target to `ip_range` when specifying - * an IP address range in the rule. - */ - target?: 'ip_range'; - - /** - * The IP address range to match. You can only use prefix lengths `/16` and `/24` - * for IPv4 ranges, and prefix lengths `/32`, `/48`, and `/64` for IPv6 ranges. - */ - value?: string; - } - - export interface FirewallASNConfiguration { - /** - * The configuration target. You must set the target to `asn` when specifying an - * Autonomous System Number (ASN) in the rule. - */ - target?: 'asn'; - - /** - * The AS number to match. - */ - value?: string; - } - - export interface FirewallCountryConfiguration { - /** - * The configuration target. You must set the target to `country` when specifying a - * country code in the rule. - */ - target?: 'country'; - - /** - * The two-letter ISO-3166-1 alpha-2 code to match. For more information, refer to - * [IP Access rules: Parameters](https://developers.cloudflare.com/waf/tools/ip-access-rules/parameters/#country). - */ - value?: string; - } -} - export interface AccessRuleGetParams { /** * The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. @@ -545,6 +473,11 @@ export interface AccessRuleGetParams { } export namespace AccessRules { + export import ASNConfiguration = AccessRulesAPI.ASNConfiguration; + export import CIDRConfiguration = AccessRulesAPI.CIDRConfiguration; + export import CountryConfiguration = AccessRulesAPI.CountryConfiguration; + export import IPConfiguration = AccessRulesAPI.IPConfiguration; + export import IPV6Configuration = AccessRulesAPI.IPV6Configuration; export import AccessRuleListResponse = AccessRulesAPI.AccessRuleListResponse; export import AccessRuleDeleteResponse = AccessRulesAPI.AccessRuleDeleteResponse; export import AccessRuleListResponsesV4PagePaginationArray = AccessRulesAPI.AccessRuleListResponsesV4PagePaginationArray; diff --git a/src/resources/firewall/firewall.ts b/src/resources/firewall/firewall.ts index f8d945716a..de8d481a54 100644 --- a/src/resources/firewall/firewall.ts +++ b/src/resources/firewall/firewall.ts @@ -42,6 +42,9 @@ export namespace Firewall { export import RuleEditParams = RulesAPI.RuleEditParams; export import RuleGetParams = RulesAPI.RuleGetParams; export import AccessRules = AccessRulesAPI.AccessRules; + export import ASNConfiguration = AccessRulesAPI.ASNConfiguration; + export import CountryConfiguration = AccessRulesAPI.CountryConfiguration; + export import IPV6Configuration = AccessRulesAPI.IPV6Configuration; export import AccessRuleListResponse = AccessRulesAPI.AccessRuleListResponse; export import AccessRuleDeleteResponse = AccessRulesAPI.AccessRuleDeleteResponse; export import AccessRuleListResponsesV4PagePaginationArray = AccessRulesAPI.AccessRuleListResponsesV4PagePaginationArray; diff --git a/src/resources/firewall/index.ts b/src/resources/firewall/index.ts index 2580097552..cd619d0417 100644 --- a/src/resources/firewall/index.ts +++ b/src/resources/firewall/index.ts @@ -1,6 +1,11 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. export { + ASNConfiguration, + CIDRConfiguration, + CountryConfiguration, + IPConfiguration, + IPV6Configuration, AccessRuleListResponse, AccessRuleDeleteResponse, AccessRuleCreateParams, diff --git a/src/resources/firewall/rules.ts b/src/resources/firewall/rules.ts index 83515a0ede..3dbdcdbf2f 100644 --- a/src/resources/firewall/rules.ts +++ b/src/resources/firewall/rules.ts @@ -4,6 +4,8 @@ import * as Core from 'cloudflare/core'; import { APIResource } from 'cloudflare/resource'; import { isRequestOptions } from 'cloudflare/core'; import * as RulesAPI from 'cloudflare/resources/firewall/rules'; +import * as FiltersAPI from 'cloudflare/resources/filters'; +import * as RateLimitsAPI from 'cloudflare/resources/rate-limits'; import { V4PagePaginationArray, type V4PagePaginationArrayParams } from 'cloudflare/pagination'; export class Rules extends APIResource { @@ -131,14 +133,14 @@ export interface Rule { * The action to apply to a matched request. The `log` action is only available on * an Enterprise plan. */ - action?: 'block' | 'challenge' | 'js_challenge' | 'managed_challenge' | 'allow' | 'log' | 'bypass'; + action?: RateLimitsAPI.Action; /** * An informative summary of the firewall rule. */ description?: string; - filter?: Rule.FirewallFilter | DeletedFilter; + filter?: FiltersAPI.Filter | DeletedFilter; /** * When true, indicates that the firewall rule is currently paused. @@ -160,36 +162,6 @@ export interface Rule { ref?: string; } -export namespace Rule { - export interface FirewallFilter { - /** - * The unique identifier of the filter. - */ - id?: string; - - /** - * 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 interface DeletedFilter { /** * The unique identifier of the filter. diff --git a/src/resources/firewall/waf/packages/index.ts b/src/resources/firewall/waf/packages/index.ts index 7a4541c724..9c190bb953 100644 --- a/src/resources/firewall/waf/packages/index.ts +++ b/src/resources/firewall/waf/packages/index.ts @@ -1,5 +1,16 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. +export { + AllowedModesAnomaly, + Rule, + UnnamedSchemaRef532d8b97684c9032dd36bae8acddebf5, + RuleEditResponse, + RuleListParams, + RuleEditParams, + RuleGetParams, + RulesV4PagePaginationArray, + Rules, +} from './rules'; export { Group, GroupListParams, @@ -15,13 +26,3 @@ export { PackageListResponsesV4PagePaginationArray, Packages, } from './packages'; -export { - Rule, - UnnamedSchemaRef532d8b97684c9032dd36bae8acddebf5, - RuleEditResponse, - RuleListParams, - RuleEditParams, - RuleGetParams, - RulesV4PagePaginationArray, - Rules, -} from './rules'; diff --git a/src/resources/firewall/waf/packages/packages.ts b/src/resources/firewall/waf/packages/packages.ts index 7eb247bace..b1527b1e5a 100644 --- a/src/resources/firewall/waf/packages/packages.ts +++ b/src/resources/firewall/waf/packages/packages.ts @@ -253,6 +253,7 @@ export namespace Packages { export import GroupEditParams = GroupsAPI.GroupEditParams; export import GroupGetParams = GroupsAPI.GroupGetParams; export import Rules = RulesAPI.Rules; + export import AllowedModesAnomaly = RulesAPI.AllowedModesAnomaly; export import Rule = RulesAPI.Rule; export import UnnamedSchemaRef532d8b97684c9032dd36bae8acddebf5 = RulesAPI.UnnamedSchemaRef532d8b97684c9032dd36bae8acddebf5; export import RuleEditResponse = RulesAPI.RuleEditResponse; diff --git a/src/resources/firewall/waf/packages/rules.ts b/src/resources/firewall/waf/packages/rules.ts index e24e7cac42..be1771c33d 100644 --- a/src/resources/firewall/waf/packages/rules.ts +++ b/src/resources/firewall/waf/packages/rules.ts @@ -71,6 +71,12 @@ export class Rules extends APIResource { export class RulesV4PagePaginationArray extends V4PagePaginationArray {} +/** + * When set to `on`, the current WAF rule will be used when evaluating the request. + * Applies to anomaly detection WAF rules. + */ +export type AllowedModesAnomaly = 'on' | 'off'; + /** * When triggered, anomaly detection WAF rules contribute to an overall threat * score that will determine if a request is considered malicious. You can @@ -99,7 +105,7 @@ export namespace Rule { * Defines the available modes for the current WAF rule. Applies to anomaly * detection WAF rules. */ - allowed_modes: Array<'on' | 'off'>; + allowed_modes: Array; /** * The public description of the WAF rule. @@ -266,7 +272,7 @@ export namespace RuleEditResponse { * Defines the available modes for the current WAF rule. Applies to anomaly * detection WAF rules. */ - allowed_modes: Array<'on' | 'off'>; + allowed_modes: Array; /** * The public description of the WAF rule. @@ -455,6 +461,7 @@ export interface RuleGetParams { } export namespace Rules { + export import AllowedModesAnomaly = RulesAPI.AllowedModesAnomaly; export import Rule = RulesAPI.Rule; export import UnnamedSchemaRef532d8b97684c9032dd36bae8acddebf5 = RulesAPI.UnnamedSchemaRef532d8b97684c9032dd36bae8acddebf5; export import RuleEditResponse = RulesAPI.RuleEditResponse; diff --git a/src/resources/rate-limits.ts b/src/resources/rate-limits.ts index 5dae0b96ed..32708d37b6 100644 --- a/src/resources/rate-limits.ts +++ b/src/resources/rate-limits.ts @@ -3,6 +3,7 @@ import * as Core from 'cloudflare/core'; import { APIResource } from 'cloudflare/resource'; import { isRequestOptions } from 'cloudflare/core'; +import * as RateLimitsAPI from 'cloudflare/resources/rate-limits'; import * as Shared from 'cloudflare/resources/shared'; import { V4PagePaginationArray, type V4PagePaginationArrayParams } from 'cloudflare/pagination'; @@ -30,24 +31,23 @@ export class RateLimits extends APIResource { zoneIdentifier: string, query?: RateLimitListParams, options?: Core.RequestOptions, - ): Core.PagePromise; + ): Core.PagePromise; list( zoneIdentifier: string, options?: Core.RequestOptions, - ): Core.PagePromise; + ): Core.PagePromise; list( zoneIdentifier: string, query: RateLimitListParams | Core.RequestOptions = {}, options?: Core.RequestOptions, - ): Core.PagePromise { + ): Core.PagePromise { if (isRequestOptions(query)) { return this.list(zoneIdentifier, {}, query); } - return this._client.getAPIList( - `/zones/${zoneIdentifier}/rate_limits`, - RateLimitListResponsesV4PagePaginationArray, - { query, ...options }, - ); + return this._client.getAPIList(`/zones/${zoneIdentifier}/rate_limits`, RateLimitsV4PagePaginationArray, { + query, + ...options, + }); } /** @@ -100,9 +100,27 @@ export class RateLimits extends APIResource { } } -export class RateLimitListResponsesV4PagePaginationArray extends V4PagePaginationArray {} - -export interface RateLimitListResponse { +export class RateLimitsV4PagePaginationArray extends V4PagePaginationArray {} + +/** + * The action to apply to a matched request. The `log` action is only available on + * an Enterprise plan. + */ +export type Action = + | 'block' + | 'challenge' + | 'js_challenge' + | 'managed_challenge' + | 'allow' + | 'log' + | 'bypass'; + +/** + * An HTTP method or `_ALL_` to indicate all methods. + */ +export type Methods = 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | '_ALL_'; + +export interface RateLimit { /** * The unique identifier of the rate limit. */ @@ -112,13 +130,13 @@ export interface RateLimitListResponse { * The action to perform when the threshold of matched traffic within the * configured period is exceeded. */ - action?: RateLimitListResponse.Action; + action?: RateLimit.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; + bypass?: Array; /** * An informative summary of the rate limit. This value is sanitized and any tags @@ -134,7 +152,7 @@ export interface RateLimitListResponse { /** * Determines which traffic the rate limit counts towards the threshold. */ - match?: RateLimitListResponse.Match; + match?: RateLimit.Match; /** * The time in seconds (an integer value) to count matching traffic. If the count @@ -150,7 +168,7 @@ export interface RateLimitListResponse { threshold?: number; } -export namespace RateLimitListResponse { +export namespace RateLimit { /** * The action to perform when the threshold of matched traffic within the * configured period is exceeded. @@ -248,7 +266,7 @@ export namespace RateLimitListResponse { * `['POST','PUT']`) or all methods (`['_ALL_']`). This field is optional when * creating a rate limit. */ - methods?: Array<'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH' | 'HEAD' | '_ALL_'>; + methods?: Array; /** * The HTTP schemes to match. You can specify one scheme (`['HTTPS']`), both diff --git a/src/resources/user/firewall/access-rules.ts b/src/resources/user/firewall/access-rules.ts index 5ff8143da0..45557236a7 100644 --- a/src/resources/user/firewall/access-rules.ts +++ b/src/resources/user/firewall/access-rules.ts @@ -3,7 +3,8 @@ import * as Core from 'cloudflare/core'; import { APIResource } from 'cloudflare/resource'; import { isRequestOptions } from 'cloudflare/core'; -import * as AccessRulesAPI from 'cloudflare/resources/user/firewall/access-rules'; +import * as FirewallAccessRulesAPI from 'cloudflare/resources/user/firewall/access-rules'; +import * as AccessRulesAPI from 'cloudflare/resources/firewall/access-rules'; import { V4PagePaginationArray, type V4PagePaginationArrayParams } from 'cloudflare/pagination'; export class AccessRules extends APIResource { @@ -13,13 +14,10 @@ export class AccessRules extends APIResource { * Note: To create an IP Access rule that applies to a specific zone, refer to the * [IP Access rules for a zone](#ip-access-rules-for-a-zone) endpoints. */ - create( - body: AccessRuleCreateParams, - options?: Core.RequestOptions, - ): Core.APIPromise { + create(body: AccessRuleCreateParams, options?: Core.RequestOptions): Core.APIPromise { return ( this._client.post('/user/firewall/access_rules/rules', { body, ...options }) as Core.APIPromise<{ - result: AccessRuleCreateResponse; + result: FirewallRule; }> )._thenUnwrap((obj) => obj.result); } @@ -31,22 +29,19 @@ export class AccessRules extends APIResource { list( query?: AccessRuleListParams, options?: Core.RequestOptions, - ): Core.PagePromise; - list( - options?: Core.RequestOptions, - ): Core.PagePromise; + ): Core.PagePromise; + list(options?: Core.RequestOptions): Core.PagePromise; list( query: AccessRuleListParams | Core.RequestOptions = {}, options?: Core.RequestOptions, - ): Core.PagePromise { + ): Core.PagePromise { if (isRequestOptions(query)) { return this.list({}, query); } - return this._client.getAPIList( - '/user/firewall/access_rules/rules', - AccessRuleListResponsesV4PagePaginationArray, - { query, ...options }, - ); + return this._client.getAPIList('/user/firewall/access_rules/rules', FirewallRulesV4PagePaginationArray, { + query, + ...options, + }); } /** @@ -75,131 +70,19 @@ export class AccessRules extends APIResource { identifier: string, body: AccessRuleEditParams, options?: Core.RequestOptions, - ): Core.APIPromise { + ): Core.APIPromise { return ( this._client.patch(`/user/firewall/access_rules/rules/${identifier}`, { body, ...options, - }) as Core.APIPromise<{ result: AccessRuleEditResponse }> + }) as Core.APIPromise<{ result: FirewallRule }> )._thenUnwrap((obj) => obj.result); } } -export class AccessRuleListResponsesV4PagePaginationArray extends V4PagePaginationArray {} - -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: - | AccessRuleCreateResponse.FirewallIPConfiguration - | AccessRuleCreateResponse.FirewallIPV6Configuration - | AccessRuleCreateResponse.FirewallCIDRConfiguration - | AccessRuleCreateResponse.FirewallASNConfiguration - | AccessRuleCreateResponse.FirewallCountryConfiguration; - - /** - * 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; -} - -export namespace AccessRuleCreateResponse { - export interface FirewallIPConfiguration { - /** - * The configuration target. You must set the target to `ip` when specifying an IP - * address in the rule. - */ - target?: 'ip'; - - /** - * The IP address to match. This address will be compared to the IP address of - * incoming requests. - */ - value?: string; - } - - export interface FirewallIPV6Configuration { - /** - * The configuration target. You must set the target to `ip6` when specifying an - * IPv6 address in the rule. - */ - target?: 'ip6'; - - /** - * The IPv6 address to match. - */ - value?: string; - } - - export interface FirewallCIDRConfiguration { - /** - * The configuration target. You must set the target to `ip_range` when specifying - * an IP address range in the rule. - */ - target?: 'ip_range'; - - /** - * The IP address range to match. You can only use prefix lengths `/16` and `/24` - * for IPv4 ranges, and prefix lengths `/32`, `/48`, and `/64` for IPv6 ranges. - */ - value?: string; - } - - export interface FirewallASNConfiguration { - /** - * The configuration target. You must set the target to `asn` when specifying an - * Autonomous System Number (ASN) in the rule. - */ - target?: 'asn'; - - /** - * The AS number to match. - */ - value?: string; - } - - export interface FirewallCountryConfiguration { - /** - * The configuration target. You must set the target to `country` when specifying a - * country code in the rule. - */ - target?: 'country'; - - /** - * The two-letter ISO-3166-1 alpha-2 code to match. For more information, refer to - * [IP Access rules: Parameters](https://developers.cloudflare.com/waf/tools/ip-access-rules/parameters/#country). - */ - value?: string; - } -} +export class FirewallRulesV4PagePaginationArray extends V4PagePaginationArray {} -export interface AccessRuleListResponse { +export interface FirewallRule { /** * The unique identifier of the IP Access rule. */ @@ -214,11 +97,11 @@ export interface AccessRuleListResponse { * The rule configuration. */ configuration: - | AccessRuleListResponse.FirewallIPConfiguration - | AccessRuleListResponse.FirewallIPV6Configuration - | AccessRuleListResponse.FirewallCIDRConfiguration - | AccessRuleListResponse.FirewallASNConfiguration - | AccessRuleListResponse.FirewallCountryConfiguration; + | AccessRulesAPI.IPConfiguration + | AccessRulesAPI.IPV6Configuration + | AccessRulesAPI.CIDRConfiguration + | AccessRulesAPI.ASNConfiguration + | AccessRulesAPI.CountryConfiguration; /** * The action to apply to a matched request. @@ -241,76 +124,6 @@ export interface AccessRuleListResponse { notes?: string; } -export namespace AccessRuleListResponse { - export interface FirewallIPConfiguration { - /** - * The configuration target. You must set the target to `ip` when specifying an IP - * address in the rule. - */ - target?: 'ip'; - - /** - * The IP address to match. This address will be compared to the IP address of - * incoming requests. - */ - value?: string; - } - - export interface FirewallIPV6Configuration { - /** - * The configuration target. You must set the target to `ip6` when specifying an - * IPv6 address in the rule. - */ - target?: 'ip6'; - - /** - * The IPv6 address to match. - */ - value?: string; - } - - export interface FirewallCIDRConfiguration { - /** - * The configuration target. You must set the target to `ip_range` when specifying - * an IP address range in the rule. - */ - target?: 'ip_range'; - - /** - * The IP address range to match. You can only use prefix lengths `/16` and `/24` - * for IPv4 ranges, and prefix lengths `/32`, `/48`, and `/64` for IPv6 ranges. - */ - value?: string; - } - - export interface FirewallASNConfiguration { - /** - * The configuration target. You must set the target to `asn` when specifying an - * Autonomous System Number (ASN) in the rule. - */ - target?: 'asn'; - - /** - * The AS number to match. - */ - value?: string; - } - - export interface FirewallCountryConfiguration { - /** - * The configuration target. You must set the target to `country` when specifying a - * country code in the rule. - */ - target?: 'country'; - - /** - * The two-letter ISO-3166-1 alpha-2 code to match. For more information, refer to - * [IP Access rules: Parameters](https://developers.cloudflare.com/waf/tools/ip-access-rules/parameters/#country). - */ - value?: string; - } -} - export interface AccessRuleDeleteResponse { /** * The unique identifier of the IP Access rule. @@ -318,128 +131,16 @@ export interface AccessRuleDeleteResponse { id?: string; } -export interface AccessRuleEditResponse { - /** - * 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: - | AccessRuleEditResponse.FirewallIPConfiguration - | AccessRuleEditResponse.FirewallIPV6Configuration - | AccessRuleEditResponse.FirewallCIDRConfiguration - | AccessRuleEditResponse.FirewallASNConfiguration - | AccessRuleEditResponse.FirewallCountryConfiguration; - - /** - * 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; -} - -export namespace AccessRuleEditResponse { - export interface FirewallIPConfiguration { - /** - * The configuration target. You must set the target to `ip` when specifying an IP - * address in the rule. - */ - target?: 'ip'; - - /** - * The IP address to match. This address will be compared to the IP address of - * incoming requests. - */ - value?: string; - } - - export interface FirewallIPV6Configuration { - /** - * The configuration target. You must set the target to `ip6` when specifying an - * IPv6 address in the rule. - */ - target?: 'ip6'; - - /** - * The IPv6 address to match. - */ - value?: string; - } - - export interface FirewallCIDRConfiguration { - /** - * The configuration target. You must set the target to `ip_range` when specifying - * an IP address range in the rule. - */ - target?: 'ip_range'; - - /** - * The IP address range to match. You can only use prefix lengths `/16` and `/24` - * for IPv4 ranges, and prefix lengths `/32`, `/48`, and `/64` for IPv6 ranges. - */ - value?: string; - } - - export interface FirewallASNConfiguration { - /** - * The configuration target. You must set the target to `asn` when specifying an - * Autonomous System Number (ASN) in the rule. - */ - target?: 'asn'; - - /** - * The AS number to match. - */ - value?: string; - } - - export interface FirewallCountryConfiguration { - /** - * The configuration target. You must set the target to `country` when specifying a - * country code in the rule. - */ - target?: 'country'; - - /** - * The two-letter ISO-3166-1 alpha-2 code to match. For more information, refer to - * [IP Access rules: Parameters](https://developers.cloudflare.com/waf/tools/ip-access-rules/parameters/#country). - */ - value?: string; - } -} - export interface AccessRuleCreateParams { /** * The rule configuration. */ configuration: - | AccessRuleCreateParams.FirewallIPConfiguration - | AccessRuleCreateParams.FirewallIPV6Configuration - | AccessRuleCreateParams.FirewallCIDRConfiguration - | AccessRuleCreateParams.FirewallASNConfiguration - | AccessRuleCreateParams.FirewallCountryConfiguration; + | AccessRulesAPI.IPConfiguration + | AccessRulesAPI.IPV6Configuration + | AccessRulesAPI.CIDRConfiguration + | AccessRulesAPI.ASNConfiguration + | AccessRulesAPI.CountryConfiguration; /** * The action to apply to a matched request. @@ -452,76 +153,6 @@ export interface AccessRuleCreateParams { notes?: string; } -export namespace AccessRuleCreateParams { - export interface FirewallIPConfiguration { - /** - * The configuration target. You must set the target to `ip` when specifying an IP - * address in the rule. - */ - target?: 'ip'; - - /** - * The IP address to match. This address will be compared to the IP address of - * incoming requests. - */ - value?: string; - } - - export interface FirewallIPV6Configuration { - /** - * The configuration target. You must set the target to `ip6` when specifying an - * IPv6 address in the rule. - */ - target?: 'ip6'; - - /** - * The IPv6 address to match. - */ - value?: string; - } - - export interface FirewallCIDRConfiguration { - /** - * The configuration target. You must set the target to `ip_range` when specifying - * an IP address range in the rule. - */ - target?: 'ip_range'; - - /** - * The IP address range to match. You can only use prefix lengths `/16` and `/24` - * for IPv4 ranges, and prefix lengths `/32`, `/48`, and `/64` for IPv6 ranges. - */ - value?: string; - } - - export interface FirewallASNConfiguration { - /** - * The configuration target. You must set the target to `asn` when specifying an - * Autonomous System Number (ASN) in the rule. - */ - target?: 'asn'; - - /** - * The AS number to match. - */ - value?: string; - } - - export interface FirewallCountryConfiguration { - /** - * The configuration target. You must set the target to `country` when specifying a - * country code in the rule. - */ - target?: 'country'; - - /** - * The two-letter ISO-3166-1 alpha-2 code to match. For more information, refer to - * [IP Access rules: Parameters](https://developers.cloudflare.com/waf/tools/ip-access-rules/parameters/#country). - */ - value?: string; - } -} - export interface AccessRuleListParams extends V4PagePaginationArrayParams { /** * The direction used to sort returned rules. @@ -607,13 +238,11 @@ export interface AccessRuleEditParams { } export namespace AccessRules { - export import AccessRuleCreateResponse = AccessRulesAPI.AccessRuleCreateResponse; - export import AccessRuleListResponse = AccessRulesAPI.AccessRuleListResponse; - export import AccessRuleDeleteResponse = AccessRulesAPI.AccessRuleDeleteResponse; - export import AccessRuleEditResponse = AccessRulesAPI.AccessRuleEditResponse; - export import AccessRuleListResponsesV4PagePaginationArray = AccessRulesAPI.AccessRuleListResponsesV4PagePaginationArray; - export import AccessRuleCreateParams = AccessRulesAPI.AccessRuleCreateParams; - export import AccessRuleListParams = AccessRulesAPI.AccessRuleListParams; - export import AccessRuleDeleteParams = AccessRulesAPI.AccessRuleDeleteParams; - export import AccessRuleEditParams = AccessRulesAPI.AccessRuleEditParams; + export import FirewallRule = FirewallAccessRulesAPI.FirewallRule; + export import AccessRuleDeleteResponse = FirewallAccessRulesAPI.AccessRuleDeleteResponse; + export import FirewallRulesV4PagePaginationArray = FirewallAccessRulesAPI.FirewallRulesV4PagePaginationArray; + export import AccessRuleCreateParams = FirewallAccessRulesAPI.AccessRuleCreateParams; + export import AccessRuleListParams = FirewallAccessRulesAPI.AccessRuleListParams; + export import AccessRuleDeleteParams = FirewallAccessRulesAPI.AccessRuleDeleteParams; + export import AccessRuleEditParams = FirewallAccessRulesAPI.AccessRuleEditParams; } diff --git a/src/resources/user/firewall/firewall.ts b/src/resources/user/firewall/firewall.ts index 9475f7e2db..d21d5818bc 100644 --- a/src/resources/user/firewall/firewall.ts +++ b/src/resources/user/firewall/firewall.ts @@ -9,11 +9,9 @@ export class Firewall extends APIResource { export namespace Firewall { export import AccessRules = AccessRulesAPI.AccessRules; - export import AccessRuleCreateResponse = AccessRulesAPI.AccessRuleCreateResponse; - export import AccessRuleListResponse = AccessRulesAPI.AccessRuleListResponse; + export import FirewallRule = AccessRulesAPI.FirewallRule; export import AccessRuleDeleteResponse = AccessRulesAPI.AccessRuleDeleteResponse; - export import AccessRuleEditResponse = AccessRulesAPI.AccessRuleEditResponse; - export import AccessRuleListResponsesV4PagePaginationArray = AccessRulesAPI.AccessRuleListResponsesV4PagePaginationArray; + export import FirewallRulesV4PagePaginationArray = AccessRulesAPI.FirewallRulesV4PagePaginationArray; export import AccessRuleCreateParams = AccessRulesAPI.AccessRuleCreateParams; export import AccessRuleListParams = AccessRulesAPI.AccessRuleListParams; export import AccessRuleDeleteParams = AccessRulesAPI.AccessRuleDeleteParams; diff --git a/src/resources/user/firewall/index.ts b/src/resources/user/firewall/index.ts index 1891207707..6ac64c2477 100644 --- a/src/resources/user/firewall/index.ts +++ b/src/resources/user/firewall/index.ts @@ -1,15 +1,13 @@ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. +export { Firewall } from './firewall'; export { - AccessRuleCreateResponse, - AccessRuleListResponse, + FirewallRule, AccessRuleDeleteResponse, - AccessRuleEditResponse, AccessRuleCreateParams, AccessRuleListParams, AccessRuleDeleteParams, AccessRuleEditParams, - AccessRuleListResponsesV4PagePaginationArray, + FirewallRulesV4PagePaginationArray, AccessRules, } from './access-rules'; -export { Firewall } from './firewall'; diff --git a/src/resources/waiting-rooms/events/events.ts b/src/resources/waiting-rooms/events/events.ts index 3e7ac274bc..6a88224a42 100644 --- a/src/resources/waiting-rooms/events/events.ts +++ b/src/resources/waiting-rooms/events/events.ts @@ -21,13 +21,13 @@ export class Events extends APIResource { waitingRoomId: string, params: EventCreateParams, options?: Core.RequestOptions, - ): Core.APIPromise { + ): Core.APIPromise { const { zone_id, ...body } = params; return ( this._client.post(`/zones/${zone_id}/waiting_rooms/${waitingRoomId}/events`, { body, ...options, - }) as Core.APIPromise<{ result: EventCreateResponse }> + }) as Core.APIPromise<{ result: Event }> )._thenUnwrap((obj) => obj.result); } @@ -39,13 +39,13 @@ export class Events extends APIResource { eventId: string, params: EventUpdateParams, options?: Core.RequestOptions, - ): Core.APIPromise { + ): Core.APIPromise { const { zone_id, ...body } = params; return ( this._client.put(`/zones/${zone_id}/waiting_rooms/${waitingRoomId}/events/${eventId}`, { body, ...options, - }) as Core.APIPromise<{ result: EventUpdateResponse }> + }) as Core.APIPromise<{ result: Event }> )._thenUnwrap((obj) => obj.result); } @@ -56,11 +56,11 @@ export class Events extends APIResource { waitingRoomId: string, params: EventListParams, options?: Core.RequestOptions, - ): Core.PagePromise { + ): Core.PagePromise { const { zone_id } = params; return this._client.getAPIList( `/zones/${zone_id}/waiting_rooms/${waitingRoomId}/events`, - EventListResponsesSinglePage, + EventsSinglePage, options, ); } @@ -91,13 +91,13 @@ export class Events extends APIResource { eventId: string, params: EventEditParams, options?: Core.RequestOptions, - ): Core.APIPromise { + ): Core.APIPromise { const { zone_id, ...body } = params; return ( this._client.patch(`/zones/${zone_id}/waiting_rooms/${waitingRoomId}/events/${eventId}`, { body, ...options, - }) as Core.APIPromise<{ result: EventEditResponse }> + }) as Core.APIPromise<{ result: Event }> )._thenUnwrap((obj) => obj.result); } @@ -109,56 +109,20 @@ export class Events extends APIResource { eventId: string, params: EventGetParams, options?: Core.RequestOptions, - ): Core.APIPromise { + ): Core.APIPromise { const { zone_id } = params; return ( this._client.get( `/zones/${zone_id}/waiting_rooms/${waitingRoomId}/events/${eventId}`, options, - ) as Core.APIPromise<{ result: EventGetResponse }> + ) as Core.APIPromise<{ result: Event }> )._thenUnwrap((obj) => obj.result); } } -export class EventListResponsesSinglePage extends SinglePage {} - export class EventsSinglePage extends SinglePage {} export interface Event { - /** - * The ID of the rule. - */ - id?: string; - - /** - * The action to take when the expression matches. - */ - action?: 'bypass_waiting_room'; - - /** - * The description of the rule. - */ - description?: string; - - /** - * When set to true, the rule is enabled. - */ - enabled?: boolean; - - /** - * Criteria defining when there is a match for the current rule. - */ - expression?: string; - - last_updated?: string; - - /** - * The version of the rule. - */ - version?: string; -} - -export interface UnnamedSchemaRef229c159575bc68a9c21f5a1615629cf6 { id?: string; created_on?: string; @@ -250,191 +214,7 @@ export interface UnnamedSchemaRef229c159575bc68a9c21f5a1615629cf6 { total_active_users?: number | null; } -export interface EventCreateResponse { - id?: string; - - created_on?: string; - - /** - * If set, the event will override the waiting room's `custom_page_html` property - * while it is active. If null, the event will inherit it. - */ - custom_page_html?: string | null; - - /** - * A note that you can use to add more details about the event. - */ - description?: string; - - /** - * If set, the event will override the waiting room's `disable_session_renewal` - * property while it is active. If null, the event will inherit it. - */ - disable_session_renewal?: boolean | null; - - /** - * An ISO 8601 timestamp that marks the end of the event. - */ - event_end_time?: string; - - /** - * An ISO 8601 timestamp that marks the start of the event. At this time, queued - * users will be processed with the event's configuration. The start time must be - * at least one minute before `event_end_time`. - */ - event_start_time?: string; - - modified_on?: string; - - /** - * A unique name to identify the event. Only alphanumeric characters, hyphens and - * underscores are allowed. - */ - name?: string; - - /** - * If set, the event will override the waiting room's `new_users_per_minute` - * property while it is active. If null, the event will inherit it. This can only - * be set if the event's `total_active_users` property is also set. - */ - new_users_per_minute?: number | null; - - /** - * An ISO 8601 timestamp that marks when to begin queueing all users before the - * event starts. The prequeue must start at least five minutes before - * `event_start_time`. - */ - prequeue_start_time?: string | null; - - /** - * If set, the event will override the waiting room's `queueing_method` property - * while it is active. If null, the event will inherit it. - */ - queueing_method?: string | null; - - /** - * If set, the event will override the waiting room's `session_duration` property - * while it is active. If null, the event will inherit it. - */ - session_duration?: number | null; - - /** - * If enabled, users in the prequeue will be shuffled randomly at the - * `event_start_time`. Requires that `prequeue_start_time` is not null. This is - * useful for situations when many users will join the event prequeue at the same - * time and you want to shuffle them to ensure fairness. Naturally, it makes the - * most sense to enable this feature when the `queueing_method` during the event - * respects ordering such as **fifo**, or else the shuffling may be unnecessary. - */ - shuffle_at_event_start?: boolean; - - /** - * Suspends or allows an event. If set to `true`, the event is ignored and traffic - * will be handled based on the waiting room configuration. - */ - suspended?: boolean; - - /** - * If set, the event will override the waiting room's `total_active_users` property - * while it is active. If null, the event will inherit it. This can only be set if - * the event's `new_users_per_minute` property is also set. - */ - total_active_users?: number | null; -} - -export interface EventUpdateResponse { - id?: string; - - created_on?: string; - - /** - * If set, the event will override the waiting room's `custom_page_html` property - * while it is active. If null, the event will inherit it. - */ - custom_page_html?: string | null; - - /** - * A note that you can use to add more details about the event. - */ - description?: string; - - /** - * If set, the event will override the waiting room's `disable_session_renewal` - * property while it is active. If null, the event will inherit it. - */ - disable_session_renewal?: boolean | null; - - /** - * An ISO 8601 timestamp that marks the end of the event. - */ - event_end_time?: string; - - /** - * An ISO 8601 timestamp that marks the start of the event. At this time, queued - * users will be processed with the event's configuration. The start time must be - * at least one minute before `event_end_time`. - */ - event_start_time?: string; - - modified_on?: string; - - /** - * A unique name to identify the event. Only alphanumeric characters, hyphens and - * underscores are allowed. - */ - name?: string; - - /** - * If set, the event will override the waiting room's `new_users_per_minute` - * property while it is active. If null, the event will inherit it. This can only - * be set if the event's `total_active_users` property is also set. - */ - new_users_per_minute?: number | null; - - /** - * An ISO 8601 timestamp that marks when to begin queueing all users before the - * event starts. The prequeue must start at least five minutes before - * `event_start_time`. - */ - prequeue_start_time?: string | null; - - /** - * If set, the event will override the waiting room's `queueing_method` property - * while it is active. If null, the event will inherit it. - */ - queueing_method?: string | null; - - /** - * If set, the event will override the waiting room's `session_duration` property - * while it is active. If null, the event will inherit it. - */ - session_duration?: number | null; - - /** - * If enabled, users in the prequeue will be shuffled randomly at the - * `event_start_time`. Requires that `prequeue_start_time` is not null. This is - * useful for situations when many users will join the event prequeue at the same - * time and you want to shuffle them to ensure fairness. Naturally, it makes the - * most sense to enable this feature when the `queueing_method` during the event - * respects ordering such as **fifo**, or else the shuffling may be unnecessary. - */ - shuffle_at_event_start?: boolean; - - /** - * Suspends or allows an event. If set to `true`, the event is ignored and traffic - * will be handled based on the waiting room configuration. - */ - suspended?: boolean; - - /** - * If set, the event will override the waiting room's `total_active_users` property - * while it is active. If null, the event will inherit it. This can only be set if - * the event's `new_users_per_minute` property is also set. - */ - total_active_users?: number | null; -} - -export interface EventListResponse { +export interface UnnamedSchemaRef229c159575bc68a9c21f5a1615629cf6 { id?: string; created_on?: string; @@ -530,190 +310,6 @@ export interface EventDeleteResponse { id?: string; } -export interface EventEditResponse { - id?: string; - - created_on?: string; - - /** - * If set, the event will override the waiting room's `custom_page_html` property - * while it is active. If null, the event will inherit it. - */ - custom_page_html?: string | null; - - /** - * A note that you can use to add more details about the event. - */ - description?: string; - - /** - * If set, the event will override the waiting room's `disable_session_renewal` - * property while it is active. If null, the event will inherit it. - */ - disable_session_renewal?: boolean | null; - - /** - * An ISO 8601 timestamp that marks the end of the event. - */ - event_end_time?: string; - - /** - * An ISO 8601 timestamp that marks the start of the event. At this time, queued - * users will be processed with the event's configuration. The start time must be - * at least one minute before `event_end_time`. - */ - event_start_time?: string; - - modified_on?: string; - - /** - * A unique name to identify the event. Only alphanumeric characters, hyphens and - * underscores are allowed. - */ - name?: string; - - /** - * If set, the event will override the waiting room's `new_users_per_minute` - * property while it is active. If null, the event will inherit it. This can only - * be set if the event's `total_active_users` property is also set. - */ - new_users_per_minute?: number | null; - - /** - * An ISO 8601 timestamp that marks when to begin queueing all users before the - * event starts. The prequeue must start at least five minutes before - * `event_start_time`. - */ - prequeue_start_time?: string | null; - - /** - * If set, the event will override the waiting room's `queueing_method` property - * while it is active. If null, the event will inherit it. - */ - queueing_method?: string | null; - - /** - * If set, the event will override the waiting room's `session_duration` property - * while it is active. If null, the event will inherit it. - */ - session_duration?: number | null; - - /** - * If enabled, users in the prequeue will be shuffled randomly at the - * `event_start_time`. Requires that `prequeue_start_time` is not null. This is - * useful for situations when many users will join the event prequeue at the same - * time and you want to shuffle them to ensure fairness. Naturally, it makes the - * most sense to enable this feature when the `queueing_method` during the event - * respects ordering such as **fifo**, or else the shuffling may be unnecessary. - */ - shuffle_at_event_start?: boolean; - - /** - * Suspends or allows an event. If set to `true`, the event is ignored and traffic - * will be handled based on the waiting room configuration. - */ - suspended?: boolean; - - /** - * If set, the event will override the waiting room's `total_active_users` property - * while it is active. If null, the event will inherit it. This can only be set if - * the event's `new_users_per_minute` property is also set. - */ - total_active_users?: number | null; -} - -export interface EventGetResponse { - id?: string; - - created_on?: string; - - /** - * If set, the event will override the waiting room's `custom_page_html` property - * while it is active. If null, the event will inherit it. - */ - custom_page_html?: string | null; - - /** - * A note that you can use to add more details about the event. - */ - description?: string; - - /** - * If set, the event will override the waiting room's `disable_session_renewal` - * property while it is active. If null, the event will inherit it. - */ - disable_session_renewal?: boolean | null; - - /** - * An ISO 8601 timestamp that marks the end of the event. - */ - event_end_time?: string; - - /** - * An ISO 8601 timestamp that marks the start of the event. At this time, queued - * users will be processed with the event's configuration. The start time must be - * at least one minute before `event_end_time`. - */ - event_start_time?: string; - - modified_on?: string; - - /** - * A unique name to identify the event. Only alphanumeric characters, hyphens and - * underscores are allowed. - */ - name?: string; - - /** - * If set, the event will override the waiting room's `new_users_per_minute` - * property while it is active. If null, the event will inherit it. This can only - * be set if the event's `total_active_users` property is also set. - */ - new_users_per_minute?: number | null; - - /** - * An ISO 8601 timestamp that marks when to begin queueing all users before the - * event starts. The prequeue must start at least five minutes before - * `event_start_time`. - */ - prequeue_start_time?: string | null; - - /** - * If set, the event will override the waiting room's `queueing_method` property - * while it is active. If null, the event will inherit it. - */ - queueing_method?: string | null; - - /** - * If set, the event will override the waiting room's `session_duration` property - * while it is active. If null, the event will inherit it. - */ - session_duration?: number | null; - - /** - * If enabled, users in the prequeue will be shuffled randomly at the - * `event_start_time`. Requires that `prequeue_start_time` is not null. This is - * useful for situations when many users will join the event prequeue at the same - * time and you want to shuffle them to ensure fairness. Naturally, it makes the - * most sense to enable this feature when the `queueing_method` during the event - * respects ordering such as **fifo**, or else the shuffling may be unnecessary. - */ - shuffle_at_event_start?: boolean; - - /** - * Suspends or allows an event. If set to `true`, the event is ignored and traffic - * will be handled based on the waiting room configuration. - */ - suspended?: boolean; - - /** - * If set, the event will override the waiting room's `total_active_users` property - * while it is active. If null, the event will inherit it. This can only be set if - * the event's `new_users_per_minute` property is also set. - */ - total_active_users?: number | null; -} - export interface EventCreateParams { /** * Path param: Identifier @@ -1031,13 +627,8 @@ export interface EventGetParams { export namespace Events { export import Event = EventsAPI.Event; export import UnnamedSchemaRef229c159575bc68a9c21f5a1615629cf6 = EventsAPI.UnnamedSchemaRef229c159575bc68a9c21f5a1615629cf6; - export import EventCreateResponse = EventsAPI.EventCreateResponse; - export import EventUpdateResponse = EventsAPI.EventUpdateResponse; - export import EventListResponse = EventsAPI.EventListResponse; export import EventDeleteResponse = EventsAPI.EventDeleteResponse; - export import EventEditResponse = EventsAPI.EventEditResponse; - export import EventGetResponse = EventsAPI.EventGetResponse; - export import EventListResponsesSinglePage = EventsAPI.EventListResponsesSinglePage; + export import EventsSinglePage = EventsAPI.EventsSinglePage; export import EventCreateParams = EventsAPI.EventCreateParams; export import EventUpdateParams = EventsAPI.EventUpdateParams; export import EventListParams = EventsAPI.EventListParams; diff --git a/src/resources/waiting-rooms/events/index.ts b/src/resources/waiting-rooms/events/index.ts index e52e79b261..39f368ad87 100644 --- a/src/resources/waiting-rooms/events/index.ts +++ b/src/resources/waiting-rooms/events/index.ts @@ -3,12 +3,7 @@ export { Event, UnnamedSchemaRef229c159575bc68a9c21f5a1615629cf6, - EventCreateResponse, - EventUpdateResponse, - EventListResponse, EventDeleteResponse, - EventEditResponse, - EventGetResponse, EventCreateParams, EventUpdateParams, EventListParams, @@ -16,7 +11,6 @@ export { EventEditParams, EventGetParams, EventsSinglePage, - EventListResponsesSinglePage, Events, } from './events'; export { EventQuery, DetailGetResponse, DetailGetParams, Details } from './details'; diff --git a/src/resources/waiting-rooms/index.ts b/src/resources/waiting-rooms/index.ts index e768771159..9aa1aa46b4 100644 --- a/src/resources/waiting-rooms/index.ts +++ b/src/resources/waiting-rooms/index.ts @@ -3,12 +3,7 @@ export { Event, UnnamedSchemaRef229c159575bc68a9c21f5a1615629cf6, - EventCreateResponse, - EventUpdateResponse, - EventListResponse, EventDeleteResponse, - EventEditResponse, - EventGetResponse, EventCreateParams, EventUpdateParams, EventListParams, @@ -16,7 +11,6 @@ export { EventEditParams, EventGetParams, EventsSinglePage, - EventListResponsesSinglePage, Events, } from './events/index'; export { PagePreviewResponse, PagePreviewParams, Page } from './page'; @@ -32,6 +26,7 @@ export { RuleListParams, RuleDeleteParams, RuleEditParams, + RulesSinglePage, Rules, } from './rules'; export { StatusGetResponse, StatusGetParams, Statuses } from './statuses'; diff --git a/src/resources/waiting-rooms/rules.ts b/src/resources/waiting-rooms/rules.ts index aae37e1c57..109d7d6508 100644 --- a/src/resources/waiting-rooms/rules.ts +++ b/src/resources/waiting-rooms/rules.ts @@ -3,8 +3,7 @@ import * as Core from 'cloudflare/core'; import { APIResource } from 'cloudflare/resource'; import * as RulesAPI from 'cloudflare/resources/waiting-rooms/rules'; -import * as EventsAPI from 'cloudflare/resources/waiting-rooms/events/events'; -import { EventsSinglePage } from 'cloudflare/resources/waiting-rooms/events/events'; +import { SinglePage } from 'cloudflare/pagination'; export class Rules extends APIResource { /** @@ -50,11 +49,11 @@ export class Rules extends APIResource { waitingRoomId: string, params: RuleListParams, options?: Core.RequestOptions, - ): Core.PagePromise { + ): Core.PagePromise { const { zone_id } = params; return this._client.getAPIList( `/zones/${zone_id}/waiting_rooms/${waitingRoomId}/rules`, - EventsSinglePage, + RulesSinglePage, options, ); } @@ -96,16 +95,18 @@ export class Rules extends APIResource { } } +export class RulesSinglePage extends SinglePage {} + export interface Rule { /** - * The action to take when the expression matches. + * The ID of the rule. */ - action: 'bypass_waiting_room'; + id?: string; /** - * Criteria defining when there is a match for the current rule. + * The action to take when the expression matches. */ - expression: string; + action?: 'bypass_waiting_room'; /** * The description of the rule. @@ -116,17 +117,29 @@ export interface Rule { * When set to true, the rule is enabled. */ enabled?: boolean; + + /** + * Criteria defining when there is a match for the current rule. + */ + expression?: string; + + last_updated?: string; + + /** + * The version of the rule. + */ + version?: string; } -export type UnnamedSchemaRefF1c0ba8f44601f2db2e07b9397b6c430 = Array; +export type UnnamedSchemaRefF1c0ba8f44601f2db2e07b9397b6c430 = Array; -export type RuleCreateResponse = Array; +export type RuleCreateResponse = Array; -export type RuleUpdateResponse = Array; +export type RuleUpdateResponse = Array; -export type RuleDeleteResponse = Array; +export type RuleDeleteResponse = Array; -export type RuleEditResponse = Array; +export type RuleEditResponse = Array; export interface RuleCreateParams { /** @@ -164,7 +177,31 @@ export interface RuleUpdateParams { /** * Body param: */ - body: Array; + body: Array; +} + +export namespace RuleUpdateParams { + export interface Body { + /** + * The action to take when the expression matches. + */ + action: 'bypass_waiting_room'; + + /** + * Criteria defining when there is a match for the current rule. + */ + expression: string; + + /** + * The description of the rule. + */ + description?: string; + + /** + * When set to true, the rule is enabled. + */ + enabled?: boolean; + } } export interface RuleListParams { @@ -253,11 +290,10 @@ export namespace Rules { export import RuleUpdateResponse = RulesAPI.RuleUpdateResponse; export import RuleDeleteResponse = RulesAPI.RuleDeleteResponse; export import RuleEditResponse = RulesAPI.RuleEditResponse; + export import RulesSinglePage = RulesAPI.RulesSinglePage; export import RuleCreateParams = RulesAPI.RuleCreateParams; export import RuleUpdateParams = RulesAPI.RuleUpdateParams; export import RuleListParams = RulesAPI.RuleListParams; export import RuleDeleteParams = RulesAPI.RuleDeleteParams; export import RuleEditParams = RulesAPI.RuleEditParams; } - -export { EventsSinglePage }; diff --git a/src/resources/waiting-rooms/waiting-rooms.ts b/src/resources/waiting-rooms/waiting-rooms.ts index fcb4e9e3e7..9e37435ea0 100644 --- a/src/resources/waiting-rooms/waiting-rooms.ts +++ b/src/resources/waiting-rooms/waiting-rooms.ts @@ -2215,13 +2215,8 @@ export namespace WaitingRooms { export import Events = EventsAPI.Events; export import Event = EventsAPI.Event; export import UnnamedSchemaRef229c159575bc68a9c21f5a1615629cf6 = EventsAPI.UnnamedSchemaRef229c159575bc68a9c21f5a1615629cf6; - export import EventCreateResponse = EventsAPI.EventCreateResponse; - export import EventUpdateResponse = EventsAPI.EventUpdateResponse; - export import EventListResponse = EventsAPI.EventListResponse; export import EventDeleteResponse = EventsAPI.EventDeleteResponse; - export import EventEditResponse = EventsAPI.EventEditResponse; - export import EventGetResponse = EventsAPI.EventGetResponse; - export import EventListResponsesSinglePage = EventsAPI.EventListResponsesSinglePage; + export import EventsSinglePage = EventsAPI.EventsSinglePage; export import EventCreateParams = EventsAPI.EventCreateParams; export import EventUpdateParams = EventsAPI.EventUpdateParams; export import EventListParams = EventsAPI.EventListParams; @@ -2235,6 +2230,7 @@ export namespace WaitingRooms { export import RuleUpdateResponse = RulesAPI.RuleUpdateResponse; export import RuleDeleteResponse = RulesAPI.RuleDeleteResponse; export import RuleEditResponse = RulesAPI.RuleEditResponse; + export import RulesSinglePage = RulesAPI.RulesSinglePage; export import RuleCreateParams = RulesAPI.RuleCreateParams; export import RuleUpdateParams = RulesAPI.RuleUpdateParams; export import RuleListParams = RulesAPI.RuleListParams;