Skip to content

Commit 080b997

Browse files
chore(api): update composite API spec
1 parent 5ee80f5 commit 080b997

File tree

7 files changed

+412
-5
lines changed

7 files changed

+412
-5
lines changed

.stats.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
configured_endpoints: 1889
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-081b52b8bd2d45843c3f99258cf4f58931bc5cd76f0b5a470d1f9c780622de6e.yml
3-
openapi_spec_hash: f22dbbc469af9002ead666ae5699f045
1+
configured_endpoints: 1891
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-79e87bbc9ff5cb53ed7706cf01778ff6436873f56a3fd29dcb23f4b0bc37747c.yml
3+
openapi_spec_hash: b3f5f9dd811a27973feca57c8b103cbd
44
config_hash: f02bc3ad56bdede6c515f996ca86012c

api.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9133,5 +9133,7 @@ Methods:
91339133
- <code title="post /zones/{zone_id}/token_validation/rules">client.tokenValidation.rules.<a href="./src/resources/token-validation/rules.ts">create</a>({ ...params }) -> TokenValidationRule</code>
91349134
- <code title="get /zones/{zone_id}/token_validation/rules">client.tokenValidation.rules.<a href="./src/resources/token-validation/rules.ts">list</a>({ ...params }) -> TokenValidationRulesV4PagePaginationArray</code>
91359135
- <code title="delete /zones/{zone_id}/token_validation/rules/{rule_id}">client.tokenValidation.rules.<a href="./src/resources/token-validation/rules.ts">delete</a>(ruleId, { ...params }) -> RuleDeleteResponse</code>
9136+
- <code title="post /zones/{zone_id}/token_validation/rules/bulk">client.tokenValidation.rules.<a href="./src/resources/token-validation/rules.ts">bulkCreate</a>([ ...body ]) -> TokenValidationRulesSinglePage</code>
9137+
- <code title="patch /zones/{zone_id}/token_validation/rules/bulk">client.tokenValidation.rules.<a href="./src/resources/token-validation/rules.ts">bulkEdit</a>([ ...body ]) -> TokenValidationRulesSinglePage</code>
91369138
- <code title="patch /zones/{zone_id}/token_validation/rules/{rule_id}">client.tokenValidation.rules.<a href="./src/resources/token-validation/rules.ts">edit</a>(ruleId, { ...params }) -> TokenValidationRule</code>
91379139
- <code title="get /zones/{zone_id}/token_validation/rules/{rule_id}">client.tokenValidation.rules.<a href="./src/resources/token-validation/rules.ts">get</a>(ruleId, { ...params }) -> TokenValidationRule</code>

src/resources/schema-validation/schemas.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ export interface SchemaDeleteResponse {
171171
/**
172172
* The ID of the schema that was just deleted
173173
*/
174-
schema_id: string;
174+
id: string;
175175
}
176176

177177
export interface SchemaCreateParams {

src/resources/token-validation/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,15 @@ export {
1515
export { TokenValidation } from './token-validation';
1616
export {
1717
TokenValidationRulesV4PagePaginationArray,
18+
TokenValidationRulesSinglePage,
1819
Rules,
1920
type TokenValidationRule,
2021
type RuleDeleteResponse,
2122
type RuleCreateParams,
2223
type RuleListParams,
2324
type RuleDeleteParams,
25+
type RuleBulkCreateParams,
26+
type RuleBulkEditParams,
2427
type RuleEditParams,
2528
type RuleGetParams,
2629
} from './rules';

src/resources/token-validation/rules.ts

Lines changed: 302 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import { APIResource } from '../../resource';
44
import * as Core from '../../core';
5-
import { V4PagePaginationArray, type V4PagePaginationArrayParams } from '../../pagination';
5+
import { SinglePage, V4PagePaginationArray, type V4PagePaginationArrayParams } from '../../pagination';
66

77
export class Rules extends APIResource {
88
/**
@@ -82,6 +82,81 @@ export class Rules extends APIResource {
8282
)._thenUnwrap((obj) => obj.result);
8383
}
8484

85+
/**
86+
* Create zone token validation rules.
87+
*
88+
* A request can create multiple Token Validation Rules.
89+
*
90+
* @example
91+
* ```ts
92+
* // Automatically fetches more pages as needed.
93+
* for await (const tokenValidationRule of client.tokenValidation.rules.bulkCreate(
94+
* {
95+
* zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
96+
* body: [
97+
* {
98+
* action: 'log',
99+
* description:
100+
* 'Long description for Token Validation Rule',
101+
* enabled: true,
102+
* expression:
103+
* 'is_jwt_valid("52973293-cb04-4a97-8f55-e7d2ad1107dd") or is_jwt_valid("46eab8d1-6376-45e3-968f-2c649d77d423")',
104+
* selector: {},
105+
* title: 'Example Token Validation Rule',
106+
* },
107+
* ],
108+
* },
109+
* )) {
110+
* // ...
111+
* }
112+
* ```
113+
*/
114+
bulkCreate(
115+
params: RuleBulkCreateParams,
116+
options?: Core.RequestOptions,
117+
): Core.PagePromise<TokenValidationRulesSinglePage, TokenValidationRule> {
118+
const { zone_id, body } = params;
119+
return this._client.getAPIList(
120+
`/zones/${zone_id}/token_validation/rules/bulk`,
121+
TokenValidationRulesSinglePage,
122+
{ body: body, method: 'post', ...options },
123+
);
124+
}
125+
126+
/**
127+
* Edit token validation rules.
128+
*
129+
* A request can update multiple Token Validation Rules.
130+
*
131+
* Rules can be re-ordered using the `position` field.
132+
*
133+
* Returns all updated rules.
134+
*
135+
* @example
136+
* ```ts
137+
* // Automatically fetches more pages as needed.
138+
* for await (const tokenValidationRule of client.tokenValidation.rules.bulkEdit(
139+
* {
140+
* zone_id: '023e105f4ecef8ad9ca31a8372d0c353',
141+
* body: [{ id: '0d9bf70c-92e1-4bb3-9411-34a3bcc59003' }],
142+
* },
143+
* )) {
144+
* // ...
145+
* }
146+
* ```
147+
*/
148+
bulkEdit(
149+
params: RuleBulkEditParams,
150+
options?: Core.RequestOptions,
151+
): Core.PagePromise<TokenValidationRulesSinglePage, TokenValidationRule> {
152+
const { zone_id, body } = params;
153+
return this._client.getAPIList(
154+
`/zones/${zone_id}/token_validation/rules/bulk`,
155+
TokenValidationRulesSinglePage,
156+
{ body: body, method: 'patch', ...options },
157+
);
158+
}
159+
85160
/**
86161
* Edit a zone token validation rule.
87162
*
@@ -136,6 +211,8 @@ export class Rules extends APIResource {
136211

137212
export class TokenValidationRulesV4PagePaginationArray extends V4PagePaginationArray<TokenValidationRule> {}
138213

214+
export class TokenValidationRulesSinglePage extends SinglePage<TokenValidationRule> {}
215+
139216
/**
140217
* A Token Validation rule that can enforce security policies using JWT Tokens.
141218
*/
@@ -357,6 +434,226 @@ export interface RuleDeleteParams {
357434
zone_id: string;
358435
}
359436

437+
export interface RuleBulkCreateParams {
438+
/**
439+
* Path param: Identifier.
440+
*/
441+
zone_id: string;
442+
443+
/**
444+
* Body param:
445+
*/
446+
body: Array<RuleBulkCreateParams.Body>;
447+
}
448+
449+
export namespace RuleBulkCreateParams {
450+
/**
451+
* A Token Validation rule that can enforce security policies using JWT Tokens.
452+
*/
453+
export interface Body {
454+
/**
455+
* Action to take on requests that match operations included in `selector` and fail
456+
* `expression`.
457+
*/
458+
action: 'log' | 'block';
459+
460+
/**
461+
* A human-readable description that gives more details than `title`.
462+
*/
463+
description: string;
464+
465+
/**
466+
* Toggle rule on or off.
467+
*/
468+
enabled: boolean;
469+
470+
/**
471+
* Rule expression. Requests that fail to match this expression will be subject to
472+
* `action`.
473+
*
474+
* For details on expressions, see the
475+
* [Cloudflare Docs](https://developers.cloudflare.com/api-shield/security/jwt-validation/).
476+
*/
477+
expression: string;
478+
479+
/**
480+
* Select operations covered by this rule.
481+
*
482+
* For details on selectors, see the
483+
* [Cloudflare Docs](https://developers.cloudflare.com/api-shield/security/jwt-validation/).
484+
*/
485+
selector: Body.Selector;
486+
487+
/**
488+
* A human-readable name for the rule.
489+
*/
490+
title: string;
491+
}
492+
493+
export namespace Body {
494+
/**
495+
* Select operations covered by this rule.
496+
*
497+
* For details on selectors, see the
498+
* [Cloudflare Docs](https://developers.cloudflare.com/api-shield/security/jwt-validation/).
499+
*/
500+
export interface Selector {
501+
/**
502+
* Ignore operations that were otherwise included by `include`.
503+
*/
504+
exclude?: Array<Selector.Exclude> | null;
505+
506+
/**
507+
* Select all matching operations.
508+
*/
509+
include?: Array<Selector.Include> | null;
510+
}
511+
512+
export namespace Selector {
513+
export interface Exclude {
514+
/**
515+
* Excluded operation IDs.
516+
*/
517+
operation_ids?: Array<string>;
518+
}
519+
520+
export interface Include {
521+
/**
522+
* Included hostnames.
523+
*/
524+
host?: Array<string>;
525+
}
526+
}
527+
}
528+
}
529+
530+
export interface RuleBulkEditParams {
531+
/**
532+
* Path param: Identifier.
533+
*/
534+
zone_id: string;
535+
536+
/**
537+
* Body param:
538+
*/
539+
body: Array<RuleBulkEditParams.Body>;
540+
}
541+
542+
export namespace RuleBulkEditParams {
543+
export interface Body {
544+
/**
545+
* Rule ID this patch applies to
546+
*/
547+
id: string;
548+
549+
/**
550+
* Action to take on requests that match operations included in `selector` and fail
551+
* `expression`.
552+
*/
553+
action?: 'log' | 'block';
554+
555+
/**
556+
* A human-readable description that gives more details than `title`.
557+
*/
558+
description?: string;
559+
560+
/**
561+
* Toggle rule on or off.
562+
*/
563+
enabled?: boolean;
564+
565+
/**
566+
* Rule expression. Requests that fail to match this expression will be subject to
567+
* `action`.
568+
*
569+
* For details on expressions, see the
570+
* [Cloudflare Docs](https://developers.cloudflare.com/api-shield/security/jwt-validation/).
571+
*/
572+
expression?: string;
573+
574+
/**
575+
* Update rule order among zone rules.
576+
*/
577+
position?: Body.APIShieldIndex | Body.APIShieldBefore | Body.APIShieldAfter;
578+
579+
/**
580+
* Select operations covered by this rule.
581+
*
582+
* For details on selectors, see the
583+
* [Cloudflare Docs](https://developers.cloudflare.com/api-shield/security/jwt-validation/).
584+
*/
585+
selector?: Body.Selector;
586+
587+
/**
588+
* A human-readable name for the rule.
589+
*/
590+
title?: string;
591+
}
592+
593+
export namespace Body {
594+
export interface APIShieldIndex {
595+
/**
596+
* Move rule to this position
597+
*/
598+
index: number;
599+
}
600+
601+
/**
602+
* Move rule to after rule with ID.
603+
*/
604+
export interface APIShieldBefore {
605+
/**
606+
* Move rule to before rule with this ID.
607+
*/
608+
before?: string;
609+
}
610+
611+
/**
612+
* Move rule to before rule with ID.
613+
*/
614+
export interface APIShieldAfter {
615+
/**
616+
* Move rule to after rule with this ID.
617+
*/
618+
after?: string;
619+
}
620+
621+
/**
622+
* Select operations covered by this rule.
623+
*
624+
* For details on selectors, see the
625+
* [Cloudflare Docs](https://developers.cloudflare.com/api-shield/security/jwt-validation/).
626+
*/
627+
export interface Selector {
628+
/**
629+
* Ignore operations that were otherwise included by `include`.
630+
*/
631+
exclude?: Array<Selector.Exclude> | null;
632+
633+
/**
634+
* Select all matching operations.
635+
*/
636+
include?: Array<Selector.Include> | null;
637+
}
638+
639+
export namespace Selector {
640+
export interface Exclude {
641+
/**
642+
* Excluded operation IDs.
643+
*/
644+
operation_ids?: Array<string>;
645+
}
646+
647+
export interface Include {
648+
/**
649+
* Included hostnames.
650+
*/
651+
host?: Array<string>;
652+
}
653+
}
654+
}
655+
}
656+
360657
export interface RuleEditParams {
361658
/**
362659
* Path param: Identifier.
@@ -478,15 +775,19 @@ export interface RuleGetParams {
478775
}
479776

480777
Rules.TokenValidationRulesV4PagePaginationArray = TokenValidationRulesV4PagePaginationArray;
778+
Rules.TokenValidationRulesSinglePage = TokenValidationRulesSinglePage;
481779

482780
export declare namespace Rules {
483781
export {
484782
type TokenValidationRule as TokenValidationRule,
485783
type RuleDeleteResponse as RuleDeleteResponse,
486784
TokenValidationRulesV4PagePaginationArray as TokenValidationRulesV4PagePaginationArray,
785+
TokenValidationRulesSinglePage as TokenValidationRulesSinglePage,
487786
type RuleCreateParams as RuleCreateParams,
488787
type RuleListParams as RuleListParams,
489788
type RuleDeleteParams as RuleDeleteParams,
789+
type RuleBulkCreateParams as RuleBulkCreateParams,
790+
type RuleBulkEditParams as RuleBulkEditParams,
490791
type RuleEditParams as RuleEditParams,
491792
type RuleGetParams as RuleGetParams,
492793
};

0 commit comments

Comments
 (0)