@@ -104,6 +104,76 @@ func (r *RuleService) Delete(ctx context.Context, ruleID string, body RuleDelete
104104 return
105105}
106106
107+ // Create zone token validation rules.
108+ //
109+ // A request can create multiple Token Validation Rules.
110+ func (r * RuleService ) BulkNew (ctx context.Context , params RuleBulkNewParams , opts ... option.RequestOption ) (res * pagination.SinglePage [TokenValidationRule ], err error ) {
111+ var raw * http.Response
112+ opts = slices .Concat (r .Options , opts )
113+ opts = append ([]option.RequestOption {option .WithResponseInto (& raw )}, opts ... )
114+ if params .ZoneID .Value == "" {
115+ err = errors .New ("missing required zone_id parameter" )
116+ return
117+ }
118+ path := fmt .Sprintf ("zones/%s/token_validation/rules/bulk" , params .ZoneID )
119+ cfg , err := requestconfig .NewRequestConfig (ctx , http .MethodPost , path , params , & res , opts ... )
120+ if err != nil {
121+ return nil , err
122+ }
123+ err = cfg .Execute ()
124+ if err != nil {
125+ return nil , err
126+ }
127+ res .SetPageConfig (cfg , raw )
128+ return res , nil
129+ }
130+
131+ // Create zone token validation rules.
132+ //
133+ // A request can create multiple Token Validation Rules.
134+ func (r * RuleService ) BulkNewAutoPaging (ctx context.Context , params RuleBulkNewParams , opts ... option.RequestOption ) * pagination.SinglePageAutoPager [TokenValidationRule ] {
135+ return pagination .NewSinglePageAutoPager (r .BulkNew (ctx , params , opts ... ))
136+ }
137+
138+ // Edit token validation rules.
139+ //
140+ // A request can update multiple Token Validation Rules.
141+ //
142+ // Rules can be re-ordered using the `position` field.
143+ //
144+ // Returns all updated rules.
145+ func (r * RuleService ) BulkEdit (ctx context.Context , params RuleBulkEditParams , opts ... option.RequestOption ) (res * pagination.SinglePage [TokenValidationRule ], err error ) {
146+ var raw * http.Response
147+ opts = slices .Concat (r .Options , opts )
148+ opts = append ([]option.RequestOption {option .WithResponseInto (& raw )}, opts ... )
149+ if params .ZoneID .Value == "" {
150+ err = errors .New ("missing required zone_id parameter" )
151+ return
152+ }
153+ path := fmt .Sprintf ("zones/%s/token_validation/rules/bulk" , params .ZoneID )
154+ cfg , err := requestconfig .NewRequestConfig (ctx , http .MethodPatch , path , params , & res , opts ... )
155+ if err != nil {
156+ return nil , err
157+ }
158+ err = cfg .Execute ()
159+ if err != nil {
160+ return nil , err
161+ }
162+ res .SetPageConfig (cfg , raw )
163+ return res , nil
164+ }
165+
166+ // Edit token validation rules.
167+ //
168+ // A request can update multiple Token Validation Rules.
169+ //
170+ // Rules can be re-ordered using the `position` field.
171+ //
172+ // Returns all updated rules.
173+ func (r * RuleService ) BulkEditAutoPaging (ctx context.Context , params RuleBulkEditParams , opts ... option.RequestOption ) * pagination.SinglePageAutoPager [TokenValidationRule ] {
174+ return pagination .NewSinglePageAutoPager (r .BulkEdit (ctx , params , opts ... ))
175+ }
176+
107177// Edit a zone token validation rule.
108178func (r * RuleService ) Edit (ctx context.Context , ruleID string , params RuleEditParams , opts ... option.RequestOption ) (res * TokenValidationRule , err error ) {
109179 var env RuleEditResponseEnvelope
@@ -511,6 +581,249 @@ func (r RuleDeleteResponseEnvelopeSuccess) IsKnown() bool {
511581 return false
512582}
513583
584+ type RuleBulkNewParams struct {
585+ // Identifier.
586+ ZoneID param.Field [string ] `path:"zone_id,required"`
587+ Body []RuleBulkNewParamsBody `json:"body,required"`
588+ }
589+
590+ func (r RuleBulkNewParams ) MarshalJSON () (data []byte , err error ) {
591+ return apijson .MarshalRoot (r .Body )
592+ }
593+
594+ // A Token Validation rule that can enforce security policies using JWT Tokens.
595+ type RuleBulkNewParamsBody struct {
596+ // Action to take on requests that match operations included in `selector` and fail
597+ // `expression`.
598+ Action param.Field [RuleBulkNewParamsBodyAction ] `json:"action,required"`
599+ // A human-readable description that gives more details than `title`.
600+ Description param.Field [string ] `json:"description,required"`
601+ // Toggle rule on or off.
602+ Enabled param.Field [bool ] `json:"enabled,required"`
603+ // Rule expression. Requests that fail to match this expression will be subject to
604+ // `action`.
605+ //
606+ // For details on expressions, see the
607+ // [Cloudflare Docs](https://developers.cloudflare.com/api-shield/security/jwt-validation/).
608+ Expression param.Field [string ] `json:"expression,required"`
609+ // Select operations covered by this rule.
610+ //
611+ // For details on selectors, see the
612+ // [Cloudflare Docs](https://developers.cloudflare.com/api-shield/security/jwt-validation/).
613+ Selector param.Field [RuleBulkNewParamsBodySelector ] `json:"selector,required"`
614+ // A human-readable name for the rule.
615+ Title param.Field [string ] `json:"title,required"`
616+ }
617+
618+ func (r RuleBulkNewParamsBody ) MarshalJSON () (data []byte , err error ) {
619+ return apijson .MarshalRoot (r )
620+ }
621+
622+ // Action to take on requests that match operations included in `selector` and fail
623+ // `expression`.
624+ type RuleBulkNewParamsBodyAction string
625+
626+ const (
627+ RuleBulkNewParamsBodyActionLog RuleBulkNewParamsBodyAction = "log"
628+ RuleBulkNewParamsBodyActionBlock RuleBulkNewParamsBodyAction = "block"
629+ )
630+
631+ func (r RuleBulkNewParamsBodyAction ) IsKnown () bool {
632+ switch r {
633+ case RuleBulkNewParamsBodyActionLog , RuleBulkNewParamsBodyActionBlock :
634+ return true
635+ }
636+ return false
637+ }
638+
639+ // Select operations covered by this rule.
640+ //
641+ // For details on selectors, see the
642+ // [Cloudflare Docs](https://developers.cloudflare.com/api-shield/security/jwt-validation/).
643+ type RuleBulkNewParamsBodySelector struct {
644+ // Ignore operations that were otherwise included by `include`.
645+ Exclude param.Field [[]RuleBulkNewParamsBodySelectorExclude ] `json:"exclude"`
646+ // Select all matching operations.
647+ Include param.Field [[]RuleBulkNewParamsBodySelectorInclude ] `json:"include"`
648+ }
649+
650+ func (r RuleBulkNewParamsBodySelector ) MarshalJSON () (data []byte , err error ) {
651+ return apijson .MarshalRoot (r )
652+ }
653+
654+ type RuleBulkNewParamsBodySelectorExclude struct {
655+ // Excluded operation IDs.
656+ OperationIDs param.Field [[]string ] `json:"operation_ids"`
657+ }
658+
659+ func (r RuleBulkNewParamsBodySelectorExclude ) MarshalJSON () (data []byte , err error ) {
660+ return apijson .MarshalRoot (r )
661+ }
662+
663+ type RuleBulkNewParamsBodySelectorInclude struct {
664+ // Included hostnames.
665+ Host param.Field [[]string ] `json:"host" format:"hostname"`
666+ }
667+
668+ func (r RuleBulkNewParamsBodySelectorInclude ) MarshalJSON () (data []byte , err error ) {
669+ return apijson .MarshalRoot (r )
670+ }
671+
672+ type RuleBulkEditParams struct {
673+ // Identifier.
674+ ZoneID param.Field [string ] `path:"zone_id,required"`
675+ Body []RuleBulkEditParamsBody `json:"body,required"`
676+ }
677+
678+ func (r RuleBulkEditParams ) MarshalJSON () (data []byte , err error ) {
679+ return apijson .MarshalRoot (r .Body )
680+ }
681+
682+ type RuleBulkEditParamsBody struct {
683+ // Rule ID this patch applies to
684+ ID param.Field [string ] `json:"id,required" format:"uuid"`
685+ // Action to take on requests that match operations included in `selector` and fail
686+ // `expression`.
687+ Action param.Field [RuleBulkEditParamsBodyAction ] `json:"action"`
688+ // A human-readable description that gives more details than `title`.
689+ Description param.Field [string ] `json:"description"`
690+ // Toggle rule on or off.
691+ Enabled param.Field [bool ] `json:"enabled"`
692+ // Rule expression. Requests that fail to match this expression will be subject to
693+ // `action`.
694+ //
695+ // For details on expressions, see the
696+ // [Cloudflare Docs](https://developers.cloudflare.com/api-shield/security/jwt-validation/).
697+ Expression param.Field [string ] `json:"expression"`
698+ // Update rule order among zone rules.
699+ Position param.Field [RuleBulkEditParamsBodyPositionUnion ] `json:"position"`
700+ // Select operations covered by this rule.
701+ //
702+ // For details on selectors, see the
703+ // [Cloudflare Docs](https://developers.cloudflare.com/api-shield/security/jwt-validation/).
704+ Selector param.Field [RuleBulkEditParamsBodySelector ] `json:"selector"`
705+ // A human-readable name for the rule.
706+ Title param.Field [string ] `json:"title"`
707+ }
708+
709+ func (r RuleBulkEditParamsBody ) MarshalJSON () (data []byte , err error ) {
710+ return apijson .MarshalRoot (r )
711+ }
712+
713+ // Action to take on requests that match operations included in `selector` and fail
714+ // `expression`.
715+ type RuleBulkEditParamsBodyAction string
716+
717+ const (
718+ RuleBulkEditParamsBodyActionLog RuleBulkEditParamsBodyAction = "log"
719+ RuleBulkEditParamsBodyActionBlock RuleBulkEditParamsBodyAction = "block"
720+ )
721+
722+ func (r RuleBulkEditParamsBodyAction ) IsKnown () bool {
723+ switch r {
724+ case RuleBulkEditParamsBodyActionLog , RuleBulkEditParamsBodyActionBlock :
725+ return true
726+ }
727+ return false
728+ }
729+
730+ // Update rule order among zone rules.
731+ type RuleBulkEditParamsBodyPosition struct {
732+ // Move rule to after rule with this ID.
733+ After param.Field [string ] `json:"after" format:"uuid"`
734+ // Move rule to before rule with this ID.
735+ Before param.Field [string ] `json:"before" format:"uuid"`
736+ // Move rule to this position
737+ Index param.Field [int64 ] `json:"index"`
738+ }
739+
740+ func (r RuleBulkEditParamsBodyPosition ) MarshalJSON () (data []byte , err error ) {
741+ return apijson .MarshalRoot (r )
742+ }
743+
744+ func (r RuleBulkEditParamsBodyPosition ) implementsRuleBulkEditParamsBodyPositionUnion () {}
745+
746+ // Update rule order among zone rules.
747+ //
748+ // Satisfied by [token_validation.RuleBulkEditParamsBodyPositionAPIShieldIndex],
749+ // [token_validation.RuleBulkEditParamsBodyPositionAPIShieldBefore],
750+ // [token_validation.RuleBulkEditParamsBodyPositionAPIShieldAfter],
751+ // [RuleBulkEditParamsBodyPosition].
752+ type RuleBulkEditParamsBodyPositionUnion interface {
753+ implementsRuleBulkEditParamsBodyPositionUnion ()
754+ }
755+
756+ type RuleBulkEditParamsBodyPositionAPIShieldIndex struct {
757+ // Move rule to this position
758+ Index param.Field [int64 ] `json:"index,required"`
759+ }
760+
761+ func (r RuleBulkEditParamsBodyPositionAPIShieldIndex ) MarshalJSON () (data []byte , err error ) {
762+ return apijson .MarshalRoot (r )
763+ }
764+
765+ func (r RuleBulkEditParamsBodyPositionAPIShieldIndex ) implementsRuleBulkEditParamsBodyPositionUnion () {
766+ }
767+
768+ // Move rule to after rule with ID.
769+ type RuleBulkEditParamsBodyPositionAPIShieldBefore struct {
770+ // Move rule to before rule with this ID.
771+ Before param.Field [string ] `json:"before" format:"uuid"`
772+ }
773+
774+ func (r RuleBulkEditParamsBodyPositionAPIShieldBefore ) MarshalJSON () (data []byte , err error ) {
775+ return apijson .MarshalRoot (r )
776+ }
777+
778+ func (r RuleBulkEditParamsBodyPositionAPIShieldBefore ) implementsRuleBulkEditParamsBodyPositionUnion () {
779+ }
780+
781+ // Move rule to before rule with ID.
782+ type RuleBulkEditParamsBodyPositionAPIShieldAfter struct {
783+ // Move rule to after rule with this ID.
784+ After param.Field [string ] `json:"after" format:"uuid"`
785+ }
786+
787+ func (r RuleBulkEditParamsBodyPositionAPIShieldAfter ) MarshalJSON () (data []byte , err error ) {
788+ return apijson .MarshalRoot (r )
789+ }
790+
791+ func (r RuleBulkEditParamsBodyPositionAPIShieldAfter ) implementsRuleBulkEditParamsBodyPositionUnion () {
792+ }
793+
794+ // Select operations covered by this rule.
795+ //
796+ // For details on selectors, see the
797+ // [Cloudflare Docs](https://developers.cloudflare.com/api-shield/security/jwt-validation/).
798+ type RuleBulkEditParamsBodySelector struct {
799+ // Ignore operations that were otherwise included by `include`.
800+ Exclude param.Field [[]RuleBulkEditParamsBodySelectorExclude ] `json:"exclude"`
801+ // Select all matching operations.
802+ Include param.Field [[]RuleBulkEditParamsBodySelectorInclude ] `json:"include"`
803+ }
804+
805+ func (r RuleBulkEditParamsBodySelector ) MarshalJSON () (data []byte , err error ) {
806+ return apijson .MarshalRoot (r )
807+ }
808+
809+ type RuleBulkEditParamsBodySelectorExclude struct {
810+ // Excluded operation IDs.
811+ OperationIDs param.Field [[]string ] `json:"operation_ids"`
812+ }
813+
814+ func (r RuleBulkEditParamsBodySelectorExclude ) MarshalJSON () (data []byte , err error ) {
815+ return apijson .MarshalRoot (r )
816+ }
817+
818+ type RuleBulkEditParamsBodySelectorInclude struct {
819+ // Included hostnames.
820+ Host param.Field [[]string ] `json:"host" format:"hostname"`
821+ }
822+
823+ func (r RuleBulkEditParamsBodySelectorInclude ) MarshalJSON () (data []byte , err error ) {
824+ return apijson .MarshalRoot (r )
825+ }
826+
514827type RuleEditParams struct {
515828 // Identifier.
516829 ZoneID param.Field [string ] `path:"zone_id,required"`
0 commit comments