Skip to content

Commit 02c9ed8

Browse files
feat(api): api update (#3826)
1 parent daa7705 commit 02c9ed8

File tree

3 files changed

+104
-17
lines changed

3 files changed

+104
-17
lines changed

.stats.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
configured_endpoints: 1493
2-
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-3d78f855257b55bbb80884f99c3802cae877968d140eed3557fcb2cdd5f937b3.yml
2+
openapi_spec_url: https://storage.googleapis.com/stainless-sdk-openapi-specs/cloudflare%2Fcloudflare-56f3021fb085763371fa342d21f231ef420fbfdddf6599c584bc84e609c421fa.yml

zero_trust/gatewayrule.go

Lines changed: 95 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -453,9 +453,9 @@ type RuleSetting struct {
453453
// Configure how session check behaves.
454454
CheckSession RuleSettingCheckSession `json:"check_session"`
455455
// Add your own custom resolvers to route queries that match the resolver policy.
456-
// Cannot be used when resolve_dns_through_cloudflare is set. DNS queries will
457-
// route to the address closest to their origin. Only valid when a rule's action is
458-
// set to 'resolve'.
456+
// Cannot be used when 'resolve_dns_through_cloudflare' or 'resolve_dns_internally'
457+
// are set. DNS queries will route to the address closest to their origin. Only
458+
// valid when a rule's action is set to 'resolve'.
459459
DNSResolvers RuleSettingDNSResolvers `json:"dns_resolvers"`
460460
// Configure how Gateway Proxy traffic egresses. You can enable this setting for
461461
// rules with Egress actions and filters, or omit it to indicate local egress via
@@ -486,9 +486,15 @@ type RuleSetting struct {
486486
PayloadLog RuleSettingPayloadLog `json:"payload_log"`
487487
// Settings that apply to quarantine rules
488488
Quarantine RuleSettingQuarantine `json:"quarantine"`
489+
// Configure to forward the query to the internal DNS service, passing the
490+
// specified 'view_id' as input. Cannot be set when 'dns_resolvers' are specified
491+
// or 'resolve_dns_through_cloudflare' is set. Only valid when a rule's action is
492+
// set to 'resolve'.
493+
ResolveDNSInternally RuleSettingResolveDNSInternally `json:"resolve_dns_internally"`
489494
// Enable to send queries that match the policy to Cloudflare's default 1.1.1.1 DNS
490-
// resolver. Cannot be set when dns_resolvers are specified. Only valid when a
491-
// rule's action is set to 'resolve'.
495+
// resolver. Cannot be set when 'dns_resolvers' are specified or
496+
// 'resolve_dns_internally' is set. Only valid when a rule's action is set to
497+
// 'resolve'.
492498
ResolveDNSThroughCloudflare bool `json:"resolve_dns_through_cloudflare"`
493499
// Configure behavior when an upstream cert is invalid or an SSL error occurs.
494500
UntrustedCERT RuleSettingUntrustedCERT `json:"untrusted_cert"`
@@ -517,6 +523,7 @@ type ruleSettingJSON struct {
517523
OverrideIPs apijson.Field
518524
PayloadLog apijson.Field
519525
Quarantine apijson.Field
526+
ResolveDNSInternally apijson.Field
520527
ResolveDNSThroughCloudflare apijson.Field
521528
UntrustedCERT apijson.Field
522529
raw string
@@ -616,9 +623,9 @@ func (r ruleSettingCheckSessionJSON) RawJSON() string {
616623
}
617624

618625
// Add your own custom resolvers to route queries that match the resolver policy.
619-
// Cannot be used when resolve_dns_through_cloudflare is set. DNS queries will
620-
// route to the address closest to their origin. Only valid when a rule's action is
621-
// set to 'resolve'.
626+
// Cannot be used when 'resolve_dns_through_cloudflare' or 'resolve_dns_internally'
627+
// are set. DNS queries will route to the address closest to their origin. Only
628+
// valid when a rule's action is set to 'resolve'.
622629
type RuleSettingDNSResolvers struct {
623630
IPV4 []DNSResolverSettingsV4 `json:"ipv4"`
624631
IPV6 []DNSResolverSettingsV6 `json:"ipv6"`
@@ -804,6 +811,55 @@ func (r RuleSettingQuarantineFileType) IsKnown() bool {
804811
return false
805812
}
806813

814+
// Configure to forward the query to the internal DNS service, passing the
815+
// specified 'view_id' as input. Cannot be set when 'dns_resolvers' are specified
816+
// or 'resolve_dns_through_cloudflare' is set. Only valid when a rule's action is
817+
// set to 'resolve'.
818+
type RuleSettingResolveDNSInternally struct {
819+
// The fallback behavior to apply when the internal DNS response code is different
820+
// from 'NOERROR' or when the response data only contains CNAME records for 'A' or
821+
// 'AAAA' queries.
822+
Fallback RuleSettingResolveDNSInternallyFallback `json:"fallback"`
823+
// The internal DNS view identifier that's passed to the internal DNS service.
824+
ViewID string `json:"view_id"`
825+
JSON ruleSettingResolveDNSInternallyJSON `json:"-"`
826+
}
827+
828+
// ruleSettingResolveDNSInternallyJSON contains the JSON metadata for the struct
829+
// [RuleSettingResolveDNSInternally]
830+
type ruleSettingResolveDNSInternallyJSON struct {
831+
Fallback apijson.Field
832+
ViewID apijson.Field
833+
raw string
834+
ExtraFields map[string]apijson.Field
835+
}
836+
837+
func (r *RuleSettingResolveDNSInternally) UnmarshalJSON(data []byte) (err error) {
838+
return apijson.UnmarshalRoot(data, r)
839+
}
840+
841+
func (r ruleSettingResolveDNSInternallyJSON) RawJSON() string {
842+
return r.raw
843+
}
844+
845+
// The fallback behavior to apply when the internal DNS response code is different
846+
// from 'NOERROR' or when the response data only contains CNAME records for 'A' or
847+
// 'AAAA' queries.
848+
type RuleSettingResolveDNSInternallyFallback string
849+
850+
const (
851+
RuleSettingResolveDNSInternallyFallbackNone RuleSettingResolveDNSInternallyFallback = "none"
852+
RuleSettingResolveDNSInternallyFallbackPublicDNS RuleSettingResolveDNSInternallyFallback = "public_dns"
853+
)
854+
855+
func (r RuleSettingResolveDNSInternallyFallback) IsKnown() bool {
856+
switch r {
857+
case RuleSettingResolveDNSInternallyFallbackNone, RuleSettingResolveDNSInternallyFallbackPublicDNS:
858+
return true
859+
}
860+
return false
861+
}
862+
807863
// Configure behavior when an upstream cert is invalid or an SSL error occurs.
808864
type RuleSettingUntrustedCERT struct {
809865
// The action performed when an untrusted certificate is seen. The default action
@@ -867,9 +923,9 @@ type RuleSettingParam struct {
867923
// Configure how session check behaves.
868924
CheckSession param.Field[RuleSettingCheckSessionParam] `json:"check_session"`
869925
// Add your own custom resolvers to route queries that match the resolver policy.
870-
// Cannot be used when resolve_dns_through_cloudflare is set. DNS queries will
871-
// route to the address closest to their origin. Only valid when a rule's action is
872-
// set to 'resolve'.
926+
// Cannot be used when 'resolve_dns_through_cloudflare' or 'resolve_dns_internally'
927+
// are set. DNS queries will route to the address closest to their origin. Only
928+
// valid when a rule's action is set to 'resolve'.
873929
DNSResolvers param.Field[RuleSettingDNSResolversParam] `json:"dns_resolvers"`
874930
// Configure how Gateway Proxy traffic egresses. You can enable this setting for
875931
// rules with Egress actions and filters, or omit it to indicate local egress via
@@ -900,9 +956,15 @@ type RuleSettingParam struct {
900956
PayloadLog param.Field[RuleSettingPayloadLogParam] `json:"payload_log"`
901957
// Settings that apply to quarantine rules
902958
Quarantine param.Field[RuleSettingQuarantineParam] `json:"quarantine"`
959+
// Configure to forward the query to the internal DNS service, passing the
960+
// specified 'view_id' as input. Cannot be set when 'dns_resolvers' are specified
961+
// or 'resolve_dns_through_cloudflare' is set. Only valid when a rule's action is
962+
// set to 'resolve'.
963+
ResolveDNSInternally param.Field[RuleSettingResolveDNSInternallyParam] `json:"resolve_dns_internally"`
903964
// Enable to send queries that match the policy to Cloudflare's default 1.1.1.1 DNS
904-
// resolver. Cannot be set when dns_resolvers are specified. Only valid when a
905-
// rule's action is set to 'resolve'.
965+
// resolver. Cannot be set when 'dns_resolvers' are specified or
966+
// 'resolve_dns_internally' is set. Only valid when a rule's action is set to
967+
// 'resolve'.
906968
ResolveDNSThroughCloudflare param.Field[bool] `json:"resolve_dns_through_cloudflare"`
907969
// Configure behavior when an upstream cert is invalid or an SSL error occurs.
908970
UntrustedCERT param.Field[RuleSettingUntrustedCERTParam] `json:"untrusted_cert"`
@@ -953,9 +1015,9 @@ func (r RuleSettingCheckSessionParam) MarshalJSON() (data []byte, err error) {
9531015
}
9541016

9551017
// Add your own custom resolvers to route queries that match the resolver policy.
956-
// Cannot be used when resolve_dns_through_cloudflare is set. DNS queries will
957-
// route to the address closest to their origin. Only valid when a rule's action is
958-
// set to 'resolve'.
1018+
// Cannot be used when 'resolve_dns_through_cloudflare' or 'resolve_dns_internally'
1019+
// are set. DNS queries will route to the address closest to their origin. Only
1020+
// valid when a rule's action is set to 'resolve'.
9591021
type RuleSettingDNSResolversParam struct {
9601022
IPV4 param.Field[[]DNSResolverSettingsV4Param] `json:"ipv4"`
9611023
IPV6 param.Field[[]DNSResolverSettingsV6Param] `json:"ipv6"`
@@ -1031,6 +1093,23 @@ func (r RuleSettingQuarantineParam) MarshalJSON() (data []byte, err error) {
10311093
return apijson.MarshalRoot(r)
10321094
}
10331095

1096+
// Configure to forward the query to the internal DNS service, passing the
1097+
// specified 'view_id' as input. Cannot be set when 'dns_resolvers' are specified
1098+
// or 'resolve_dns_through_cloudflare' is set. Only valid when a rule's action is
1099+
// set to 'resolve'.
1100+
type RuleSettingResolveDNSInternallyParam struct {
1101+
// The fallback behavior to apply when the internal DNS response code is different
1102+
// from 'NOERROR' or when the response data only contains CNAME records for 'A' or
1103+
// 'AAAA' queries.
1104+
Fallback param.Field[RuleSettingResolveDNSInternallyFallback] `json:"fallback"`
1105+
// The internal DNS view identifier that's passed to the internal DNS service.
1106+
ViewID param.Field[string] `json:"view_id"`
1107+
}
1108+
1109+
func (r RuleSettingResolveDNSInternallyParam) MarshalJSON() (data []byte, err error) {
1110+
return apijson.MarshalRoot(r)
1111+
}
1112+
10341113
// Configure behavior when an upstream cert is invalid or an SSL error occurs.
10351114
type RuleSettingUntrustedCERTParam struct {
10361115
// The action performed when an untrusted certificate is seen. The default action

zero_trust/gatewayrule_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,10 @@ func TestGatewayRuleNewWithOptionalParams(t *testing.T) {
105105
Quarantine: cloudflare.F(zero_trust.RuleSettingQuarantineParam{
106106
FileTypes: cloudflare.F([]zero_trust.RuleSettingQuarantineFileType{zero_trust.RuleSettingQuarantineFileTypeExe}),
107107
}),
108+
ResolveDNSInternally: cloudflare.F(zero_trust.RuleSettingResolveDNSInternallyParam{
109+
Fallback: cloudflare.F(zero_trust.RuleSettingResolveDNSInternallyFallbackNone),
110+
ViewID: cloudflare.F("view_id"),
111+
}),
108112
ResolveDNSThroughCloudflare: cloudflare.F(true),
109113
UntrustedCERT: cloudflare.F(zero_trust.RuleSettingUntrustedCERTParam{
110114
Action: cloudflare.F(zero_trust.RuleSettingUntrustedCERTActionPassThrough),
@@ -224,6 +228,10 @@ func TestGatewayRuleUpdateWithOptionalParams(t *testing.T) {
224228
Quarantine: cloudflare.F(zero_trust.RuleSettingQuarantineParam{
225229
FileTypes: cloudflare.F([]zero_trust.RuleSettingQuarantineFileType{zero_trust.RuleSettingQuarantineFileTypeExe}),
226230
}),
231+
ResolveDNSInternally: cloudflare.F(zero_trust.RuleSettingResolveDNSInternallyParam{
232+
Fallback: cloudflare.F(zero_trust.RuleSettingResolveDNSInternallyFallbackNone),
233+
ViewID: cloudflare.F("view_id"),
234+
}),
227235
ResolveDNSThroughCloudflare: cloudflare.F(true),
228236
UntrustedCERT: cloudflare.F(zero_trust.RuleSettingUntrustedCERTParam{
229237
Action: cloudflare.F(zero_trust.RuleSettingUntrustedCERTActionPassThrough),

0 commit comments

Comments
 (0)