// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. import { APIResource } from '../../../../core/resource'; import * as Shared from '../../../shared'; import * as GroupsAPI from './groups'; import { BaseGroups, Group, GroupEditParams, GroupEditResponse, GroupGetParams, GroupGetResponse, GroupListParams, Groups, GroupsV4PagePaginationArray, } from './groups'; import * as RulesAPI from './rules'; import { AllowedModesAnomaly, BaseRules, RuleEditParams, RuleEditResponse, RuleGetParams, RuleGetResponse, RuleListParams, RuleListResponse, RuleListResponsesV4PagePaginationArray, Rules, WAFRuleGroup, } from './rules'; import { APIPromise } from '../../../../core/api-promise'; import { PagePromise, V4PagePaginationArray, type V4PagePaginationArrayParams, } from '../../../../core/pagination'; import { RequestOptions } from '../../../../internal/request-options'; import { path } from '../../../../internal/utils/path'; export class BasePackages extends APIResource { static override readonly _key: readonly ['firewall', 'waf', 'packages'] = Object.freeze([ 'firewall', 'waf', 'packages', ] as const); /** * 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/). * * @deprecated */ list( params: PackageListParams, options?: RequestOptions, ): PagePromise { const { zone_id, ...query } = params; return this._client.getAPIList( path`/zones/${zone_id}/firewall/waf/packages`, V4PagePaginationArray, { 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/). * * @deprecated */ get(packageID: string, params: PackageGetParams, options?: RequestOptions): APIPromise { const { zone_id } = params; return this._client.get(path`/zones/${zone_id}/firewall/waf/packages/${packageID}`, options); } } export class Packages extends BasePackages { groups: GroupsAPI.Groups = new GroupsAPI.Groups(this._client); rules: RulesAPI.Rules = new RulesAPI.Rules(this._client); } export type PackageListResponsesV4PagePaginationArray = 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; /** * Defines whether the API call was successful. */ success: true; } export interface Result { result?: unknown; } } export interface PackageListParams extends V4PagePaginationArrayParams { /** * Path param: Defines an 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 { /** * Defines an identifier. */ zone_id: string; } Packages.Groups = Groups; Packages.BaseGroups = BaseGroups; Packages.Rules = Rules; Packages.BaseRules = BaseRules; export declare namespace Packages { export { type PackageListResponse as PackageListResponse, type PackageGetResponse as PackageGetResponse, type PackageListResponsesV4PagePaginationArray as PackageListResponsesV4PagePaginationArray, type PackageListParams as PackageListParams, type PackageGetParams as PackageGetParams, }; export { Groups as Groups, BaseGroups as BaseGroups, type Group as Group, type GroupEditResponse as GroupEditResponse, type GroupGetResponse as GroupGetResponse, type GroupsV4PagePaginationArray as GroupsV4PagePaginationArray, type GroupListParams as GroupListParams, type GroupEditParams as GroupEditParams, type GroupGetParams as GroupGetParams, }; export { Rules as Rules, BaseRules as BaseRules, type AllowedModesAnomaly as AllowedModesAnomaly, type WAFRuleGroup as WAFRuleGroup, type RuleListResponse as RuleListResponse, type RuleEditResponse as RuleEditResponse, type RuleGetResponse as RuleGetResponse, type RuleListResponsesV4PagePaginationArray as RuleListResponsesV4PagePaginationArray, type RuleListParams as RuleListParams, type RuleEditParams as RuleEditParams, type RuleGetParams as RuleGetParams, }; }