Skip to content

Commit

Permalink
feat(api): api update (#2105)
Browse files Browse the repository at this point in the history
  • Loading branch information
stainless-app[bot] authored and meorphis committed Jan 13, 2025
1 parent 0c53d5b commit ad74309
Show file tree
Hide file tree
Showing 31 changed files with 4,159 additions and 100 deletions.
4 changes: 2 additions & 2 deletions .stats.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
configured_endpoints: 1361
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-bc0b27a6ed686a5f7ea5742498072a682dae635643c49cea95a3e5292868faa3.yml
configured_endpoints: 1397
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-d7ac42a96dd2d1679005f853c1c4c29034e362c73f2d75ad004d948ad8abfb74.yml
124 changes: 108 additions & 16 deletions api.md

Large diffs are not rendered by default.

192 changes: 191 additions & 1 deletion src/resources/filters.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,101 @@
// 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 {}
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<FilterCreateResponse | null> {
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<FirewallFilter> {
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<FirewallFiltersV4PagePaginationArray, FirewallFilter> {
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<FirewallFilter> {
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<FirewallFilter> {
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<FirewallFilter> {}

export interface FirewallFilter {
/**
Expand Down Expand Up @@ -31,3 +124,100 @@ 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<FirewallFilter>;

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;
}
Loading

0 comments on commit ad74309

Please sign in to comment.