From 2566a6956d2ead63d634f72db20f1ad58edad6e6 Mon Sep 17 00:00:00 2001 From: "stainless-app[bot]" <142633134+stainless-app[bot]@users.noreply.github.com> Date: Fri, 5 Apr 2024 01:58:44 +0000 Subject: [PATCH] feat(api): update via SDK Studio (#1667) --- accounts/member.go | 180 +-- accounts/member_test.go | 2 +- accounts/role.go | 53 +- alerting/destinationpagerduty.go | 19 +- alerting/policy.go | 727 +++------- alerting/policy_test.go | 44 +- api.md | 138 +- bot_management/botmanagement.go | 728 +++------- bot_management/botmanagement_test.go | 2 +- .../hostnameassociation.go | 12 +- .../hostnameassociation_test.go | 2 +- challenges/widget.go | 12 +- challenges/widget_test.go | 4 +- custom_certificates/customcertificate.go | 110 +- custom_certificates/customcertificate_test.go | 8 +- custom_hostnames/customhostname.go | 1286 +++-------------- dns/firewall.go | 174 ++- dns/firewall_test.go | 10 +- email_routing/address.go | 147 +- email_routing/emailrouting.go | 259 +--- email_routing/rule.go | 868 ++--------- email_routing/rule_test.go | 44 +- email_routing/rulecatchall.go | 188 +-- email_routing/rulecatchall_test.go | 16 +- internal/shared/union.go | 12 +- load_balancers/loadbalancer.go | 513 +++++++ load_balancers/pool.go | 686 +-------- load_balancers/pool_test.go | 94 +- memberships/membership.go | 3 +- user/invite.go | 34 +- user/loadbalancerpool.go | 932 +----------- user/loadbalancerpool_test.go | 73 +- user/tokenpermissiongroup.go | 64 + 33 files changed, 2028 insertions(+), 5416 deletions(-) diff --git a/accounts/member.go b/accounts/member.go index 7a7ec825e47..b25fb9e989e 100644 --- a/accounts/member.go +++ b/accounts/member.go @@ -15,6 +15,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/requestconfig" "github.com/cloudflare/cloudflare-go/v2/internal/shared" "github.com/cloudflare/cloudflare-go/v2/option" + "github.com/cloudflare/cloudflare-go/v2/user" ) // MemberService contains methods and other services that help with interacting @@ -113,10 +114,10 @@ type Member struct { // Membership identifier tag. ID string `json:"id,required"` // Roles assigned to this member. - Roles []Role `json:"roles,required"` - Status interface{} `json:"status,required"` - User MemberUser `json:"user,required"` - JSON memberJSON `json:"-"` + Roles []MemberRole `json:"roles,required"` + Status interface{} `json:"status,required"` + User MemberUser `json:"user,required"` + JSON memberJSON `json:"-"` } // memberJSON contains the JSON metadata for the struct [Member] @@ -137,6 +138,35 @@ func (r memberJSON) RawJSON() string { return r.raw } +type MemberRole struct { + // Role identifier tag. + ID string `json:"id,required"` + // Description of role's permissions. + Description string `json:"description,required"` + // Role name. + Name string `json:"name,required"` + Permissions user.Permission `json:"permissions,required"` + JSON memberRoleJSON `json:"-"` +} + +// memberRoleJSON contains the JSON metadata for the struct [MemberRole] +type memberRoleJSON struct { + ID apijson.Field + Description apijson.Field + Name apijson.Field + Permissions apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *MemberRole) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r memberRoleJSON) RawJSON() string { + return r.raw +} + type MemberUser struct { // The contact email address of the user. Email string `json:"email,required"` @@ -171,75 +201,13 @@ func (r memberUserJSON) RawJSON() string { return r.raw } -type MemberPermission struct { - Analytics PermissionGrant `json:"analytics"` - Billing PermissionGrant `json:"billing"` - CachePurge PermissionGrant `json:"cache_purge"` - DNS PermissionGrant `json:"dns"` - DNSRecords PermissionGrant `json:"dns_records"` - Lb PermissionGrant `json:"lb"` - Logs PermissionGrant `json:"logs"` - Organization PermissionGrant `json:"organization"` - SSL PermissionGrant `json:"ssl"` - WAF PermissionGrant `json:"waf"` - ZoneSettings PermissionGrant `json:"zone_settings"` - Zones PermissionGrant `json:"zones"` - JSON memberPermissionJSON `json:"-"` -} - -// memberPermissionJSON contains the JSON metadata for the struct -// [MemberPermission] -type memberPermissionJSON struct { - Analytics apijson.Field - Billing apijson.Field - CachePurge apijson.Field - DNS apijson.Field - DNSRecords apijson.Field - Lb apijson.Field - Logs apijson.Field - Organization apijson.Field - SSL apijson.Field - WAF apijson.Field - ZoneSettings apijson.Field - Zones apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MemberPermission) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r memberPermissionJSON) RawJSON() string { - return r.raw -} - -type MemberPermissionParam struct { - Analytics param.Field[PermissionGrantParam] `json:"analytics"` - Billing param.Field[PermissionGrantParam] `json:"billing"` - CachePurge param.Field[PermissionGrantParam] `json:"cache_purge"` - DNS param.Field[PermissionGrantParam] `json:"dns"` - DNSRecords param.Field[PermissionGrantParam] `json:"dns_records"` - Lb param.Field[PermissionGrantParam] `json:"lb"` - Logs param.Field[PermissionGrantParam] `json:"logs"` - Organization param.Field[PermissionGrantParam] `json:"organization"` - SSL param.Field[PermissionGrantParam] `json:"ssl"` - WAF param.Field[PermissionGrantParam] `json:"waf"` - ZoneSettings param.Field[PermissionGrantParam] `json:"zone_settings"` - Zones param.Field[PermissionGrantParam] `json:"zones"` -} - -func (r MemberPermissionParam) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - type MemberWithCode struct { // Membership identifier tag. ID string `json:"id,required"` // Roles assigned to this member. - Roles []Role `json:"roles,required"` - Status interface{} `json:"status,required"` - User MemberWithCodeUser `json:"user,required"` + Roles []MemberWithCodeRole `json:"roles,required"` + Status interface{} `json:"status,required"` + User MemberWithCodeUser `json:"user,required"` // The unique activation code for the account membership. Code string `json:"code"` JSON memberWithCodeJSON `json:"-"` @@ -264,6 +232,36 @@ func (r memberWithCodeJSON) RawJSON() string { return r.raw } +type MemberWithCodeRole struct { + // Role identifier tag. + ID string `json:"id,required"` + // Description of role's permissions. + Description string `json:"description,required"` + // Role name. + Name string `json:"name,required"` + Permissions user.Permission `json:"permissions,required"` + JSON memberWithCodeRoleJSON `json:"-"` +} + +// memberWithCodeRoleJSON contains the JSON metadata for the struct +// [MemberWithCodeRole] +type memberWithCodeRoleJSON struct { + ID apijson.Field + Description apijson.Field + Name apijson.Field + Permissions apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *MemberWithCodeRole) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r memberWithCodeRoleJSON) RawJSON() string { + return r.raw +} + type MemberWithCodeUser struct { // The contact email address of the user. Email string `json:"email,required"` @@ -307,7 +305,7 @@ type MemberListResponse struct { // Member Name. Name string `json:"name,required,nullable"` // Roles assigned to this Member. - Roles []MemberListResponseRole `json:"roles,required"` + Roles []Role `json:"roles,required"` // A member's status in the organization. Status MemberListResponseStatus `json:"status,required"` JSON memberListResponseJSON `json:"-"` @@ -333,37 +331,6 @@ func (r memberListResponseJSON) RawJSON() string { return r.raw } -type MemberListResponseRole struct { - // Role identifier tag. - ID string `json:"id,required"` - // Description of role's permissions. - Description string `json:"description,required"` - // Role Name. - Name string `json:"name,required"` - // Access permissions for this User. - Permissions []string `json:"permissions,required"` - JSON memberListResponseRoleJSON `json:"-"` -} - -// memberListResponseRoleJSON contains the JSON metadata for the struct -// [MemberListResponseRole] -type memberListResponseRoleJSON struct { - ID apijson.Field - Description apijson.Field - Name apijson.Field - Permissions apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *MemberListResponseRole) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r memberListResponseRoleJSON) RawJSON() string { - return r.raw -} - // A member's status in the organization. type MemberListResponseStatus string @@ -476,13 +443,22 @@ func (r MemberNewResponseEnvelopeSuccess) IsKnown() bool { type MemberUpdateParams struct { AccountID param.Field[interface{}] `path:"account_id,required"` // Roles assigned to this member. - Roles param.Field[[]RoleParam] `json:"roles,required"` + Roles param.Field[[]MemberUpdateParamsRole] `json:"roles,required"` } func (r MemberUpdateParams) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } +type MemberUpdateParamsRole struct { + // Role identifier tag. + ID param.Field[string] `json:"id,required"` +} + +func (r MemberUpdateParamsRole) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + type MemberUpdateResponseEnvelope struct { Errors []shared.UnnamedSchemaRef3248f24329456e19dfa042fff9986f72 `json:"errors,required"` Messages []shared.UnnamedSchemaRef3248f24329456e19dfa042fff9986f72 `json:"messages,required"` diff --git a/accounts/member_test.go b/accounts/member_test.go index 5768798bc2f..8bd5143efdf 100644 --- a/accounts/member_test.go +++ b/accounts/member_test.go @@ -62,7 +62,7 @@ func TestMemberUpdate(t *testing.T) { "4536bcfad5faccb111b47003c79917fa", accounts.MemberUpdateParams{ AccountID: cloudflare.F[any](map[string]interface{}{}), - Roles: cloudflare.F([]accounts.RoleParam{{ + Roles: cloudflare.F([]accounts.MemberUpdateParamsRole{{ ID: cloudflare.F("3536bcfad5faccb999b47003c79917fb"), }, { ID: cloudflare.F("3536bcfad5faccb999b47003c79917fb"), diff --git a/accounts/role.go b/accounts/role.go index 9f18109bfe7..f954316a81c 100644 --- a/accounts/role.go +++ b/accounts/role.go @@ -33,7 +33,7 @@ func NewRoleService(opts ...option.RequestOption) (r *RoleService) { } // Get all available roles for an account. -func (r *RoleService) List(ctx context.Context, query RoleListParams, opts ...option.RequestOption) (res *pagination.SinglePage[RoleListResponse], err error) { +func (r *RoleService) List(ctx context.Context, query RoleListParams, opts ...option.RequestOption) (res *pagination.SinglePage[Role], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -51,7 +51,7 @@ func (r *RoleService) List(ctx context.Context, query RoleListParams, opts ...op } // Get all available roles for an account. -func (r *RoleService) ListAutoPaging(ctx context.Context, query RoleListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[RoleListResponse] { +func (r *RoleService) ListAutoPaging(ctx context.Context, query RoleListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[Role] { return pagination.NewSinglePageAutoPager(r.List(ctx, query, opts...)) } @@ -104,10 +104,11 @@ type Role struct { ID string `json:"id,required"` // Description of role's permissions. Description string `json:"description,required"` - // Role name. - Name string `json:"name,required"` - Permissions MemberPermission `json:"permissions,required"` - JSON roleJSON `json:"-"` + // Role Name. + Name string `json:"name,required"` + // Access permissions for this User. + Permissions []string `json:"permissions,required"` + JSON roleJSON `json:"-"` } // roleJSON contains the JSON metadata for the struct [Role] @@ -128,46 +129,6 @@ func (r roleJSON) RawJSON() string { return r.raw } -type RoleParam struct { - // Role identifier tag. - ID param.Field[string] `json:"id,required"` -} - -func (r RoleParam) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type RoleListResponse struct { - // Role identifier tag. - ID string `json:"id,required"` - // Description of role's permissions. - Description string `json:"description,required"` - // Role Name. - Name string `json:"name,required"` - // Access permissions for this User. - Permissions []string `json:"permissions,required"` - JSON roleListResponseJSON `json:"-"` -} - -// roleListResponseJSON contains the JSON metadata for the struct -// [RoleListResponse] -type roleListResponseJSON struct { - ID apijson.Field - Description apijson.Field - Name apijson.Field - Permissions apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RoleListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r roleListResponseJSON) RawJSON() string { - return r.raw -} - type RoleListParams struct { AccountID param.Field[interface{}] `path:"account_id,required"` } diff --git a/alerting/destinationpagerduty.go b/alerting/destinationpagerduty.go index 09cb98c7675..dc80871d71e 100644 --- a/alerting/destinationpagerduty.go +++ b/alerting/destinationpagerduty.go @@ -59,7 +59,7 @@ func (r *DestinationPagerdutyService) Delete(ctx context.Context, body Destinati } // Get a list of all configured PagerDuty services. -func (r *DestinationPagerdutyService) Get(ctx context.Context, query DestinationPagerdutyGetParams, opts ...option.RequestOption) (res *[]AlertingPagerduty, err error) { +func (r *DestinationPagerdutyService) Get(ctx context.Context, query DestinationPagerdutyGetParams, opts ...option.RequestOption) (res *[]Pagerduty, err error) { opts = append(r.Options[:], opts...) var env DestinationPagerdutyGetResponseEnvelope path := fmt.Sprintf("accounts/%s/alerting/v3/destinations/pagerduty", query.AccountID) @@ -84,28 +84,27 @@ func (r *DestinationPagerdutyService) Link(ctx context.Context, tokenID string, return } -type AlertingPagerduty struct { +type Pagerduty struct { // UUID ID string `json:"id"` // The name of the pagerduty service. - Name string `json:"name"` - JSON alertingPagerdutyJSON `json:"-"` + Name string `json:"name"` + JSON pagerdutyJSON `json:"-"` } -// alertingPagerdutyJSON contains the JSON metadata for the struct -// [AlertingPagerduty] -type alertingPagerdutyJSON struct { +// pagerdutyJSON contains the JSON metadata for the struct [Pagerduty] +type pagerdutyJSON struct { ID apijson.Field Name apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *AlertingPagerduty) UnmarshalJSON(data []byte) (err error) { +func (r *Pagerduty) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r alertingPagerdutyJSON) RawJSON() string { +func (r pagerdutyJSON) RawJSON() string { return r.raw } @@ -290,7 +289,7 @@ type DestinationPagerdutyGetParams struct { type DestinationPagerdutyGetResponseEnvelope struct { Errors []shared.UnnamedSchemaRef3248f24329456e19dfa042fff9986f72 `json:"errors,required"` Messages []shared.UnnamedSchemaRef3248f24329456e19dfa042fff9986f72 `json:"messages,required"` - Result []AlertingPagerduty `json:"result,required,nullable"` + Result []Pagerduty `json:"result,required,nullable"` // Whether the API call was successful Success DestinationPagerdutyGetResponseEnvelopeSuccess `json:"success,required"` ResultInfo DestinationPagerdutyGetResponseEnvelopeResultInfo `json:"result_info"` diff --git a/alerting/policy.go b/alerting/policy.go index 0fc33cf51d5..81620b81bf1 100644 --- a/alerting/policy.go +++ b/alerting/policy.go @@ -6,7 +6,6 @@ import ( "context" "fmt" "net/http" - "reflect" "time" "github.com/cloudflare/cloudflare-go/v2/internal/apijson" @@ -15,7 +14,6 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/requestconfig" "github.com/cloudflare/cloudflare-go/v2/internal/shared" "github.com/cloudflare/cloudflare-go/v2/option" - "github.com/tidwall/gjson" ) // PolicyService contains methods and other services that help with interacting @@ -62,7 +60,7 @@ func (r *PolicyService) Update(ctx context.Context, policyID string, params Poli } // Get a list of all Notification policies. -func (r *PolicyService) List(ctx context.Context, query PolicyListParams, opts ...option.RequestOption) (res *pagination.SinglePage[AlertingPolicies], err error) { +func (r *PolicyService) List(ctx context.Context, query PolicyListParams, opts ...option.RequestOption) (res *pagination.SinglePage[Policies], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -80,7 +78,7 @@ func (r *PolicyService) List(ctx context.Context, query PolicyListParams, opts . } // Get a list of all Notification policies. -func (r *PolicyService) ListAutoPaging(ctx context.Context, query PolicyListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[AlertingPolicies] { +func (r *PolicyService) ListAutoPaging(ctx context.Context, query PolicyListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[Policies] { return pagination.NewSinglePageAutoPager(r.List(ctx, query, opts...)) } @@ -98,7 +96,7 @@ func (r *PolicyService) Delete(ctx context.Context, policyID string, body Policy } // Get details for a single policy. -func (r *PolicyService) Get(ctx context.Context, policyID string, query PolicyGetParams, opts ...option.RequestOption) (res *AlertingPolicies, err error) { +func (r *PolicyService) Get(ctx context.Context, policyID string, query PolicyGetParams, opts ...option.RequestOption) (res *Policies, err error) { opts = append(r.Options[:], opts...) var env PolicyGetResponseEnvelope path := fmt.Sprintf("accounts/%s/alerting/v3/policies/%s", query.AccountID, policyID) @@ -110,130 +108,10 @@ func (r *PolicyService) Get(ctx context.Context, policyID string, query PolicyGe return } -type AlertingPolicies struct { - // The unique identifier of a notification policy - ID string `json:"id"` - // Refers to which event will trigger a Notification dispatch. You can use the - // endpoint to get available alert types which then will give you a list of - // possible values. - AlertType AlertingPoliciesAlertType `json:"alert_type"` - Created time.Time `json:"created" format:"date-time"` - // Optional description for the Notification policy. - Description string `json:"description"` - // Whether or not the Notification policy is enabled. - Enabled bool `json:"enabled"` - // Optional filters that allow you to be alerted only on a subset of events for - // that alert type based on some criteria. This is only available for select alert - // types. See alert type documentation for more details. - Filters AlertingPoliciesFilters `json:"filters"` - // List of IDs that will be used when dispatching a notification. IDs for email - // type will be the email address. - Mechanisms map[string][]AlertingPoliciesMechanisms `json:"mechanisms"` - Modified time.Time `json:"modified" format:"date-time"` - // Name of the policy. - Name string `json:"name"` - JSON alertingPoliciesJSON `json:"-"` -} - -// alertingPoliciesJSON contains the JSON metadata for the struct -// [AlertingPolicies] -type alertingPoliciesJSON struct { - ID apijson.Field - AlertType apijson.Field - Created apijson.Field - Description apijson.Field - Enabled apijson.Field - Filters apijson.Field - Mechanisms apijson.Field - Modified apijson.Field - Name apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AlertingPolicies) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r alertingPoliciesJSON) RawJSON() string { - return r.raw -} - -// Refers to which event will trigger a Notification dispatch. You can use the -// endpoint to get available alert types which then will give you a list of -// possible values. -type AlertingPoliciesAlertType string - -const ( - AlertingPoliciesAlertTypeAccessCustomCertificateExpirationType AlertingPoliciesAlertType = "access_custom_certificate_expiration_type" - AlertingPoliciesAlertTypeAdvancedDDoSAttackL4Alert AlertingPoliciesAlertType = "advanced_ddos_attack_l4_alert" - AlertingPoliciesAlertTypeAdvancedDDoSAttackL7Alert AlertingPoliciesAlertType = "advanced_ddos_attack_l7_alert" - AlertingPoliciesAlertTypeAdvancedHTTPAlertError AlertingPoliciesAlertType = "advanced_http_alert_error" - AlertingPoliciesAlertTypeBGPHijackNotification AlertingPoliciesAlertType = "bgp_hijack_notification" - AlertingPoliciesAlertTypeBillingUsageAlert AlertingPoliciesAlertType = "billing_usage_alert" - AlertingPoliciesAlertTypeBlockNotificationBlockRemoved AlertingPoliciesAlertType = "block_notification_block_removed" - AlertingPoliciesAlertTypeBlockNotificationNewBlock AlertingPoliciesAlertType = "block_notification_new_block" - AlertingPoliciesAlertTypeBlockNotificationReviewRejected AlertingPoliciesAlertType = "block_notification_review_rejected" - AlertingPoliciesAlertTypeBrandProtectionAlert AlertingPoliciesAlertType = "brand_protection_alert" - AlertingPoliciesAlertTypeBrandProtectionDigest AlertingPoliciesAlertType = "brand_protection_digest" - AlertingPoliciesAlertTypeClickhouseAlertFwAnomaly AlertingPoliciesAlertType = "clickhouse_alert_fw_anomaly" - AlertingPoliciesAlertTypeClickhouseAlertFwEntAnomaly AlertingPoliciesAlertType = "clickhouse_alert_fw_ent_anomaly" - AlertingPoliciesAlertTypeCustomSSLCertificateEventType AlertingPoliciesAlertType = "custom_ssl_certificate_event_type" - AlertingPoliciesAlertTypeDedicatedSSLCertificateEventType AlertingPoliciesAlertType = "dedicated_ssl_certificate_event_type" - AlertingPoliciesAlertTypeDosAttackL4 AlertingPoliciesAlertType = "dos_attack_l4" - AlertingPoliciesAlertTypeDosAttackL7 AlertingPoliciesAlertType = "dos_attack_l7" - AlertingPoliciesAlertTypeExpiringServiceTokenAlert AlertingPoliciesAlertType = "expiring_service_token_alert" - AlertingPoliciesAlertTypeFailingLogpushJobDisabledAlert AlertingPoliciesAlertType = "failing_logpush_job_disabled_alert" - AlertingPoliciesAlertTypeFbmAutoAdvertisement AlertingPoliciesAlertType = "fbm_auto_advertisement" - AlertingPoliciesAlertTypeFbmDosdAttack AlertingPoliciesAlertType = "fbm_dosd_attack" - AlertingPoliciesAlertTypeFbmVolumetricAttack AlertingPoliciesAlertType = "fbm_volumetric_attack" - AlertingPoliciesAlertTypeHealthCheckStatusNotification AlertingPoliciesAlertType = "health_check_status_notification" - AlertingPoliciesAlertTypeHostnameAopCustomCertificateExpirationType AlertingPoliciesAlertType = "hostname_aop_custom_certificate_expiration_type" - AlertingPoliciesAlertTypeHTTPAlertEdgeError AlertingPoliciesAlertType = "http_alert_edge_error" - AlertingPoliciesAlertTypeHTTPAlertOriginError AlertingPoliciesAlertType = "http_alert_origin_error" - AlertingPoliciesAlertTypeIncidentAlert AlertingPoliciesAlertType = "incident_alert" - AlertingPoliciesAlertTypeLoadBalancingHealthAlert AlertingPoliciesAlertType = "load_balancing_health_alert" - AlertingPoliciesAlertTypeLoadBalancingPoolEnablementAlert AlertingPoliciesAlertType = "load_balancing_pool_enablement_alert" - AlertingPoliciesAlertTypeLogoMatchAlert AlertingPoliciesAlertType = "logo_match_alert" - AlertingPoliciesAlertTypeMagicTunnelHealthCheckEvent AlertingPoliciesAlertType = "magic_tunnel_health_check_event" - AlertingPoliciesAlertTypeMaintenanceEventNotification AlertingPoliciesAlertType = "maintenance_event_notification" - AlertingPoliciesAlertTypeMTLSCertificateStoreCertificateExpirationType AlertingPoliciesAlertType = "mtls_certificate_store_certificate_expiration_type" - AlertingPoliciesAlertTypePagesEventAlert AlertingPoliciesAlertType = "pages_event_alert" - AlertingPoliciesAlertTypeRadarNotification AlertingPoliciesAlertType = "radar_notification" - AlertingPoliciesAlertTypeRealOriginMonitoring AlertingPoliciesAlertType = "real_origin_monitoring" - AlertingPoliciesAlertTypeScriptmonitorAlertNewCodeChangeDetections AlertingPoliciesAlertType = "scriptmonitor_alert_new_code_change_detections" - AlertingPoliciesAlertTypeScriptmonitorAlertNewHosts AlertingPoliciesAlertType = "scriptmonitor_alert_new_hosts" - AlertingPoliciesAlertTypeScriptmonitorAlertNewMaliciousHosts AlertingPoliciesAlertType = "scriptmonitor_alert_new_malicious_hosts" - AlertingPoliciesAlertTypeScriptmonitorAlertNewMaliciousScripts AlertingPoliciesAlertType = "scriptmonitor_alert_new_malicious_scripts" - AlertingPoliciesAlertTypeScriptmonitorAlertNewMaliciousURL AlertingPoliciesAlertType = "scriptmonitor_alert_new_malicious_url" - AlertingPoliciesAlertTypeScriptmonitorAlertNewMaxLengthResourceURL AlertingPoliciesAlertType = "scriptmonitor_alert_new_max_length_resource_url" - AlertingPoliciesAlertTypeScriptmonitorAlertNewResources AlertingPoliciesAlertType = "scriptmonitor_alert_new_resources" - AlertingPoliciesAlertTypeSecondaryDNSAllPrimariesFailing AlertingPoliciesAlertType = "secondary_dns_all_primaries_failing" - AlertingPoliciesAlertTypeSecondaryDNSPrimariesFailing AlertingPoliciesAlertType = "secondary_dns_primaries_failing" - AlertingPoliciesAlertTypeSecondaryDNSZoneSuccessfullyUpdated AlertingPoliciesAlertType = "secondary_dns_zone_successfully_updated" - AlertingPoliciesAlertTypeSecondaryDNSZoneValidationWarning AlertingPoliciesAlertType = "secondary_dns_zone_validation_warning" - AlertingPoliciesAlertTypeSentinelAlert AlertingPoliciesAlertType = "sentinel_alert" - AlertingPoliciesAlertTypeStreamLiveNotifications AlertingPoliciesAlertType = "stream_live_notifications" - AlertingPoliciesAlertTypeTrafficAnomaliesAlert AlertingPoliciesAlertType = "traffic_anomalies_alert" - AlertingPoliciesAlertTypeTunnelHealthEvent AlertingPoliciesAlertType = "tunnel_health_event" - AlertingPoliciesAlertTypeTunnelUpdateEvent AlertingPoliciesAlertType = "tunnel_update_event" - AlertingPoliciesAlertTypeUniversalSSLEventType AlertingPoliciesAlertType = "universal_ssl_event_type" - AlertingPoliciesAlertTypeWebAnalyticsMetricsUpdate AlertingPoliciesAlertType = "web_analytics_metrics_update" - AlertingPoliciesAlertTypeZoneAopCustomCertificateExpirationType AlertingPoliciesAlertType = "zone_aop_custom_certificate_expiration_type" -) - -func (r AlertingPoliciesAlertType) IsKnown() bool { - switch r { - case AlertingPoliciesAlertTypeAccessCustomCertificateExpirationType, AlertingPoliciesAlertTypeAdvancedDDoSAttackL4Alert, AlertingPoliciesAlertTypeAdvancedDDoSAttackL7Alert, AlertingPoliciesAlertTypeAdvancedHTTPAlertError, AlertingPoliciesAlertTypeBGPHijackNotification, AlertingPoliciesAlertTypeBillingUsageAlert, AlertingPoliciesAlertTypeBlockNotificationBlockRemoved, AlertingPoliciesAlertTypeBlockNotificationNewBlock, AlertingPoliciesAlertTypeBlockNotificationReviewRejected, AlertingPoliciesAlertTypeBrandProtectionAlert, AlertingPoliciesAlertTypeBrandProtectionDigest, AlertingPoliciesAlertTypeClickhouseAlertFwAnomaly, AlertingPoliciesAlertTypeClickhouseAlertFwEntAnomaly, AlertingPoliciesAlertTypeCustomSSLCertificateEventType, AlertingPoliciesAlertTypeDedicatedSSLCertificateEventType, AlertingPoliciesAlertTypeDosAttackL4, AlertingPoliciesAlertTypeDosAttackL7, AlertingPoliciesAlertTypeExpiringServiceTokenAlert, AlertingPoliciesAlertTypeFailingLogpushJobDisabledAlert, AlertingPoliciesAlertTypeFbmAutoAdvertisement, AlertingPoliciesAlertTypeFbmDosdAttack, AlertingPoliciesAlertTypeFbmVolumetricAttack, AlertingPoliciesAlertTypeHealthCheckStatusNotification, AlertingPoliciesAlertTypeHostnameAopCustomCertificateExpirationType, AlertingPoliciesAlertTypeHTTPAlertEdgeError, AlertingPoliciesAlertTypeHTTPAlertOriginError, AlertingPoliciesAlertTypeIncidentAlert, AlertingPoliciesAlertTypeLoadBalancingHealthAlert, AlertingPoliciesAlertTypeLoadBalancingPoolEnablementAlert, AlertingPoliciesAlertTypeLogoMatchAlert, AlertingPoliciesAlertTypeMagicTunnelHealthCheckEvent, AlertingPoliciesAlertTypeMaintenanceEventNotification, AlertingPoliciesAlertTypeMTLSCertificateStoreCertificateExpirationType, AlertingPoliciesAlertTypePagesEventAlert, AlertingPoliciesAlertTypeRadarNotification, AlertingPoliciesAlertTypeRealOriginMonitoring, AlertingPoliciesAlertTypeScriptmonitorAlertNewCodeChangeDetections, AlertingPoliciesAlertTypeScriptmonitorAlertNewHosts, AlertingPoliciesAlertTypeScriptmonitorAlertNewMaliciousHosts, AlertingPoliciesAlertTypeScriptmonitorAlertNewMaliciousScripts, AlertingPoliciesAlertTypeScriptmonitorAlertNewMaliciousURL, AlertingPoliciesAlertTypeScriptmonitorAlertNewMaxLengthResourceURL, AlertingPoliciesAlertTypeScriptmonitorAlertNewResources, AlertingPoliciesAlertTypeSecondaryDNSAllPrimariesFailing, AlertingPoliciesAlertTypeSecondaryDNSPrimariesFailing, AlertingPoliciesAlertTypeSecondaryDNSZoneSuccessfullyUpdated, AlertingPoliciesAlertTypeSecondaryDNSZoneValidationWarning, AlertingPoliciesAlertTypeSentinelAlert, AlertingPoliciesAlertTypeStreamLiveNotifications, AlertingPoliciesAlertTypeTrafficAnomaliesAlert, AlertingPoliciesAlertTypeTunnelHealthEvent, AlertingPoliciesAlertTypeTunnelUpdateEvent, AlertingPoliciesAlertTypeUniversalSSLEventType, AlertingPoliciesAlertTypeWebAnalyticsMetricsUpdate, AlertingPoliciesAlertTypeZoneAopCustomCertificateExpirationType: - return true - } - return false -} - // Optional filters that allow you to be alerted only on a subset of events for // that alert type based on some criteria. This is only available for select alert // types. See alert type documentation for more details. -type AlertingPoliciesFilters struct { +type Filters struct { // Usage depends on specific alert type Actions []string `json:"actions"` // Used for configuring radar_notification @@ -248,7 +126,7 @@ type AlertingPoliciesFilters struct { // Usage depends on specific alert type AlertTriggerPreferences []string `json:"alert_trigger_preferences"` // Used for configuring magic_tunnel_health_check_event - AlertTriggerPreferencesValue []AlertingPoliciesFiltersAlertTriggerPreferencesValue `json:"alert_trigger_preferences_value"` + AlertTriggerPreferencesValue []FiltersAlertTriggerPreferencesValue `json:"alert_trigger_preferences_value"` // Used for configuring load_balancing_pool_enablement_alert Enabled []string `json:"enabled"` // Used for configuring pages_event_alert @@ -264,7 +142,7 @@ type AlertingPoliciesFilters struct { // Used for configuring health_check_status_notification HealthCheckID []string `json:"health_check_id"` // Used for configuring incident_alert - IncidentImpact []AlertingPoliciesFiltersIncidentImpact `json:"incident_impact"` + IncidentImpact []FiltersIncidentImpact `json:"incident_impact"` // Used for configuring stream_live_notifications InputID []string `json:"input_id"` // Used for configuring billing_usage_alert @@ -306,7 +184,7 @@ type AlertingPoliciesFilters struct { // Used for configuring advanced_ddos_attack_l7_alert TargetZoneName []string `json:"target_zone_name"` // Used for configuring traffic_anomalies_alert - TrafficExclusions []AlertingPoliciesFiltersTrafficExclusion `json:"traffic_exclusions"` + TrafficExclusions []FiltersTrafficExclusion `json:"traffic_exclusions"` // Used for configuring tunnel_health_event TunnelID []string `json:"tunnel_id"` // Used for configuring magic_tunnel_health_check_event @@ -314,13 +192,12 @@ type AlertingPoliciesFilters struct { // Usage depends on specific alert type Where []string `json:"where"` // Usage depends on specific alert type - Zones []string `json:"zones"` - JSON alertingPoliciesFiltersJSON `json:"-"` + Zones []string `json:"zones"` + JSON filtersJSON `json:"-"` } -// alertingPoliciesFiltersJSON contains the JSON metadata for the struct -// [AlertingPoliciesFilters] -type alertingPoliciesFiltersJSON struct { +// filtersJSON contains the JSON metadata for the struct [Filters] +type filtersJSON struct { Actions apijson.Field AffectedASNs apijson.Field AffectedComponents apijson.Field @@ -365,103 +242,273 @@ type alertingPoliciesFiltersJSON struct { ExtraFields map[string]apijson.Field } -func (r *AlertingPoliciesFilters) UnmarshalJSON(data []byte) (err error) { +func (r *Filters) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r alertingPoliciesFiltersJSON) RawJSON() string { +func (r filtersJSON) RawJSON() string { return r.raw } -type AlertingPoliciesFiltersAlertTriggerPreferencesValue string +type FiltersAlertTriggerPreferencesValue string const ( - AlertingPoliciesFiltersAlertTriggerPreferencesValue99_0 AlertingPoliciesFiltersAlertTriggerPreferencesValue = "99.0" - AlertingPoliciesFiltersAlertTriggerPreferencesValue98_0 AlertingPoliciesFiltersAlertTriggerPreferencesValue = "98.0" - AlertingPoliciesFiltersAlertTriggerPreferencesValue97_0 AlertingPoliciesFiltersAlertTriggerPreferencesValue = "97.0" + FiltersAlertTriggerPreferencesValue99_0 FiltersAlertTriggerPreferencesValue = "99.0" + FiltersAlertTriggerPreferencesValue98_0 FiltersAlertTriggerPreferencesValue = "98.0" + FiltersAlertTriggerPreferencesValue97_0 FiltersAlertTriggerPreferencesValue = "97.0" ) -func (r AlertingPoliciesFiltersAlertTriggerPreferencesValue) IsKnown() bool { +func (r FiltersAlertTriggerPreferencesValue) IsKnown() bool { switch r { - case AlertingPoliciesFiltersAlertTriggerPreferencesValue99_0, AlertingPoliciesFiltersAlertTriggerPreferencesValue98_0, AlertingPoliciesFiltersAlertTriggerPreferencesValue97_0: + case FiltersAlertTriggerPreferencesValue99_0, FiltersAlertTriggerPreferencesValue98_0, FiltersAlertTriggerPreferencesValue97_0: return true } return false } -type AlertingPoliciesFiltersIncidentImpact string +type FiltersIncidentImpact string const ( - AlertingPoliciesFiltersIncidentImpactIncidentImpactNone AlertingPoliciesFiltersIncidentImpact = "INCIDENT_IMPACT_NONE" - AlertingPoliciesFiltersIncidentImpactIncidentImpactMinor AlertingPoliciesFiltersIncidentImpact = "INCIDENT_IMPACT_MINOR" - AlertingPoliciesFiltersIncidentImpactIncidentImpactMajor AlertingPoliciesFiltersIncidentImpact = "INCIDENT_IMPACT_MAJOR" - AlertingPoliciesFiltersIncidentImpactIncidentImpactCritical AlertingPoliciesFiltersIncidentImpact = "INCIDENT_IMPACT_CRITICAL" + FiltersIncidentImpactIncidentImpactNone FiltersIncidentImpact = "INCIDENT_IMPACT_NONE" + FiltersIncidentImpactIncidentImpactMinor FiltersIncidentImpact = "INCIDENT_IMPACT_MINOR" + FiltersIncidentImpactIncidentImpactMajor FiltersIncidentImpact = "INCIDENT_IMPACT_MAJOR" + FiltersIncidentImpactIncidentImpactCritical FiltersIncidentImpact = "INCIDENT_IMPACT_CRITICAL" ) -func (r AlertingPoliciesFiltersIncidentImpact) IsKnown() bool { +func (r FiltersIncidentImpact) IsKnown() bool { switch r { - case AlertingPoliciesFiltersIncidentImpactIncidentImpactNone, AlertingPoliciesFiltersIncidentImpactIncidentImpactMinor, AlertingPoliciesFiltersIncidentImpactIncidentImpactMajor, AlertingPoliciesFiltersIncidentImpactIncidentImpactCritical: + case FiltersIncidentImpactIncidentImpactNone, FiltersIncidentImpactIncidentImpactMinor, FiltersIncidentImpactIncidentImpactMajor, FiltersIncidentImpactIncidentImpactCritical: return true } return false } -type AlertingPoliciesFiltersTrafficExclusion string +type FiltersTrafficExclusion string const ( - AlertingPoliciesFiltersTrafficExclusionSecurityEvents AlertingPoliciesFiltersTrafficExclusion = "security_events" + FiltersTrafficExclusionSecurityEvents FiltersTrafficExclusion = "security_events" ) -func (r AlertingPoliciesFiltersTrafficExclusion) IsKnown() bool { +func (r FiltersTrafficExclusion) IsKnown() bool { switch r { - case AlertingPoliciesFiltersTrafficExclusionSecurityEvents: + case FiltersTrafficExclusionSecurityEvents: return true } return false } -type AlertingPoliciesMechanisms struct { - // UUID - ID AlertingPoliciesMechanismsIDUnion `json:"id"` - JSON alertingPoliciesMechanismsJSON `json:"-"` +// Optional filters that allow you to be alerted only on a subset of events for +// that alert type based on some criteria. This is only available for select alert +// types. See alert type documentation for more details. +type FiltersParam struct { + // Usage depends on specific alert type + Actions param.Field[[]string] `json:"actions"` + // Used for configuring radar_notification + AffectedASNs param.Field[[]string] `json:"affected_asns"` + // Used for configuring incident_alert. A list of identifiers for each component to + // monitor. + AffectedComponents param.Field[[]string] `json:"affected_components"` + // Used for configuring radar_notification + AffectedLocations param.Field[[]string] `json:"affected_locations"` + // Used for configuring maintenance_event_notification + AirportCode param.Field[[]string] `json:"airport_code"` + // Usage depends on specific alert type + AlertTriggerPreferences param.Field[[]string] `json:"alert_trigger_preferences"` + // Used for configuring magic_tunnel_health_check_event + AlertTriggerPreferencesValue param.Field[[]FiltersAlertTriggerPreferencesValue] `json:"alert_trigger_preferences_value"` + // Used for configuring load_balancing_pool_enablement_alert + Enabled param.Field[[]string] `json:"enabled"` + // Used for configuring pages_event_alert + Environment param.Field[[]string] `json:"environment"` + // Used for configuring pages_event_alert + Event param.Field[[]string] `json:"event"` + // Used for configuring load_balancing_health_alert + EventSource param.Field[[]string] `json:"event_source"` + // Usage depends on specific alert type + EventType param.Field[[]string] `json:"event_type"` + // Usage depends on specific alert type + GroupBy param.Field[[]string] `json:"group_by"` + // Used for configuring health_check_status_notification + HealthCheckID param.Field[[]string] `json:"health_check_id"` + // Used for configuring incident_alert + IncidentImpact param.Field[[]FiltersIncidentImpact] `json:"incident_impact"` + // Used for configuring stream_live_notifications + InputID param.Field[[]string] `json:"input_id"` + // Used for configuring billing_usage_alert + Limit param.Field[[]string] `json:"limit"` + // Used for configuring logo_match_alert + LogoTag param.Field[[]string] `json:"logo_tag"` + // Used for configuring advanced_ddos_attack_l4_alert + MegabitsPerSecond param.Field[[]string] `json:"megabits_per_second"` + // Used for configuring load_balancing_health_alert + NewHealth param.Field[[]string] `json:"new_health"` + // Used for configuring tunnel_health_event + NewStatus param.Field[[]string] `json:"new_status"` + // Used for configuring advanced_ddos_attack_l4_alert + PacketsPerSecond param.Field[[]string] `json:"packets_per_second"` + // Usage depends on specific alert type + PoolID param.Field[[]string] `json:"pool_id"` + // Used for configuring billing_usage_alert + Product param.Field[[]string] `json:"product"` + // Used for configuring pages_event_alert + ProjectID param.Field[[]string] `json:"project_id"` + // Used for configuring advanced_ddos_attack_l4_alert + Protocol param.Field[[]string] `json:"protocol"` + // Usage depends on specific alert type + QueryTag param.Field[[]string] `json:"query_tag"` + // Used for configuring advanced_ddos_attack_l7_alert + RequestsPerSecond param.Field[[]string] `json:"requests_per_second"` + // Usage depends on specific alert type + Selectors param.Field[[]string] `json:"selectors"` + // Used for configuring clickhouse_alert_fw_ent_anomaly + Services param.Field[[]string] `json:"services"` + // Usage depends on specific alert type + Slo param.Field[[]string] `json:"slo"` + // Used for configuring health_check_status_notification + Status param.Field[[]string] `json:"status"` + // Used for configuring advanced_ddos_attack_l7_alert + TargetHostname param.Field[[]string] `json:"target_hostname"` + // Used for configuring advanced_ddos_attack_l4_alert + TargetIP param.Field[[]string] `json:"target_ip"` + // Used for configuring advanced_ddos_attack_l7_alert + TargetZoneName param.Field[[]string] `json:"target_zone_name"` + // Used for configuring traffic_anomalies_alert + TrafficExclusions param.Field[[]FiltersTrafficExclusion] `json:"traffic_exclusions"` + // Used for configuring tunnel_health_event + TunnelID param.Field[[]string] `json:"tunnel_id"` + // Used for configuring magic_tunnel_health_check_event + TunnelName param.Field[[]string] `json:"tunnel_name"` + // Usage depends on specific alert type + Where param.Field[[]string] `json:"where"` + // Usage depends on specific alert type + Zones param.Field[[]string] `json:"zones"` } -// alertingPoliciesMechanismsJSON contains the JSON metadata for the struct -// [AlertingPoliciesMechanisms] -type alertingPoliciesMechanismsJSON struct { +func (r FiltersParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type Mechanisms map[string][]Mechanisms + +type MechanismsParam map[string][]MechanismsParam + +type Policies struct { + // The unique identifier of a notification policy + ID string `json:"id"` + // Refers to which event will trigger a Notification dispatch. You can use the + // endpoint to get available alert types which then will give you a list of + // possible values. + AlertType PoliciesAlertType `json:"alert_type"` + Created time.Time `json:"created" format:"date-time"` + // Optional description for the Notification policy. + Description string `json:"description"` + // Whether or not the Notification policy is enabled. + Enabled bool `json:"enabled"` + // Optional filters that allow you to be alerted only on a subset of events for + // that alert type based on some criteria. This is only available for select alert + // types. See alert type documentation for more details. + Filters Filters `json:"filters"` + // List of IDs that will be used when dispatching a notification. IDs for email + // type will be the email address. + Mechanisms Mechanisms `json:"mechanisms"` + Modified time.Time `json:"modified" format:"date-time"` + // Name of the policy. + Name string `json:"name"` + JSON policiesJSON `json:"-"` +} + +// policiesJSON contains the JSON metadata for the struct [Policies] +type policiesJSON struct { ID apijson.Field + AlertType apijson.Field + Created apijson.Field + Description apijson.Field + Enabled apijson.Field + Filters apijson.Field + Mechanisms apijson.Field + Modified apijson.Field + Name apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *AlertingPoliciesMechanisms) UnmarshalJSON(data []byte) (err error) { +func (r *Policies) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r alertingPoliciesMechanismsJSON) RawJSON() string { +func (r policiesJSON) RawJSON() string { return r.raw } -// UUID -// -// Union satisfied by [shared.UnionString] or [shared.UnionString]. -type AlertingPoliciesMechanismsIDUnion interface { - ImplementsAlertingAlertingPoliciesMechanismsIDUnion() -} +// Refers to which event will trigger a Notification dispatch. You can use the +// endpoint to get available alert types which then will give you a list of +// possible values. +type PoliciesAlertType string -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*AlertingPoliciesMechanismsIDUnion)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) +const ( + PoliciesAlertTypeAccessCustomCertificateExpirationType PoliciesAlertType = "access_custom_certificate_expiration_type" + PoliciesAlertTypeAdvancedDDoSAttackL4Alert PoliciesAlertType = "advanced_ddos_attack_l4_alert" + PoliciesAlertTypeAdvancedDDoSAttackL7Alert PoliciesAlertType = "advanced_ddos_attack_l7_alert" + PoliciesAlertTypeAdvancedHTTPAlertError PoliciesAlertType = "advanced_http_alert_error" + PoliciesAlertTypeBGPHijackNotification PoliciesAlertType = "bgp_hijack_notification" + PoliciesAlertTypeBillingUsageAlert PoliciesAlertType = "billing_usage_alert" + PoliciesAlertTypeBlockNotificationBlockRemoved PoliciesAlertType = "block_notification_block_removed" + PoliciesAlertTypeBlockNotificationNewBlock PoliciesAlertType = "block_notification_new_block" + PoliciesAlertTypeBlockNotificationReviewRejected PoliciesAlertType = "block_notification_review_rejected" + PoliciesAlertTypeBrandProtectionAlert PoliciesAlertType = "brand_protection_alert" + PoliciesAlertTypeBrandProtectionDigest PoliciesAlertType = "brand_protection_digest" + PoliciesAlertTypeClickhouseAlertFwAnomaly PoliciesAlertType = "clickhouse_alert_fw_anomaly" + PoliciesAlertTypeClickhouseAlertFwEntAnomaly PoliciesAlertType = "clickhouse_alert_fw_ent_anomaly" + PoliciesAlertTypeCustomSSLCertificateEventType PoliciesAlertType = "custom_ssl_certificate_event_type" + PoliciesAlertTypeDedicatedSSLCertificateEventType PoliciesAlertType = "dedicated_ssl_certificate_event_type" + PoliciesAlertTypeDosAttackL4 PoliciesAlertType = "dos_attack_l4" + PoliciesAlertTypeDosAttackL7 PoliciesAlertType = "dos_attack_l7" + PoliciesAlertTypeExpiringServiceTokenAlert PoliciesAlertType = "expiring_service_token_alert" + PoliciesAlertTypeFailingLogpushJobDisabledAlert PoliciesAlertType = "failing_logpush_job_disabled_alert" + PoliciesAlertTypeFbmAutoAdvertisement PoliciesAlertType = "fbm_auto_advertisement" + PoliciesAlertTypeFbmDosdAttack PoliciesAlertType = "fbm_dosd_attack" + PoliciesAlertTypeFbmVolumetricAttack PoliciesAlertType = "fbm_volumetric_attack" + PoliciesAlertTypeHealthCheckStatusNotification PoliciesAlertType = "health_check_status_notification" + PoliciesAlertTypeHostnameAopCustomCertificateExpirationType PoliciesAlertType = "hostname_aop_custom_certificate_expiration_type" + PoliciesAlertTypeHTTPAlertEdgeError PoliciesAlertType = "http_alert_edge_error" + PoliciesAlertTypeHTTPAlertOriginError PoliciesAlertType = "http_alert_origin_error" + PoliciesAlertTypeIncidentAlert PoliciesAlertType = "incident_alert" + PoliciesAlertTypeLoadBalancingHealthAlert PoliciesAlertType = "load_balancing_health_alert" + PoliciesAlertTypeLoadBalancingPoolEnablementAlert PoliciesAlertType = "load_balancing_pool_enablement_alert" + PoliciesAlertTypeLogoMatchAlert PoliciesAlertType = "logo_match_alert" + PoliciesAlertTypeMagicTunnelHealthCheckEvent PoliciesAlertType = "magic_tunnel_health_check_event" + PoliciesAlertTypeMaintenanceEventNotification PoliciesAlertType = "maintenance_event_notification" + PoliciesAlertTypeMTLSCertificateStoreCertificateExpirationType PoliciesAlertType = "mtls_certificate_store_certificate_expiration_type" + PoliciesAlertTypePagesEventAlert PoliciesAlertType = "pages_event_alert" + PoliciesAlertTypeRadarNotification PoliciesAlertType = "radar_notification" + PoliciesAlertTypeRealOriginMonitoring PoliciesAlertType = "real_origin_monitoring" + PoliciesAlertTypeScriptmonitorAlertNewCodeChangeDetections PoliciesAlertType = "scriptmonitor_alert_new_code_change_detections" + PoliciesAlertTypeScriptmonitorAlertNewHosts PoliciesAlertType = "scriptmonitor_alert_new_hosts" + PoliciesAlertTypeScriptmonitorAlertNewMaliciousHosts PoliciesAlertType = "scriptmonitor_alert_new_malicious_hosts" + PoliciesAlertTypeScriptmonitorAlertNewMaliciousScripts PoliciesAlertType = "scriptmonitor_alert_new_malicious_scripts" + PoliciesAlertTypeScriptmonitorAlertNewMaliciousURL PoliciesAlertType = "scriptmonitor_alert_new_malicious_url" + PoliciesAlertTypeScriptmonitorAlertNewMaxLengthResourceURL PoliciesAlertType = "scriptmonitor_alert_new_max_length_resource_url" + PoliciesAlertTypeScriptmonitorAlertNewResources PoliciesAlertType = "scriptmonitor_alert_new_resources" + PoliciesAlertTypeSecondaryDNSAllPrimariesFailing PoliciesAlertType = "secondary_dns_all_primaries_failing" + PoliciesAlertTypeSecondaryDNSPrimariesFailing PoliciesAlertType = "secondary_dns_primaries_failing" + PoliciesAlertTypeSecondaryDNSZoneSuccessfullyUpdated PoliciesAlertType = "secondary_dns_zone_successfully_updated" + PoliciesAlertTypeSecondaryDNSZoneValidationWarning PoliciesAlertType = "secondary_dns_zone_validation_warning" + PoliciesAlertTypeSentinelAlert PoliciesAlertType = "sentinel_alert" + PoliciesAlertTypeStreamLiveNotifications PoliciesAlertType = "stream_live_notifications" + PoliciesAlertTypeTrafficAnomaliesAlert PoliciesAlertType = "traffic_anomalies_alert" + PoliciesAlertTypeTunnelHealthEvent PoliciesAlertType = "tunnel_health_event" + PoliciesAlertTypeTunnelUpdateEvent PoliciesAlertType = "tunnel_update_event" + PoliciesAlertTypeUniversalSSLEventType PoliciesAlertType = "universal_ssl_event_type" + PoliciesAlertTypeWebAnalyticsMetricsUpdate PoliciesAlertType = "web_analytics_metrics_update" + PoliciesAlertTypeZoneAopCustomCertificateExpirationType PoliciesAlertType = "zone_aop_custom_certificate_expiration_type" +) + +func (r PoliciesAlertType) IsKnown() bool { + switch r { + case PoliciesAlertTypeAccessCustomCertificateExpirationType, PoliciesAlertTypeAdvancedDDoSAttackL4Alert, PoliciesAlertTypeAdvancedDDoSAttackL7Alert, PoliciesAlertTypeAdvancedHTTPAlertError, PoliciesAlertTypeBGPHijackNotification, PoliciesAlertTypeBillingUsageAlert, PoliciesAlertTypeBlockNotificationBlockRemoved, PoliciesAlertTypeBlockNotificationNewBlock, PoliciesAlertTypeBlockNotificationReviewRejected, PoliciesAlertTypeBrandProtectionAlert, PoliciesAlertTypeBrandProtectionDigest, PoliciesAlertTypeClickhouseAlertFwAnomaly, PoliciesAlertTypeClickhouseAlertFwEntAnomaly, PoliciesAlertTypeCustomSSLCertificateEventType, PoliciesAlertTypeDedicatedSSLCertificateEventType, PoliciesAlertTypeDosAttackL4, PoliciesAlertTypeDosAttackL7, PoliciesAlertTypeExpiringServiceTokenAlert, PoliciesAlertTypeFailingLogpushJobDisabledAlert, PoliciesAlertTypeFbmAutoAdvertisement, PoliciesAlertTypeFbmDosdAttack, PoliciesAlertTypeFbmVolumetricAttack, PoliciesAlertTypeHealthCheckStatusNotification, PoliciesAlertTypeHostnameAopCustomCertificateExpirationType, PoliciesAlertTypeHTTPAlertEdgeError, PoliciesAlertTypeHTTPAlertOriginError, PoliciesAlertTypeIncidentAlert, PoliciesAlertTypeLoadBalancingHealthAlert, PoliciesAlertTypeLoadBalancingPoolEnablementAlert, PoliciesAlertTypeLogoMatchAlert, PoliciesAlertTypeMagicTunnelHealthCheckEvent, PoliciesAlertTypeMaintenanceEventNotification, PoliciesAlertTypeMTLSCertificateStoreCertificateExpirationType, PoliciesAlertTypePagesEventAlert, PoliciesAlertTypeRadarNotification, PoliciesAlertTypeRealOriginMonitoring, PoliciesAlertTypeScriptmonitorAlertNewCodeChangeDetections, PoliciesAlertTypeScriptmonitorAlertNewHosts, PoliciesAlertTypeScriptmonitorAlertNewMaliciousHosts, PoliciesAlertTypeScriptmonitorAlertNewMaliciousScripts, PoliciesAlertTypeScriptmonitorAlertNewMaliciousURL, PoliciesAlertTypeScriptmonitorAlertNewMaxLengthResourceURL, PoliciesAlertTypeScriptmonitorAlertNewResources, PoliciesAlertTypeSecondaryDNSAllPrimariesFailing, PoliciesAlertTypeSecondaryDNSPrimariesFailing, PoliciesAlertTypeSecondaryDNSZoneSuccessfullyUpdated, PoliciesAlertTypeSecondaryDNSZoneValidationWarning, PoliciesAlertTypeSentinelAlert, PoliciesAlertTypeStreamLiveNotifications, PoliciesAlertTypeTrafficAnomaliesAlert, PoliciesAlertTypeTunnelHealthEvent, PoliciesAlertTypeTunnelUpdateEvent, PoliciesAlertTypeUniversalSSLEventType, PoliciesAlertTypeWebAnalyticsMetricsUpdate, PoliciesAlertTypeZoneAopCustomCertificateExpirationType: + return true + } + return false } type PolicyNewResponse struct { @@ -519,7 +566,7 @@ type PolicyNewParams struct { Enabled param.Field[bool] `json:"enabled,required"` // List of IDs that will be used when dispatching a notification. IDs for email // type will be the email address. - Mechanisms param.Field[map[string][]PolicyNewParamsMechanisms] `json:"mechanisms,required"` + Mechanisms param.Field[MechanismsParam] `json:"mechanisms,required"` // Name of the policy. Name param.Field[string] `json:"name,required"` // Optional description for the Notification policy. @@ -527,7 +574,7 @@ type PolicyNewParams struct { // Optional filters that allow you to be alerted only on a subset of events for // that alert type based on some criteria. This is only available for select alert // types. See alert type documentation for more details. - Filters param.Field[PolicyNewParamsFilters] `json:"filters"` + Filters param.Field[FiltersParam] `json:"filters"` } func (r PolicyNewParams) MarshalJSON() (data []byte, err error) { @@ -605,160 +652,6 @@ func (r PolicyNewParamsAlertType) IsKnown() bool { return false } -type PolicyNewParamsMechanisms struct { - // UUID - ID param.Field[PolicyNewParamsMechanismsIDUnion] `json:"id"` -} - -func (r PolicyNewParamsMechanisms) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// UUID -// -// Satisfied by [shared.UnionString], [shared.UnionString]. -type PolicyNewParamsMechanismsIDUnion interface { - ImplementsAlertingPolicyNewParamsMechanismsIDUnion() -} - -// Optional filters that allow you to be alerted only on a subset of events for -// that alert type based on some criteria. This is only available for select alert -// types. See alert type documentation for more details. -type PolicyNewParamsFilters struct { - // Usage depends on specific alert type - Actions param.Field[[]string] `json:"actions"` - // Used for configuring radar_notification - AffectedASNs param.Field[[]string] `json:"affected_asns"` - // Used for configuring incident_alert. A list of identifiers for each component to - // monitor. - AffectedComponents param.Field[[]string] `json:"affected_components"` - // Used for configuring radar_notification - AffectedLocations param.Field[[]string] `json:"affected_locations"` - // Used for configuring maintenance_event_notification - AirportCode param.Field[[]string] `json:"airport_code"` - // Usage depends on specific alert type - AlertTriggerPreferences param.Field[[]string] `json:"alert_trigger_preferences"` - // Used for configuring magic_tunnel_health_check_event - AlertTriggerPreferencesValue param.Field[[]PolicyNewParamsFiltersAlertTriggerPreferencesValue] `json:"alert_trigger_preferences_value"` - // Used for configuring load_balancing_pool_enablement_alert - Enabled param.Field[[]string] `json:"enabled"` - // Used for configuring pages_event_alert - Environment param.Field[[]string] `json:"environment"` - // Used for configuring pages_event_alert - Event param.Field[[]string] `json:"event"` - // Used for configuring load_balancing_health_alert - EventSource param.Field[[]string] `json:"event_source"` - // Usage depends on specific alert type - EventType param.Field[[]string] `json:"event_type"` - // Usage depends on specific alert type - GroupBy param.Field[[]string] `json:"group_by"` - // Used for configuring health_check_status_notification - HealthCheckID param.Field[[]string] `json:"health_check_id"` - // Used for configuring incident_alert - IncidentImpact param.Field[[]PolicyNewParamsFiltersIncidentImpact] `json:"incident_impact"` - // Used for configuring stream_live_notifications - InputID param.Field[[]string] `json:"input_id"` - // Used for configuring billing_usage_alert - Limit param.Field[[]string] `json:"limit"` - // Used for configuring logo_match_alert - LogoTag param.Field[[]string] `json:"logo_tag"` - // Used for configuring advanced_ddos_attack_l4_alert - MegabitsPerSecond param.Field[[]string] `json:"megabits_per_second"` - // Used for configuring load_balancing_health_alert - NewHealth param.Field[[]string] `json:"new_health"` - // Used for configuring tunnel_health_event - NewStatus param.Field[[]string] `json:"new_status"` - // Used for configuring advanced_ddos_attack_l4_alert - PacketsPerSecond param.Field[[]string] `json:"packets_per_second"` - // Usage depends on specific alert type - PoolID param.Field[[]string] `json:"pool_id"` - // Used for configuring billing_usage_alert - Product param.Field[[]string] `json:"product"` - // Used for configuring pages_event_alert - ProjectID param.Field[[]string] `json:"project_id"` - // Used for configuring advanced_ddos_attack_l4_alert - Protocol param.Field[[]string] `json:"protocol"` - // Usage depends on specific alert type - QueryTag param.Field[[]string] `json:"query_tag"` - // Used for configuring advanced_ddos_attack_l7_alert - RequestsPerSecond param.Field[[]string] `json:"requests_per_second"` - // Usage depends on specific alert type - Selectors param.Field[[]string] `json:"selectors"` - // Used for configuring clickhouse_alert_fw_ent_anomaly - Services param.Field[[]string] `json:"services"` - // Usage depends on specific alert type - Slo param.Field[[]string] `json:"slo"` - // Used for configuring health_check_status_notification - Status param.Field[[]string] `json:"status"` - // Used for configuring advanced_ddos_attack_l7_alert - TargetHostname param.Field[[]string] `json:"target_hostname"` - // Used for configuring advanced_ddos_attack_l4_alert - TargetIP param.Field[[]string] `json:"target_ip"` - // Used for configuring advanced_ddos_attack_l7_alert - TargetZoneName param.Field[[]string] `json:"target_zone_name"` - // Used for configuring traffic_anomalies_alert - TrafficExclusions param.Field[[]PolicyNewParamsFiltersTrafficExclusion] `json:"traffic_exclusions"` - // Used for configuring tunnel_health_event - TunnelID param.Field[[]string] `json:"tunnel_id"` - // Used for configuring magic_tunnel_health_check_event - TunnelName param.Field[[]string] `json:"tunnel_name"` - // Usage depends on specific alert type - Where param.Field[[]string] `json:"where"` - // Usage depends on specific alert type - Zones param.Field[[]string] `json:"zones"` -} - -func (r PolicyNewParamsFilters) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type PolicyNewParamsFiltersAlertTriggerPreferencesValue string - -const ( - PolicyNewParamsFiltersAlertTriggerPreferencesValue99_0 PolicyNewParamsFiltersAlertTriggerPreferencesValue = "99.0" - PolicyNewParamsFiltersAlertTriggerPreferencesValue98_0 PolicyNewParamsFiltersAlertTriggerPreferencesValue = "98.0" - PolicyNewParamsFiltersAlertTriggerPreferencesValue97_0 PolicyNewParamsFiltersAlertTriggerPreferencesValue = "97.0" -) - -func (r PolicyNewParamsFiltersAlertTriggerPreferencesValue) IsKnown() bool { - switch r { - case PolicyNewParamsFiltersAlertTriggerPreferencesValue99_0, PolicyNewParamsFiltersAlertTriggerPreferencesValue98_0, PolicyNewParamsFiltersAlertTriggerPreferencesValue97_0: - return true - } - return false -} - -type PolicyNewParamsFiltersIncidentImpact string - -const ( - PolicyNewParamsFiltersIncidentImpactIncidentImpactNone PolicyNewParamsFiltersIncidentImpact = "INCIDENT_IMPACT_NONE" - PolicyNewParamsFiltersIncidentImpactIncidentImpactMinor PolicyNewParamsFiltersIncidentImpact = "INCIDENT_IMPACT_MINOR" - PolicyNewParamsFiltersIncidentImpactIncidentImpactMajor PolicyNewParamsFiltersIncidentImpact = "INCIDENT_IMPACT_MAJOR" - PolicyNewParamsFiltersIncidentImpactIncidentImpactCritical PolicyNewParamsFiltersIncidentImpact = "INCIDENT_IMPACT_CRITICAL" -) - -func (r PolicyNewParamsFiltersIncidentImpact) IsKnown() bool { - switch r { - case PolicyNewParamsFiltersIncidentImpactIncidentImpactNone, PolicyNewParamsFiltersIncidentImpactIncidentImpactMinor, PolicyNewParamsFiltersIncidentImpactIncidentImpactMajor, PolicyNewParamsFiltersIncidentImpactIncidentImpactCritical: - return true - } - return false -} - -type PolicyNewParamsFiltersTrafficExclusion string - -const ( - PolicyNewParamsFiltersTrafficExclusionSecurityEvents PolicyNewParamsFiltersTrafficExclusion = "security_events" -) - -func (r PolicyNewParamsFiltersTrafficExclusion) IsKnown() bool { - switch r { - case PolicyNewParamsFiltersTrafficExclusionSecurityEvents: - return true - } - return false -} - type PolicyNewResponseEnvelope struct { Errors []shared.UnnamedSchemaRef3248f24329456e19dfa042fff9986f72 `json:"errors,required"` Messages []shared.UnnamedSchemaRef3248f24329456e19dfa042fff9986f72 `json:"messages,required"` @@ -816,10 +709,10 @@ type PolicyUpdateParams struct { // Optional filters that allow you to be alerted only on a subset of events for // that alert type based on some criteria. This is only available for select alert // types. See alert type documentation for more details. - Filters param.Field[PolicyUpdateParamsFilters] `json:"filters"` + Filters param.Field[FiltersParam] `json:"filters"` // List of IDs that will be used when dispatching a notification. IDs for email // type will be the email address. - Mechanisms param.Field[map[string][]PolicyUpdateParamsMechanisms] `json:"mechanisms"` + Mechanisms param.Field[MechanismsParam] `json:"mechanisms"` // Name of the policy. Name param.Field[string] `json:"name"` } @@ -899,160 +792,6 @@ func (r PolicyUpdateParamsAlertType) IsKnown() bool { return false } -// Optional filters that allow you to be alerted only on a subset of events for -// that alert type based on some criteria. This is only available for select alert -// types. See alert type documentation for more details. -type PolicyUpdateParamsFilters struct { - // Usage depends on specific alert type - Actions param.Field[[]string] `json:"actions"` - // Used for configuring radar_notification - AffectedASNs param.Field[[]string] `json:"affected_asns"` - // Used for configuring incident_alert. A list of identifiers for each component to - // monitor. - AffectedComponents param.Field[[]string] `json:"affected_components"` - // Used for configuring radar_notification - AffectedLocations param.Field[[]string] `json:"affected_locations"` - // Used for configuring maintenance_event_notification - AirportCode param.Field[[]string] `json:"airport_code"` - // Usage depends on specific alert type - AlertTriggerPreferences param.Field[[]string] `json:"alert_trigger_preferences"` - // Used for configuring magic_tunnel_health_check_event - AlertTriggerPreferencesValue param.Field[[]PolicyUpdateParamsFiltersAlertTriggerPreferencesValue] `json:"alert_trigger_preferences_value"` - // Used for configuring load_balancing_pool_enablement_alert - Enabled param.Field[[]string] `json:"enabled"` - // Used for configuring pages_event_alert - Environment param.Field[[]string] `json:"environment"` - // Used for configuring pages_event_alert - Event param.Field[[]string] `json:"event"` - // Used for configuring load_balancing_health_alert - EventSource param.Field[[]string] `json:"event_source"` - // Usage depends on specific alert type - EventType param.Field[[]string] `json:"event_type"` - // Usage depends on specific alert type - GroupBy param.Field[[]string] `json:"group_by"` - // Used for configuring health_check_status_notification - HealthCheckID param.Field[[]string] `json:"health_check_id"` - // Used for configuring incident_alert - IncidentImpact param.Field[[]PolicyUpdateParamsFiltersIncidentImpact] `json:"incident_impact"` - // Used for configuring stream_live_notifications - InputID param.Field[[]string] `json:"input_id"` - // Used for configuring billing_usage_alert - Limit param.Field[[]string] `json:"limit"` - // Used for configuring logo_match_alert - LogoTag param.Field[[]string] `json:"logo_tag"` - // Used for configuring advanced_ddos_attack_l4_alert - MegabitsPerSecond param.Field[[]string] `json:"megabits_per_second"` - // Used for configuring load_balancing_health_alert - NewHealth param.Field[[]string] `json:"new_health"` - // Used for configuring tunnel_health_event - NewStatus param.Field[[]string] `json:"new_status"` - // Used for configuring advanced_ddos_attack_l4_alert - PacketsPerSecond param.Field[[]string] `json:"packets_per_second"` - // Usage depends on specific alert type - PoolID param.Field[[]string] `json:"pool_id"` - // Used for configuring billing_usage_alert - Product param.Field[[]string] `json:"product"` - // Used for configuring pages_event_alert - ProjectID param.Field[[]string] `json:"project_id"` - // Used for configuring advanced_ddos_attack_l4_alert - Protocol param.Field[[]string] `json:"protocol"` - // Usage depends on specific alert type - QueryTag param.Field[[]string] `json:"query_tag"` - // Used for configuring advanced_ddos_attack_l7_alert - RequestsPerSecond param.Field[[]string] `json:"requests_per_second"` - // Usage depends on specific alert type - Selectors param.Field[[]string] `json:"selectors"` - // Used for configuring clickhouse_alert_fw_ent_anomaly - Services param.Field[[]string] `json:"services"` - // Usage depends on specific alert type - Slo param.Field[[]string] `json:"slo"` - // Used for configuring health_check_status_notification - Status param.Field[[]string] `json:"status"` - // Used for configuring advanced_ddos_attack_l7_alert - TargetHostname param.Field[[]string] `json:"target_hostname"` - // Used for configuring advanced_ddos_attack_l4_alert - TargetIP param.Field[[]string] `json:"target_ip"` - // Used for configuring advanced_ddos_attack_l7_alert - TargetZoneName param.Field[[]string] `json:"target_zone_name"` - // Used for configuring traffic_anomalies_alert - TrafficExclusions param.Field[[]PolicyUpdateParamsFiltersTrafficExclusion] `json:"traffic_exclusions"` - // Used for configuring tunnel_health_event - TunnelID param.Field[[]string] `json:"tunnel_id"` - // Used for configuring magic_tunnel_health_check_event - TunnelName param.Field[[]string] `json:"tunnel_name"` - // Usage depends on specific alert type - Where param.Field[[]string] `json:"where"` - // Usage depends on specific alert type - Zones param.Field[[]string] `json:"zones"` -} - -func (r PolicyUpdateParamsFilters) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type PolicyUpdateParamsFiltersAlertTriggerPreferencesValue string - -const ( - PolicyUpdateParamsFiltersAlertTriggerPreferencesValue99_0 PolicyUpdateParamsFiltersAlertTriggerPreferencesValue = "99.0" - PolicyUpdateParamsFiltersAlertTriggerPreferencesValue98_0 PolicyUpdateParamsFiltersAlertTriggerPreferencesValue = "98.0" - PolicyUpdateParamsFiltersAlertTriggerPreferencesValue97_0 PolicyUpdateParamsFiltersAlertTriggerPreferencesValue = "97.0" -) - -func (r PolicyUpdateParamsFiltersAlertTriggerPreferencesValue) IsKnown() bool { - switch r { - case PolicyUpdateParamsFiltersAlertTriggerPreferencesValue99_0, PolicyUpdateParamsFiltersAlertTriggerPreferencesValue98_0, PolicyUpdateParamsFiltersAlertTriggerPreferencesValue97_0: - return true - } - return false -} - -type PolicyUpdateParamsFiltersIncidentImpact string - -const ( - PolicyUpdateParamsFiltersIncidentImpactIncidentImpactNone PolicyUpdateParamsFiltersIncidentImpact = "INCIDENT_IMPACT_NONE" - PolicyUpdateParamsFiltersIncidentImpactIncidentImpactMinor PolicyUpdateParamsFiltersIncidentImpact = "INCIDENT_IMPACT_MINOR" - PolicyUpdateParamsFiltersIncidentImpactIncidentImpactMajor PolicyUpdateParamsFiltersIncidentImpact = "INCIDENT_IMPACT_MAJOR" - PolicyUpdateParamsFiltersIncidentImpactIncidentImpactCritical PolicyUpdateParamsFiltersIncidentImpact = "INCIDENT_IMPACT_CRITICAL" -) - -func (r PolicyUpdateParamsFiltersIncidentImpact) IsKnown() bool { - switch r { - case PolicyUpdateParamsFiltersIncidentImpactIncidentImpactNone, PolicyUpdateParamsFiltersIncidentImpactIncidentImpactMinor, PolicyUpdateParamsFiltersIncidentImpactIncidentImpactMajor, PolicyUpdateParamsFiltersIncidentImpactIncidentImpactCritical: - return true - } - return false -} - -type PolicyUpdateParamsFiltersTrafficExclusion string - -const ( - PolicyUpdateParamsFiltersTrafficExclusionSecurityEvents PolicyUpdateParamsFiltersTrafficExclusion = "security_events" -) - -func (r PolicyUpdateParamsFiltersTrafficExclusion) IsKnown() bool { - switch r { - case PolicyUpdateParamsFiltersTrafficExclusionSecurityEvents: - return true - } - return false -} - -type PolicyUpdateParamsMechanisms struct { - // UUID - ID param.Field[PolicyUpdateParamsMechanismsIDUnion] `json:"id"` -} - -func (r PolicyUpdateParamsMechanisms) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// UUID -// -// Satisfied by [shared.UnionString], [shared.UnionString]. -type PolicyUpdateParamsMechanismsIDUnion interface { - ImplementsAlertingPolicyUpdateParamsMechanismsIDUnion() -} - type PolicyUpdateResponseEnvelope struct { Errors []shared.UnnamedSchemaRef3248f24329456e19dfa042fff9986f72 `json:"errors,required"` Messages []shared.UnnamedSchemaRef3248f24329456e19dfa042fff9986f72 `json:"messages,required"` @@ -1190,7 +929,7 @@ type PolicyGetParams struct { type PolicyGetResponseEnvelope struct { Errors []shared.UnnamedSchemaRef3248f24329456e19dfa042fff9986f72 `json:"errors,required"` Messages []shared.UnnamedSchemaRef3248f24329456e19dfa042fff9986f72 `json:"messages,required"` - Result AlertingPolicies `json:"result,required"` + Result Policies `json:"result,required"` // Whether the API call was successful Success PolicyGetResponseEnvelopeSuccess `json:"success,required"` JSON policyGetResponseEnvelopeJSON `json:"-"` diff --git a/alerting/policy_test.go b/alerting/policy_test.go index ac75af02bde..3559791443e 100644 --- a/alerting/policy_test.go +++ b/alerting/policy_test.go @@ -33,27 +33,27 @@ func TestPolicyNewWithOptionalParams(t *testing.T) { AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), AlertType: cloudflare.F(alerting.PolicyNewParamsAlertTypeUniversalSSLEventType), Enabled: cloudflare.F(true), - Mechanisms: cloudflare.F(map[string][]alerting.PolicyNewParamsMechanisms{ - "email": {{ - ID: cloudflare.F[alerting.PolicyNewParamsMechanismsIDUnion](shared.UnionString("test@example.com")), + Mechanisms: cloudflare.F(alerting.MechanismsParam{ + "email": []alerting.MechanismsParam{{ + ID: cloudflare.F[alerting.MechanismsIDUnionParam](shared.UnionString("test@example.com")), }}, - "pagerduty": {{ - ID: cloudflare.F[alerting.PolicyNewParamsMechanismsIDUnion](shared.UnionString("e8133a15-00a4-4d69-aec1-32f70c51f6e5")), + "pagerduty": []alerting.MechanismsParam{{ + ID: cloudflare.F[alerting.MechanismsIDUnionParam](shared.UnionString("e8133a15-00a4-4d69-aec1-32f70c51f6e5")), }}, - "webhooks": {{ - ID: cloudflare.F[alerting.PolicyNewParamsMechanismsIDUnion](shared.UnionString("14cc1190-5d2b-4b98-a696-c424cb2ad05f")), + "webhooks": []alerting.MechanismsParam{{ + ID: cloudflare.F[alerting.MechanismsIDUnionParam](shared.UnionString("14cc1190-5d2b-4b98-a696-c424cb2ad05f")), }}, }), Name: cloudflare.F("SSL Notification Event Policy"), Description: cloudflare.F("Something describing the policy."), - Filters: cloudflare.F(alerting.PolicyNewParamsFilters{ + Filters: cloudflare.F(alerting.FiltersParam{ Actions: cloudflare.F([]string{"string", "string", "string"}), AffectedASNs: cloudflare.F([]string{"string", "string", "string"}), AffectedComponents: cloudflare.F([]string{"string", "string", "string"}), AffectedLocations: cloudflare.F([]string{"string", "string", "string"}), AirportCode: cloudflare.F([]string{"string", "string", "string"}), AlertTriggerPreferences: cloudflare.F([]string{"string", "string", "string"}), - AlertTriggerPreferencesValue: cloudflare.F([]alerting.PolicyNewParamsFiltersAlertTriggerPreferencesValue{alerting.PolicyNewParamsFiltersAlertTriggerPreferencesValue99_0, alerting.PolicyNewParamsFiltersAlertTriggerPreferencesValue98_0, alerting.PolicyNewParamsFiltersAlertTriggerPreferencesValue97_0}), + AlertTriggerPreferencesValue: cloudflare.F([]alerting.FiltersAlertTriggerPreferencesValue{alerting.FiltersAlertTriggerPreferencesValue99_0, alerting.FiltersAlertTriggerPreferencesValue98_0, alerting.FiltersAlertTriggerPreferencesValue97_0}), Enabled: cloudflare.F([]string{"string", "string", "string"}), Environment: cloudflare.F([]string{"string", "string", "string"}), Event: cloudflare.F([]string{"string", "string", "string"}), @@ -61,7 +61,7 @@ func TestPolicyNewWithOptionalParams(t *testing.T) { EventType: cloudflare.F([]string{"string", "string", "string"}), GroupBy: cloudflare.F([]string{"string", "string", "string"}), HealthCheckID: cloudflare.F([]string{"string", "string", "string"}), - IncidentImpact: cloudflare.F([]alerting.PolicyNewParamsFiltersIncidentImpact{alerting.PolicyNewParamsFiltersIncidentImpactIncidentImpactNone, alerting.PolicyNewParamsFiltersIncidentImpactIncidentImpactMinor, alerting.PolicyNewParamsFiltersIncidentImpactIncidentImpactMajor}), + IncidentImpact: cloudflare.F([]alerting.FiltersIncidentImpact{alerting.FiltersIncidentImpactIncidentImpactNone, alerting.FiltersIncidentImpactIncidentImpactMinor, alerting.FiltersIncidentImpactIncidentImpactMajor}), InputID: cloudflare.F([]string{"string", "string", "string"}), Limit: cloudflare.F([]string{"string", "string", "string"}), LogoTag: cloudflare.F([]string{"string", "string", "string"}), @@ -82,7 +82,7 @@ func TestPolicyNewWithOptionalParams(t *testing.T) { TargetHostname: cloudflare.F([]string{"string", "string", "string"}), TargetIP: cloudflare.F([]string{"string", "string", "string"}), TargetZoneName: cloudflare.F([]string{"string", "string", "string"}), - TrafficExclusions: cloudflare.F([]alerting.PolicyNewParamsFiltersTrafficExclusion{alerting.PolicyNewParamsFiltersTrafficExclusionSecurityEvents}), + TrafficExclusions: cloudflare.F([]alerting.FiltersTrafficExclusion{alerting.FiltersTrafficExclusionSecurityEvents}), TunnelID: cloudflare.F([]string{"string", "string", "string"}), TunnelName: cloudflare.F([]string{"string", "string", "string"}), Where: cloudflare.F([]string{"string", "string", "string"}), @@ -120,14 +120,14 @@ func TestPolicyUpdateWithOptionalParams(t *testing.T) { AlertType: cloudflare.F(alerting.PolicyUpdateParamsAlertTypeUniversalSSLEventType), Description: cloudflare.F("Something describing the policy."), Enabled: cloudflare.F(true), - Filters: cloudflare.F(alerting.PolicyUpdateParamsFilters{ + Filters: cloudflare.F(alerting.FiltersParam{ Actions: cloudflare.F([]string{"string", "string", "string"}), AffectedASNs: cloudflare.F([]string{"string", "string", "string"}), AffectedComponents: cloudflare.F([]string{"string", "string", "string"}), AffectedLocations: cloudflare.F([]string{"string", "string", "string"}), AirportCode: cloudflare.F([]string{"string", "string", "string"}), AlertTriggerPreferences: cloudflare.F([]string{"string", "string", "string"}), - AlertTriggerPreferencesValue: cloudflare.F([]alerting.PolicyUpdateParamsFiltersAlertTriggerPreferencesValue{alerting.PolicyUpdateParamsFiltersAlertTriggerPreferencesValue99_0, alerting.PolicyUpdateParamsFiltersAlertTriggerPreferencesValue98_0, alerting.PolicyUpdateParamsFiltersAlertTriggerPreferencesValue97_0}), + AlertTriggerPreferencesValue: cloudflare.F([]alerting.FiltersAlertTriggerPreferencesValue{alerting.FiltersAlertTriggerPreferencesValue99_0, alerting.FiltersAlertTriggerPreferencesValue98_0, alerting.FiltersAlertTriggerPreferencesValue97_0}), Enabled: cloudflare.F([]string{"string", "string", "string"}), Environment: cloudflare.F([]string{"string", "string", "string"}), Event: cloudflare.F([]string{"string", "string", "string"}), @@ -135,7 +135,7 @@ func TestPolicyUpdateWithOptionalParams(t *testing.T) { EventType: cloudflare.F([]string{"string", "string", "string"}), GroupBy: cloudflare.F([]string{"string", "string", "string"}), HealthCheckID: cloudflare.F([]string{"string", "string", "string"}), - IncidentImpact: cloudflare.F([]alerting.PolicyUpdateParamsFiltersIncidentImpact{alerting.PolicyUpdateParamsFiltersIncidentImpactIncidentImpactNone, alerting.PolicyUpdateParamsFiltersIncidentImpactIncidentImpactMinor, alerting.PolicyUpdateParamsFiltersIncidentImpactIncidentImpactMajor}), + IncidentImpact: cloudflare.F([]alerting.FiltersIncidentImpact{alerting.FiltersIncidentImpactIncidentImpactNone, alerting.FiltersIncidentImpactIncidentImpactMinor, alerting.FiltersIncidentImpactIncidentImpactMajor}), InputID: cloudflare.F([]string{"string", "string", "string"}), Limit: cloudflare.F([]string{"string", "string", "string"}), LogoTag: cloudflare.F([]string{"string", "string", "string"}), @@ -156,21 +156,21 @@ func TestPolicyUpdateWithOptionalParams(t *testing.T) { TargetHostname: cloudflare.F([]string{"string", "string", "string"}), TargetIP: cloudflare.F([]string{"string", "string", "string"}), TargetZoneName: cloudflare.F([]string{"string", "string", "string"}), - TrafficExclusions: cloudflare.F([]alerting.PolicyUpdateParamsFiltersTrafficExclusion{alerting.PolicyUpdateParamsFiltersTrafficExclusionSecurityEvents}), + TrafficExclusions: cloudflare.F([]alerting.FiltersTrafficExclusion{alerting.FiltersTrafficExclusionSecurityEvents}), TunnelID: cloudflare.F([]string{"string", "string", "string"}), TunnelName: cloudflare.F([]string{"string", "string", "string"}), Where: cloudflare.F([]string{"string", "string", "string"}), Zones: cloudflare.F([]string{"string", "string", "string"}), }), - Mechanisms: cloudflare.F(map[string][]alerting.PolicyUpdateParamsMechanisms{ - "email": {{ - ID: cloudflare.F[alerting.PolicyUpdateParamsMechanismsIDUnion](shared.UnionString("test@example.com")), + Mechanisms: cloudflare.F(alerting.MechanismsParam{ + "email": []alerting.MechanismsParam{{ + ID: cloudflare.F[alerting.MechanismsIDUnionParam](shared.UnionString("test@example.com")), }}, - "pagerduty": {{ - ID: cloudflare.F[alerting.PolicyUpdateParamsMechanismsIDUnion](shared.UnionString("e8133a15-00a4-4d69-aec1-32f70c51f6e5")), + "pagerduty": []alerting.MechanismsParam{{ + ID: cloudflare.F[alerting.MechanismsIDUnionParam](shared.UnionString("e8133a15-00a4-4d69-aec1-32f70c51f6e5")), }}, - "webhooks": {{ - ID: cloudflare.F[alerting.PolicyUpdateParamsMechanismsIDUnion](shared.UnionString("14cc1190-5d2b-4b98-a696-c424cb2ad05f")), + "webhooks": []alerting.MechanismsParam{{ + ID: cloudflare.F[alerting.MechanismsIDUnionParam](shared.UnionString("14cc1190-5d2b-4b98-a696-c424cb2ad05f")), }}, }), Name: cloudflare.F("SSL Notification Event Policy"), diff --git a/api.md b/api.md index e7abfab278b..a20b56d3d19 100644 --- a/api.md +++ b/api.md @@ -36,14 +36,9 @@ Methods: ## Members -Params Types: - -- accounts.MemberPermissionParam - Response Types: - accounts.Member -- accounts.MemberPermission - accounts.MemberWithCode - accounts.MemberListResponse - accounts.MemberDeleteResponse @@ -61,17 +56,15 @@ Methods: Params Types: - accounts.PermissionGrantParam -- accounts.RoleParam Response Types: - accounts.PermissionGrant - accounts.Role -- accounts.RoleListResponse Methods: -- client.Accounts.Roles.List(ctx context.Context, query accounts.RoleListParams) (pagination.SinglePage[accounts.RoleListResponse], error) +- client.Accounts.Roles.List(ctx context.Context, query accounts.RoleListParams) (pagination.SinglePage[accounts.Role], error) - client.Accounts.Roles.Get(ctx context.Context, roleID interface{}, query accounts.RoleGetParams) (shared.UnnamedSchemaRef9444735ca60712dbcf8afd832eb5716aUnion, error) # OriginCACertificates @@ -289,8 +282,13 @@ Methods: ### PermissionGroups +Params Types: + +- user.PermissionParam + Response Types: +- user.Permission - user.TokenPermissionGroupListResponse Methods: @@ -986,9 +984,30 @@ Methods: # LoadBalancers +Params Types: + +- load_balancers.CheckRegion +- load_balancers.FilterOptionsParam +- load_balancers.HeaderParam +- load_balancers.HostItemParam +- load_balancers.LoadSheddingParam +- load_balancers.NotificationFilterParam +- load_balancers.OriginParam +- load_balancers.OriginItemParam +- load_balancers.OriginSteeringParam + Response Types: +- load_balancers.CheckRegion +- load_balancers.FilterOptions +- load_balancers.Header +- load_balancers.HostItem - load_balancers.LoadBalancer +- load_balancers.LoadShedding +- load_balancers.NotificationFilter +- load_balancers.Origin +- load_balancers.OriginItem +- load_balancers.OriginSteering - load_balancers.LoadBalancerDeleteResponse Methods: @@ -1310,8 +1329,13 @@ Methods: ## HostnameAssociations +Params Types: + +- certificate_authorities.HostnameAssociationItemParam + Response Types: +- certificate_authorities.HostnameAssociationItem - certificate_authorities.HostnameAssociationUpdateResponse - certificate_authorities.HostnameAssociationGetResponse @@ -1336,9 +1360,14 @@ Methods: # CustomCertificates +Params Types: + +- custom_certificates.GeoRestrictionsParam + Response Types: - custom_certificates.CustomCertificate +- custom_certificates.GeoRestrictions Methods: @@ -1364,6 +1393,7 @@ Params Types: Response Types: +- custom_hostnames.SSL - custom_hostnames.UnnamedSchemaRef16aca57bde2963201c7e6e895436c1c1 - custom_hostnames.UnnamedSchemaRef78adb375f06c6d462dd92b99e2ecf510 - custom_hostnames.UnnamedSchemaRef9a9935a9a770967bb604ae41a81e42e1 @@ -1484,9 +1514,18 @@ Methods: ## Firewall +Params Types: + +- dns.AttackMitigationParam +- dns.FirewallIPsItemUnionParam +- dns.UpstreamIPsItemsUnionParam + Response Types: +- dns.AttackMitigation - dns.DNSFirewall +- dns.FirewallIPsItemUnion +- dns.UpstreamIPsItemsUnion - dns.FirewallDeleteResponse Methods: @@ -1527,15 +1566,13 @@ Methods: Response Types: -- email_routing.EmailRoutingDisableResponse -- email_routing.EmailRoutingEnableResponse -- email_routing.EmailRoutingGetResponse +- email_routing.EmailSettings Methods: -- client.EmailRouting.Disable(ctx context.Context, zoneIdentifier string, body email_routing.EmailRoutingDisableParams) (email_routing.EmailRoutingDisableResponse, error) -- client.EmailRouting.Enable(ctx context.Context, zoneIdentifier string, body email_routing.EmailRoutingEnableParams) (email_routing.EmailRoutingEnableResponse, error) -- client.EmailRouting.Get(ctx context.Context, zoneIdentifier string) (email_routing.EmailRoutingGetResponse, error) +- client.EmailRouting.Disable(ctx context.Context, zoneIdentifier string, body email_routing.EmailRoutingDisableParams) (email_routing.EmailSettings, error) +- client.EmailRouting.Enable(ctx context.Context, zoneIdentifier string, body email_routing.EmailRoutingEnableParams) (email_routing.EmailSettings, error) +- client.EmailRouting.Get(ctx context.Context, zoneIdentifier string) (email_routing.EmailSettings, error) ## DNS @@ -1549,27 +1586,41 @@ Methods: ## Rules +Params Types: + +- email_routing.ActionParam +- email_routing.ActionItemParam +- email_routing.MatcherParam +- email_routing.MatcherItemParam + Response Types: -- email_routing.RuleNewResponse -- email_routing.RuleUpdateResponse -- email_routing.RuleListResponse -- email_routing.RuleDeleteResponse -- email_routing.RuleGetResponse +- email_routing.Action +- email_routing.ActionItem +- email_routing.Matcher +- email_routing.MatcherItem +- email_routing.Properties Methods: -- client.EmailRouting.Rules.New(ctx context.Context, zoneIdentifier string, body email_routing.RuleNewParams) (email_routing.RuleNewResponse, error) -- client.EmailRouting.Rules.Update(ctx context.Context, zoneIdentifier string, ruleIdentifier string, body email_routing.RuleUpdateParams) (email_routing.RuleUpdateResponse, error) -- client.EmailRouting.Rules.List(ctx context.Context, zoneIdentifier string, query email_routing.RuleListParams) (pagination.V4PagePaginationArray[email_routing.RuleListResponse], error) -- client.EmailRouting.Rules.Delete(ctx context.Context, zoneIdentifier string, ruleIdentifier string) (email_routing.RuleDeleteResponse, error) -- client.EmailRouting.Rules.Get(ctx context.Context, zoneIdentifier string, ruleIdentifier string) (email_routing.RuleGetResponse, error) +- client.EmailRouting.Rules.New(ctx context.Context, zoneIdentifier string, body email_routing.RuleNewParams) (email_routing.Properties, error) +- client.EmailRouting.Rules.Update(ctx context.Context, zoneIdentifier string, ruleIdentifier string, body email_routing.RuleUpdateParams) (email_routing.Properties, error) +- client.EmailRouting.Rules.List(ctx context.Context, zoneIdentifier string, query email_routing.RuleListParams) (pagination.V4PagePaginationArray[email_routing.Properties], error) +- client.EmailRouting.Rules.Delete(ctx context.Context, zoneIdentifier string, ruleIdentifier string) (email_routing.Properties, error) +- client.EmailRouting.Rules.Get(ctx context.Context, zoneIdentifier string, ruleIdentifier string) (email_routing.Properties, error) ### CatchAlls +Params Types: + +- email_routing.ActionParam +- email_routing.MatcherParam + Response Types: +- email_routing.Action - email_routing.EmailCatchAllRule +- email_routing.Matcher Methods: @@ -1580,17 +1631,14 @@ Methods: Response Types: -- email_routing.AddressNewResponse -- email_routing.AddressListResponse -- email_routing.AddressDeleteResponse -- email_routing.AddressGetResponse +- email_routing.DestinationAddress Methods: -- client.EmailRouting.Addresses.New(ctx context.Context, accountIdentifier string, body email_routing.AddressNewParams) (email_routing.AddressNewResponse, error) -- client.EmailRouting.Addresses.List(ctx context.Context, accountIdentifier string, query email_routing.AddressListParams) (pagination.V4PagePaginationArray[email_routing.AddressListResponse], error) -- client.EmailRouting.Addresses.Delete(ctx context.Context, accountIdentifier string, destinationAddressIdentifier string) (email_routing.AddressDeleteResponse, error) -- client.EmailRouting.Addresses.Get(ctx context.Context, accountIdentifier string, destinationAddressIdentifier string) (email_routing.AddressGetResponse, error) +- client.EmailRouting.Addresses.New(ctx context.Context, accountIdentifier string, body email_routing.AddressNewParams) (email_routing.DestinationAddress, error) +- client.EmailRouting.Addresses.List(ctx context.Context, accountIdentifier string, query email_routing.AddressListParams) (pagination.V4PagePaginationArray[email_routing.DestinationAddress], error) +- client.EmailRouting.Addresses.Delete(ctx context.Context, accountIdentifier string, destinationAddressIdentifier string) (email_routing.DestinationAddress, error) +- client.EmailRouting.Addresses.Get(ctx context.Context, accountIdentifier string, destinationAddressIdentifier string) (email_routing.DestinationAddress, error) # Filters @@ -3837,7 +3885,7 @@ Methods: Response Types: -- alerting.AlertingPagerduty +- alerting.Pagerduty - alerting.DestinationPagerdutyNewResponse - alerting.DestinationPagerdutyLinkResponse @@ -3845,7 +3893,7 @@ Methods: - client.Alerting.Destinations.Pagerduty.New(ctx context.Context, body alerting.DestinationPagerdutyNewParams) (alerting.DestinationPagerdutyNewResponse, error) - client.Alerting.Destinations.Pagerduty.Delete(ctx context.Context, body alerting.DestinationPagerdutyDeleteParams) (shared.UnnamedSchemaRef67bbb1ccdd42c3e2937b9fd19f791151Union, error) -- client.Alerting.Destinations.Pagerduty.Get(ctx context.Context, query alerting.DestinationPagerdutyGetParams) ([]alerting.AlertingPagerduty, error) +- client.Alerting.Destinations.Pagerduty.Get(ctx context.Context, query alerting.DestinationPagerdutyGetParams) ([]alerting.Pagerduty, error) - client.Alerting.Destinations.Pagerduty.Link(ctx context.Context, tokenID string, query alerting.DestinationPagerdutyLinkParams) (alerting.DestinationPagerdutyLinkResponse, error) ### Webhooks @@ -3876,9 +3924,16 @@ Methods: ## Policies +Params Types: + +- alerting.FiltersParam +- alerting.MechanismsParam + Response Types: -- alerting.AlertingPolicies +- alerting.Filters +- alerting.Mechanisms +- alerting.Policies - alerting.PolicyNewResponse - alerting.PolicyUpdateResponse @@ -3886,9 +3941,9 @@ Methods: - client.Alerting.Policies.New(ctx context.Context, params alerting.PolicyNewParams) (alerting.PolicyNewResponse, error) - client.Alerting.Policies.Update(ctx context.Context, policyID string, params alerting.PolicyUpdateParams) (alerting.PolicyUpdateResponse, error) -- client.Alerting.Policies.List(ctx context.Context, query alerting.PolicyListParams) (pagination.SinglePage[alerting.AlertingPolicies], error) +- client.Alerting.Policies.List(ctx context.Context, query alerting.PolicyListParams) (pagination.SinglePage[alerting.Policies], error) - client.Alerting.Policies.Delete(ctx context.Context, policyID string, body alerting.PolicyDeleteParams) (shared.UnnamedSchemaRef67bbb1ccdd42c3e2937b9fd19f791151Union, error) -- client.Alerting.Policies.Get(ctx context.Context, policyID string, query alerting.PolicyGetParams) (alerting.AlertingPolicies, error) +- client.Alerting.Policies.Get(ctx context.Context, policyID string, query alerting.PolicyGetParams) (alerting.Policies, error) # D1 @@ -4939,10 +4994,15 @@ Methods: ## Widgets +Params Types: + +- challenges.ChallengesWidgetListItemParam + Response Types: - challenges.ChallengesWidget - challenges.ChallengesWidgetList +- challenges.ChallengesWidgetListItem Methods: @@ -5967,6 +6027,10 @@ Methods: Response Types: +- bot_management.BotFightModeConfiguration +- bot_management.SubscriptionConfiguration +- bot_management.SuperBotFightModeDefinitelyConfiguration +- bot_management.SuperBotFightModeLikelyConfig - bot_management.BotManagementUpdateResponse - bot_management.BotManagementGetResponse diff --git a/bot_management/botmanagement.go b/bot_management/botmanagement.go index 88d58b4c7d6..086d69043ff 100644 --- a/bot_management/botmanagement.go +++ b/bot_management/botmanagement.go @@ -69,161 +69,103 @@ func (r *BotManagementService) Get(ctx context.Context, query BotManagementGetPa return } -type BotManagementUpdateResponse struct { +type BotFightModeConfiguration struct { // Use lightweight, invisible JavaScript detections to improve Bot Management. // [Learn more about JavaScript Detections](https://developers.cloudflare.com/bots/reference/javascript-detections/). EnableJs bool `json:"enable_js"` - // A read-only field that indicates whether the zone currently is running the - // latest ML model. - UsingLatestModel bool `json:"using_latest_model"` // Whether to enable Bot Fight Mode. FightMode bool `json:"fight_mode"` - // Whether to optimize Super Bot Fight Mode protections for Wordpress. - OptimizeWordpress bool `json:"optimize_wordpress"` - // Super Bot Fight Mode (SBFM) action to take on definitely automated requests. - SbfmDefinitelyAutomated BotManagementUpdateResponseSbfmDefinitelyAutomated `json:"sbfm_definitely_automated"` - // Super Bot Fight Mode (SBFM) to enable static resource protection. Enable if - // static resources on your application need bot protection. Note: Static resource - // protection can also result in legitimate traffic being blocked. - SbfmStaticResourceProtection bool `json:"sbfm_static_resource_protection"` - // Super Bot Fight Mode (SBFM) action to take on verified bots requests. - SbfmVerifiedBots BotManagementUpdateResponseSbfmVerifiedBots `json:"sbfm_verified_bots"` - // Super Bot Fight Mode (SBFM) action to take on likely automated requests. - SbfmLikelyAutomated BotManagementUpdateResponseSbfmLikelyAutomated `json:"sbfm_likely_automated"` - // Automatically update to the newest bot detection models created by Cloudflare as - // they are released. - // [Learn more.](https://developers.cloudflare.com/bots/reference/machine-learning-models#model-versions-and-release-notes) - AutoUpdateModel bool `json:"auto_update_model"` - // Whether to disable tracking the highest bot score for a session in the Bot - // Management cookie. - SuppressSessionScore bool `json:"suppress_session_score"` - JSON botManagementUpdateResponseJSON `json:"-"` - union BotManagementUpdateResponseUnion -} - -// botManagementUpdateResponseJSON contains the JSON metadata for the struct -// [BotManagementUpdateResponse] -type botManagementUpdateResponseJSON struct { - EnableJs apijson.Field - UsingLatestModel apijson.Field - FightMode apijson.Field - OptimizeWordpress apijson.Field - SbfmDefinitelyAutomated apijson.Field - SbfmStaticResourceProtection apijson.Field - SbfmVerifiedBots apijson.Field - SbfmLikelyAutomated apijson.Field - AutoUpdateModel apijson.Field - SuppressSessionScore apijson.Field - raw string - ExtraFields map[string]apijson.Field + // A read-only field that indicates whether the zone currently is running the + // latest ML model. + UsingLatestModel bool `json:"using_latest_model"` + JSON botFightModeConfigurationJSON `json:"-"` } -func (r botManagementUpdateResponseJSON) RawJSON() string { - return r.raw +// botFightModeConfigurationJSON contains the JSON metadata for the struct +// [BotFightModeConfiguration] +type botFightModeConfigurationJSON struct { + EnableJs apijson.Field + FightMode apijson.Field + UsingLatestModel apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r *BotManagementUpdateResponse) UnmarshalJSON(data []byte) (err error) { - err = apijson.UnmarshalRoot(data, &r.union) - if err != nil { - return err - } - return apijson.Port(r.union, &r) +func (r *BotFightModeConfiguration) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) } -func (r BotManagementUpdateResponse) AsUnion() BotManagementUpdateResponseUnion { - return r.union +func (r botFightModeConfigurationJSON) RawJSON() string { + return r.raw } -// Union satisfied by -// [bot_management.BotManagementUpdateResponseBotManagementBotFightModeConfig], -// [bot_management.BotManagementUpdateResponseBotManagementSbfmDefinitelyConfig], -// [bot_management.BotManagementUpdateResponseBotManagementSbfmLikelyConfig] or -// [bot_management.BotManagementUpdateResponseBotManagementBmSubscriptionConfig]. -type BotManagementUpdateResponseUnion interface { - implementsBotManagementBotManagementUpdateResponse() -} +func (r BotFightModeConfiguration) implementsBotManagementBotManagementUpdateResponse() {} -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*BotManagementUpdateResponseUnion)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(BotManagementUpdateResponseBotManagementBotFightModeConfig{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(BotManagementUpdateResponseBotManagementSbfmDefinitelyConfig{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(BotManagementUpdateResponseBotManagementSbfmLikelyConfig{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(BotManagementUpdateResponseBotManagementBmSubscriptionConfig{}), - }, - ) -} +func (r BotFightModeConfiguration) implementsBotManagementBotManagementGetResponse() {} -type BotManagementUpdateResponseBotManagementBotFightModeConfig struct { +type SubscriptionConfiguration struct { + // Automatically update to the newest bot detection models created by Cloudflare as + // they are released. + // [Learn more.](https://developers.cloudflare.com/bots/reference/machine-learning-models#model-versions-and-release-notes) + AutoUpdateModel bool `json:"auto_update_model"` // Use lightweight, invisible JavaScript detections to improve Bot Management. // [Learn more about JavaScript Detections](https://developers.cloudflare.com/bots/reference/javascript-detections/). EnableJs bool `json:"enable_js"` - // Whether to enable Bot Fight Mode. - FightMode bool `json:"fight_mode"` + // Whether to disable tracking the highest bot score for a session in the Bot + // Management cookie. + SuppressSessionScore bool `json:"suppress_session_score"` // A read-only field that indicates whether the zone currently is running the // latest ML model. - UsingLatestModel bool `json:"using_latest_model"` - JSON botManagementUpdateResponseBotManagementBotFightModeConfigJSON `json:"-"` + UsingLatestModel bool `json:"using_latest_model"` + JSON subscriptionConfigurationJSON `json:"-"` } -// botManagementUpdateResponseBotManagementBotFightModeConfigJSON contains the JSON -// metadata for the struct -// [BotManagementUpdateResponseBotManagementBotFightModeConfig] -type botManagementUpdateResponseBotManagementBotFightModeConfigJSON struct { - EnableJs apijson.Field - FightMode apijson.Field - UsingLatestModel apijson.Field - raw string - ExtraFields map[string]apijson.Field +// subscriptionConfigurationJSON contains the JSON metadata for the struct +// [SubscriptionConfiguration] +type subscriptionConfigurationJSON struct { + AutoUpdateModel apijson.Field + EnableJs apijson.Field + SuppressSessionScore apijson.Field + UsingLatestModel apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r *BotManagementUpdateResponseBotManagementBotFightModeConfig) UnmarshalJSON(data []byte) (err error) { +func (r *SubscriptionConfiguration) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r botManagementUpdateResponseBotManagementBotFightModeConfigJSON) RawJSON() string { +func (r subscriptionConfigurationJSON) RawJSON() string { return r.raw } -func (r BotManagementUpdateResponseBotManagementBotFightModeConfig) implementsBotManagementBotManagementUpdateResponse() { -} +func (r SubscriptionConfiguration) implementsBotManagementBotManagementUpdateResponse() {} + +func (r SubscriptionConfiguration) implementsBotManagementBotManagementGetResponse() {} -type BotManagementUpdateResponseBotManagementSbfmDefinitelyConfig struct { +type SuperBotFightModeDefinitelyConfiguration struct { // Use lightweight, invisible JavaScript detections to improve Bot Management. // [Learn more about JavaScript Detections](https://developers.cloudflare.com/bots/reference/javascript-detections/). EnableJs bool `json:"enable_js"` // Whether to optimize Super Bot Fight Mode protections for Wordpress. OptimizeWordpress bool `json:"optimize_wordpress"` // Super Bot Fight Mode (SBFM) action to take on definitely automated requests. - SbfmDefinitelyAutomated BotManagementUpdateResponseBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomated `json:"sbfm_definitely_automated"` + SbfmDefinitelyAutomated SuperBotFightModeDefinitelyConfigurationSbfmDefinitelyAutomated `json:"sbfm_definitely_automated"` // Super Bot Fight Mode (SBFM) to enable static resource protection. Enable if // static resources on your application need bot protection. Note: Static resource // protection can also result in legitimate traffic being blocked. SbfmStaticResourceProtection bool `json:"sbfm_static_resource_protection"` // Super Bot Fight Mode (SBFM) action to take on verified bots requests. - SbfmVerifiedBots BotManagementUpdateResponseBotManagementSbfmDefinitelyConfigSbfmVerifiedBots `json:"sbfm_verified_bots"` + SbfmVerifiedBots SuperBotFightModeDefinitelyConfigurationSbfmVerifiedBots `json:"sbfm_verified_bots"` // A read-only field that indicates whether the zone currently is running the // latest ML model. - UsingLatestModel bool `json:"using_latest_model"` - JSON botManagementUpdateResponseBotManagementSbfmDefinitelyConfigJSON `json:"-"` + UsingLatestModel bool `json:"using_latest_model"` + JSON superBotFightModeDefinitelyConfigurationJSON `json:"-"` } -// botManagementUpdateResponseBotManagementSbfmDefinitelyConfigJSON contains the -// JSON metadata for the struct -// [BotManagementUpdateResponseBotManagementSbfmDefinitelyConfig] -type botManagementUpdateResponseBotManagementSbfmDefinitelyConfigJSON struct { +// superBotFightModeDefinitelyConfigurationJSON contains the JSON metadata for the +// struct [SuperBotFightModeDefinitelyConfiguration] +type superBotFightModeDefinitelyConfigurationJSON struct { EnableJs apijson.Field OptimizeWordpress apijson.Field SbfmDefinitelyAutomated apijson.Field @@ -234,76 +176,77 @@ type botManagementUpdateResponseBotManagementSbfmDefinitelyConfigJSON struct { ExtraFields map[string]apijson.Field } -func (r *BotManagementUpdateResponseBotManagementSbfmDefinitelyConfig) UnmarshalJSON(data []byte) (err error) { +func (r *SuperBotFightModeDefinitelyConfiguration) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r botManagementUpdateResponseBotManagementSbfmDefinitelyConfigJSON) RawJSON() string { +func (r superBotFightModeDefinitelyConfigurationJSON) RawJSON() string { return r.raw } -func (r BotManagementUpdateResponseBotManagementSbfmDefinitelyConfig) implementsBotManagementBotManagementUpdateResponse() { +func (r SuperBotFightModeDefinitelyConfiguration) implementsBotManagementBotManagementUpdateResponse() { } +func (r SuperBotFightModeDefinitelyConfiguration) implementsBotManagementBotManagementGetResponse() {} + // Super Bot Fight Mode (SBFM) action to take on definitely automated requests. -type BotManagementUpdateResponseBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomated string +type SuperBotFightModeDefinitelyConfigurationSbfmDefinitelyAutomated string const ( - BotManagementUpdateResponseBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomatedAllow BotManagementUpdateResponseBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomated = "allow" - BotManagementUpdateResponseBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomatedBlock BotManagementUpdateResponseBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomated = "block" - BotManagementUpdateResponseBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomatedManagedChallenge BotManagementUpdateResponseBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomated = "managed_challenge" + SuperBotFightModeDefinitelyConfigurationSbfmDefinitelyAutomatedAllow SuperBotFightModeDefinitelyConfigurationSbfmDefinitelyAutomated = "allow" + SuperBotFightModeDefinitelyConfigurationSbfmDefinitelyAutomatedBlock SuperBotFightModeDefinitelyConfigurationSbfmDefinitelyAutomated = "block" + SuperBotFightModeDefinitelyConfigurationSbfmDefinitelyAutomatedManagedChallenge SuperBotFightModeDefinitelyConfigurationSbfmDefinitelyAutomated = "managed_challenge" ) -func (r BotManagementUpdateResponseBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomated) IsKnown() bool { +func (r SuperBotFightModeDefinitelyConfigurationSbfmDefinitelyAutomated) IsKnown() bool { switch r { - case BotManagementUpdateResponseBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomatedAllow, BotManagementUpdateResponseBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomatedBlock, BotManagementUpdateResponseBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomatedManagedChallenge: + case SuperBotFightModeDefinitelyConfigurationSbfmDefinitelyAutomatedAllow, SuperBotFightModeDefinitelyConfigurationSbfmDefinitelyAutomatedBlock, SuperBotFightModeDefinitelyConfigurationSbfmDefinitelyAutomatedManagedChallenge: return true } return false } // Super Bot Fight Mode (SBFM) action to take on verified bots requests. -type BotManagementUpdateResponseBotManagementSbfmDefinitelyConfigSbfmVerifiedBots string +type SuperBotFightModeDefinitelyConfigurationSbfmVerifiedBots string const ( - BotManagementUpdateResponseBotManagementSbfmDefinitelyConfigSbfmVerifiedBotsAllow BotManagementUpdateResponseBotManagementSbfmDefinitelyConfigSbfmVerifiedBots = "allow" - BotManagementUpdateResponseBotManagementSbfmDefinitelyConfigSbfmVerifiedBotsBlock BotManagementUpdateResponseBotManagementSbfmDefinitelyConfigSbfmVerifiedBots = "block" + SuperBotFightModeDefinitelyConfigurationSbfmVerifiedBotsAllow SuperBotFightModeDefinitelyConfigurationSbfmVerifiedBots = "allow" + SuperBotFightModeDefinitelyConfigurationSbfmVerifiedBotsBlock SuperBotFightModeDefinitelyConfigurationSbfmVerifiedBots = "block" ) -func (r BotManagementUpdateResponseBotManagementSbfmDefinitelyConfigSbfmVerifiedBots) IsKnown() bool { +func (r SuperBotFightModeDefinitelyConfigurationSbfmVerifiedBots) IsKnown() bool { switch r { - case BotManagementUpdateResponseBotManagementSbfmDefinitelyConfigSbfmVerifiedBotsAllow, BotManagementUpdateResponseBotManagementSbfmDefinitelyConfigSbfmVerifiedBotsBlock: + case SuperBotFightModeDefinitelyConfigurationSbfmVerifiedBotsAllow, SuperBotFightModeDefinitelyConfigurationSbfmVerifiedBotsBlock: return true } return false } -type BotManagementUpdateResponseBotManagementSbfmLikelyConfig struct { +type SuperBotFightModeLikelyConfig struct { // Use lightweight, invisible JavaScript detections to improve Bot Management. // [Learn more about JavaScript Detections](https://developers.cloudflare.com/bots/reference/javascript-detections/). EnableJs bool `json:"enable_js"` // Whether to optimize Super Bot Fight Mode protections for Wordpress. OptimizeWordpress bool `json:"optimize_wordpress"` // Super Bot Fight Mode (SBFM) action to take on definitely automated requests. - SbfmDefinitelyAutomated BotManagementUpdateResponseBotManagementSbfmLikelyConfigSbfmDefinitelyAutomated `json:"sbfm_definitely_automated"` + SbfmDefinitelyAutomated SuperBotFightModeLikelyConfigSbfmDefinitelyAutomated `json:"sbfm_definitely_automated"` // Super Bot Fight Mode (SBFM) action to take on likely automated requests. - SbfmLikelyAutomated BotManagementUpdateResponseBotManagementSbfmLikelyConfigSbfmLikelyAutomated `json:"sbfm_likely_automated"` + SbfmLikelyAutomated SuperBotFightModeLikelyConfigSbfmLikelyAutomated `json:"sbfm_likely_automated"` // Super Bot Fight Mode (SBFM) to enable static resource protection. Enable if // static resources on your application need bot protection. Note: Static resource // protection can also result in legitimate traffic being blocked. SbfmStaticResourceProtection bool `json:"sbfm_static_resource_protection"` // Super Bot Fight Mode (SBFM) action to take on verified bots requests. - SbfmVerifiedBots BotManagementUpdateResponseBotManagementSbfmLikelyConfigSbfmVerifiedBots `json:"sbfm_verified_bots"` + SbfmVerifiedBots SuperBotFightModeLikelyConfigSbfmVerifiedBots `json:"sbfm_verified_bots"` // A read-only field that indicates whether the zone currently is running the // latest ML model. - UsingLatestModel bool `json:"using_latest_model"` - JSON botManagementUpdateResponseBotManagementSbfmLikelyConfigJSON `json:"-"` + UsingLatestModel bool `json:"using_latest_model"` + JSON superBotFightModeLikelyConfigJSON `json:"-"` } -// botManagementUpdateResponseBotManagementSbfmLikelyConfigJSON contains the JSON -// metadata for the struct -// [BotManagementUpdateResponseBotManagementSbfmLikelyConfig] -type botManagementUpdateResponseBotManagementSbfmLikelyConfigJSON struct { +// superBotFightModeLikelyConfigJSON contains the JSON metadata for the struct +// [SuperBotFightModeLikelyConfig] +type superBotFightModeLikelyConfigJSON struct { EnableJs apijson.Field OptimizeWordpress apijson.Field SbfmDefinitelyAutomated apijson.Field @@ -315,105 +258,162 @@ type botManagementUpdateResponseBotManagementSbfmLikelyConfigJSON struct { ExtraFields map[string]apijson.Field } -func (r *BotManagementUpdateResponseBotManagementSbfmLikelyConfig) UnmarshalJSON(data []byte) (err error) { +func (r *SuperBotFightModeLikelyConfig) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r botManagementUpdateResponseBotManagementSbfmLikelyConfigJSON) RawJSON() string { +func (r superBotFightModeLikelyConfigJSON) RawJSON() string { return r.raw } -func (r BotManagementUpdateResponseBotManagementSbfmLikelyConfig) implementsBotManagementBotManagementUpdateResponse() { -} +func (r SuperBotFightModeLikelyConfig) implementsBotManagementBotManagementUpdateResponse() {} + +func (r SuperBotFightModeLikelyConfig) implementsBotManagementBotManagementGetResponse() {} // Super Bot Fight Mode (SBFM) action to take on definitely automated requests. -type BotManagementUpdateResponseBotManagementSbfmLikelyConfigSbfmDefinitelyAutomated string +type SuperBotFightModeLikelyConfigSbfmDefinitelyAutomated string const ( - BotManagementUpdateResponseBotManagementSbfmLikelyConfigSbfmDefinitelyAutomatedAllow BotManagementUpdateResponseBotManagementSbfmLikelyConfigSbfmDefinitelyAutomated = "allow" - BotManagementUpdateResponseBotManagementSbfmLikelyConfigSbfmDefinitelyAutomatedBlock BotManagementUpdateResponseBotManagementSbfmLikelyConfigSbfmDefinitelyAutomated = "block" - BotManagementUpdateResponseBotManagementSbfmLikelyConfigSbfmDefinitelyAutomatedManagedChallenge BotManagementUpdateResponseBotManagementSbfmLikelyConfigSbfmDefinitelyAutomated = "managed_challenge" + SuperBotFightModeLikelyConfigSbfmDefinitelyAutomatedAllow SuperBotFightModeLikelyConfigSbfmDefinitelyAutomated = "allow" + SuperBotFightModeLikelyConfigSbfmDefinitelyAutomatedBlock SuperBotFightModeLikelyConfigSbfmDefinitelyAutomated = "block" + SuperBotFightModeLikelyConfigSbfmDefinitelyAutomatedManagedChallenge SuperBotFightModeLikelyConfigSbfmDefinitelyAutomated = "managed_challenge" ) -func (r BotManagementUpdateResponseBotManagementSbfmLikelyConfigSbfmDefinitelyAutomated) IsKnown() bool { +func (r SuperBotFightModeLikelyConfigSbfmDefinitelyAutomated) IsKnown() bool { switch r { - case BotManagementUpdateResponseBotManagementSbfmLikelyConfigSbfmDefinitelyAutomatedAllow, BotManagementUpdateResponseBotManagementSbfmLikelyConfigSbfmDefinitelyAutomatedBlock, BotManagementUpdateResponseBotManagementSbfmLikelyConfigSbfmDefinitelyAutomatedManagedChallenge: + case SuperBotFightModeLikelyConfigSbfmDefinitelyAutomatedAllow, SuperBotFightModeLikelyConfigSbfmDefinitelyAutomatedBlock, SuperBotFightModeLikelyConfigSbfmDefinitelyAutomatedManagedChallenge: return true } return false } // Super Bot Fight Mode (SBFM) action to take on likely automated requests. -type BotManagementUpdateResponseBotManagementSbfmLikelyConfigSbfmLikelyAutomated string +type SuperBotFightModeLikelyConfigSbfmLikelyAutomated string const ( - BotManagementUpdateResponseBotManagementSbfmLikelyConfigSbfmLikelyAutomatedAllow BotManagementUpdateResponseBotManagementSbfmLikelyConfigSbfmLikelyAutomated = "allow" - BotManagementUpdateResponseBotManagementSbfmLikelyConfigSbfmLikelyAutomatedBlock BotManagementUpdateResponseBotManagementSbfmLikelyConfigSbfmLikelyAutomated = "block" - BotManagementUpdateResponseBotManagementSbfmLikelyConfigSbfmLikelyAutomatedManagedChallenge BotManagementUpdateResponseBotManagementSbfmLikelyConfigSbfmLikelyAutomated = "managed_challenge" + SuperBotFightModeLikelyConfigSbfmLikelyAutomatedAllow SuperBotFightModeLikelyConfigSbfmLikelyAutomated = "allow" + SuperBotFightModeLikelyConfigSbfmLikelyAutomatedBlock SuperBotFightModeLikelyConfigSbfmLikelyAutomated = "block" + SuperBotFightModeLikelyConfigSbfmLikelyAutomatedManagedChallenge SuperBotFightModeLikelyConfigSbfmLikelyAutomated = "managed_challenge" ) -func (r BotManagementUpdateResponseBotManagementSbfmLikelyConfigSbfmLikelyAutomated) IsKnown() bool { +func (r SuperBotFightModeLikelyConfigSbfmLikelyAutomated) IsKnown() bool { switch r { - case BotManagementUpdateResponseBotManagementSbfmLikelyConfigSbfmLikelyAutomatedAllow, BotManagementUpdateResponseBotManagementSbfmLikelyConfigSbfmLikelyAutomatedBlock, BotManagementUpdateResponseBotManagementSbfmLikelyConfigSbfmLikelyAutomatedManagedChallenge: + case SuperBotFightModeLikelyConfigSbfmLikelyAutomatedAllow, SuperBotFightModeLikelyConfigSbfmLikelyAutomatedBlock, SuperBotFightModeLikelyConfigSbfmLikelyAutomatedManagedChallenge: return true } return false } // Super Bot Fight Mode (SBFM) action to take on verified bots requests. -type BotManagementUpdateResponseBotManagementSbfmLikelyConfigSbfmVerifiedBots string +type SuperBotFightModeLikelyConfigSbfmVerifiedBots string const ( - BotManagementUpdateResponseBotManagementSbfmLikelyConfigSbfmVerifiedBotsAllow BotManagementUpdateResponseBotManagementSbfmLikelyConfigSbfmVerifiedBots = "allow" - BotManagementUpdateResponseBotManagementSbfmLikelyConfigSbfmVerifiedBotsBlock BotManagementUpdateResponseBotManagementSbfmLikelyConfigSbfmVerifiedBots = "block" + SuperBotFightModeLikelyConfigSbfmVerifiedBotsAllow SuperBotFightModeLikelyConfigSbfmVerifiedBots = "allow" + SuperBotFightModeLikelyConfigSbfmVerifiedBotsBlock SuperBotFightModeLikelyConfigSbfmVerifiedBots = "block" ) -func (r BotManagementUpdateResponseBotManagementSbfmLikelyConfigSbfmVerifiedBots) IsKnown() bool { +func (r SuperBotFightModeLikelyConfigSbfmVerifiedBots) IsKnown() bool { switch r { - case BotManagementUpdateResponseBotManagementSbfmLikelyConfigSbfmVerifiedBotsAllow, BotManagementUpdateResponseBotManagementSbfmLikelyConfigSbfmVerifiedBotsBlock: + case SuperBotFightModeLikelyConfigSbfmVerifiedBotsAllow, SuperBotFightModeLikelyConfigSbfmVerifiedBotsBlock: return true } return false } -type BotManagementUpdateResponseBotManagementBmSubscriptionConfig struct { +type BotManagementUpdateResponse struct { + // Use lightweight, invisible JavaScript detections to improve Bot Management. + // [Learn more about JavaScript Detections](https://developers.cloudflare.com/bots/reference/javascript-detections/). + EnableJs bool `json:"enable_js"` + // A read-only field that indicates whether the zone currently is running the + // latest ML model. + UsingLatestModel bool `json:"using_latest_model"` + // Whether to enable Bot Fight Mode. + FightMode bool `json:"fight_mode"` + // Whether to optimize Super Bot Fight Mode protections for Wordpress. + OptimizeWordpress bool `json:"optimize_wordpress"` + // Super Bot Fight Mode (SBFM) action to take on definitely automated requests. + SbfmDefinitelyAutomated BotManagementUpdateResponseSbfmDefinitelyAutomated `json:"sbfm_definitely_automated"` + // Super Bot Fight Mode (SBFM) to enable static resource protection. Enable if + // static resources on your application need bot protection. Note: Static resource + // protection can also result in legitimate traffic being blocked. + SbfmStaticResourceProtection bool `json:"sbfm_static_resource_protection"` + // Super Bot Fight Mode (SBFM) action to take on verified bots requests. + SbfmVerifiedBots BotManagementUpdateResponseSbfmVerifiedBots `json:"sbfm_verified_bots"` + // Super Bot Fight Mode (SBFM) action to take on likely automated requests. + SbfmLikelyAutomated BotManagementUpdateResponseSbfmLikelyAutomated `json:"sbfm_likely_automated"` // Automatically update to the newest bot detection models created by Cloudflare as // they are released. // [Learn more.](https://developers.cloudflare.com/bots/reference/machine-learning-models#model-versions-and-release-notes) AutoUpdateModel bool `json:"auto_update_model"` - // Use lightweight, invisible JavaScript detections to improve Bot Management. - // [Learn more about JavaScript Detections](https://developers.cloudflare.com/bots/reference/javascript-detections/). - EnableJs bool `json:"enable_js"` // Whether to disable tracking the highest bot score for a session in the Bot // Management cookie. - SuppressSessionScore bool `json:"suppress_session_score"` - // A read-only field that indicates whether the zone currently is running the - // latest ML model. - UsingLatestModel bool `json:"using_latest_model"` - JSON botManagementUpdateResponseBotManagementBmSubscriptionConfigJSON `json:"-"` + SuppressSessionScore bool `json:"suppress_session_score"` + JSON botManagementUpdateResponseJSON `json:"-"` + union BotManagementUpdateResponseUnion } -// botManagementUpdateResponseBotManagementBmSubscriptionConfigJSON contains the -// JSON metadata for the struct -// [BotManagementUpdateResponseBotManagementBmSubscriptionConfig] -type botManagementUpdateResponseBotManagementBmSubscriptionConfigJSON struct { - AutoUpdateModel apijson.Field - EnableJs apijson.Field - SuppressSessionScore apijson.Field - UsingLatestModel apijson.Field - raw string - ExtraFields map[string]apijson.Field +// botManagementUpdateResponseJSON contains the JSON metadata for the struct +// [BotManagementUpdateResponse] +type botManagementUpdateResponseJSON struct { + EnableJs apijson.Field + UsingLatestModel apijson.Field + FightMode apijson.Field + OptimizeWordpress apijson.Field + SbfmDefinitelyAutomated apijson.Field + SbfmStaticResourceProtection apijson.Field + SbfmVerifiedBots apijson.Field + SbfmLikelyAutomated apijson.Field + AutoUpdateModel apijson.Field + SuppressSessionScore apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r *BotManagementUpdateResponseBotManagementBmSubscriptionConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) +func (r botManagementUpdateResponseJSON) RawJSON() string { + return r.raw } -func (r botManagementUpdateResponseBotManagementBmSubscriptionConfigJSON) RawJSON() string { - return r.raw +func (r *BotManagementUpdateResponse) UnmarshalJSON(data []byte) (err error) { + err = apijson.UnmarshalRoot(data, &r.union) + if err != nil { + return err + } + return apijson.Port(r.union, &r) } -func (r BotManagementUpdateResponseBotManagementBmSubscriptionConfig) implementsBotManagementBotManagementUpdateResponse() { +func (r BotManagementUpdateResponse) AsUnion() BotManagementUpdateResponseUnion { + return r.union +} + +// Union satisfied by [bot_management.BotFightModeConfiguration], +// [bot_management.SuperBotFightModeDefinitelyConfiguration], +// [bot_management.SuperBotFightModeLikelyConfig] or +// [bot_management.SubscriptionConfiguration]. +type BotManagementUpdateResponseUnion interface { + implementsBotManagementBotManagementUpdateResponse() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*BotManagementUpdateResponseUnion)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(BotFightModeConfiguration{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(SuperBotFightModeDefinitelyConfiguration{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(SuperBotFightModeLikelyConfig{}), + }, + apijson.UnionVariant{ + TypeFilter: gjson.JSON, + Type: reflect.TypeOf(SubscriptionConfiguration{}), + }, + ) } // Super Bot Fight Mode (SBFM) action to take on definitely automated requests. @@ -531,11 +531,10 @@ func (r BotManagementGetResponse) AsUnion() BotManagementGetResponseUnion { return r.union } -// Union satisfied by -// [bot_management.BotManagementGetResponseBotManagementBotFightModeConfig], -// [bot_management.BotManagementGetResponseBotManagementSbfmDefinitelyConfig], -// [bot_management.BotManagementGetResponseBotManagementSbfmLikelyConfig] or -// [bot_management.BotManagementGetResponseBotManagementBmSubscriptionConfig]. +// Union satisfied by [bot_management.BotFightModeConfiguration], +// [bot_management.SuperBotFightModeDefinitelyConfiguration], +// [bot_management.SuperBotFightModeLikelyConfig] or +// [bot_management.SubscriptionConfiguration]. type BotManagementGetResponseUnion interface { implementsBotManagementBotManagementGetResponse() } @@ -546,272 +545,23 @@ func init() { "", apijson.UnionVariant{ TypeFilter: gjson.JSON, - Type: reflect.TypeOf(BotManagementGetResponseBotManagementBotFightModeConfig{}), + Type: reflect.TypeOf(BotFightModeConfiguration{}), }, apijson.UnionVariant{ TypeFilter: gjson.JSON, - Type: reflect.TypeOf(BotManagementGetResponseBotManagementSbfmDefinitelyConfig{}), + Type: reflect.TypeOf(SuperBotFightModeDefinitelyConfiguration{}), }, apijson.UnionVariant{ TypeFilter: gjson.JSON, - Type: reflect.TypeOf(BotManagementGetResponseBotManagementSbfmLikelyConfig{}), + Type: reflect.TypeOf(SuperBotFightModeLikelyConfig{}), }, apijson.UnionVariant{ TypeFilter: gjson.JSON, - Type: reflect.TypeOf(BotManagementGetResponseBotManagementBmSubscriptionConfig{}), + Type: reflect.TypeOf(SubscriptionConfiguration{}), }, ) } -type BotManagementGetResponseBotManagementBotFightModeConfig struct { - // Use lightweight, invisible JavaScript detections to improve Bot Management. - // [Learn more about JavaScript Detections](https://developers.cloudflare.com/bots/reference/javascript-detections/). - EnableJs bool `json:"enable_js"` - // Whether to enable Bot Fight Mode. - FightMode bool `json:"fight_mode"` - // A read-only field that indicates whether the zone currently is running the - // latest ML model. - UsingLatestModel bool `json:"using_latest_model"` - JSON botManagementGetResponseBotManagementBotFightModeConfigJSON `json:"-"` -} - -// botManagementGetResponseBotManagementBotFightModeConfigJSON contains the JSON -// metadata for the struct -// [BotManagementGetResponseBotManagementBotFightModeConfig] -type botManagementGetResponseBotManagementBotFightModeConfigJSON struct { - EnableJs apijson.Field - FightMode apijson.Field - UsingLatestModel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *BotManagementGetResponseBotManagementBotFightModeConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r botManagementGetResponseBotManagementBotFightModeConfigJSON) RawJSON() string { - return r.raw -} - -func (r BotManagementGetResponseBotManagementBotFightModeConfig) implementsBotManagementBotManagementGetResponse() { -} - -type BotManagementGetResponseBotManagementSbfmDefinitelyConfig struct { - // Use lightweight, invisible JavaScript detections to improve Bot Management. - // [Learn more about JavaScript Detections](https://developers.cloudflare.com/bots/reference/javascript-detections/). - EnableJs bool `json:"enable_js"` - // Whether to optimize Super Bot Fight Mode protections for Wordpress. - OptimizeWordpress bool `json:"optimize_wordpress"` - // Super Bot Fight Mode (SBFM) action to take on definitely automated requests. - SbfmDefinitelyAutomated BotManagementGetResponseBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomated `json:"sbfm_definitely_automated"` - // Super Bot Fight Mode (SBFM) to enable static resource protection. Enable if - // static resources on your application need bot protection. Note: Static resource - // protection can also result in legitimate traffic being blocked. - SbfmStaticResourceProtection bool `json:"sbfm_static_resource_protection"` - // Super Bot Fight Mode (SBFM) action to take on verified bots requests. - SbfmVerifiedBots BotManagementGetResponseBotManagementSbfmDefinitelyConfigSbfmVerifiedBots `json:"sbfm_verified_bots"` - // A read-only field that indicates whether the zone currently is running the - // latest ML model. - UsingLatestModel bool `json:"using_latest_model"` - JSON botManagementGetResponseBotManagementSbfmDefinitelyConfigJSON `json:"-"` -} - -// botManagementGetResponseBotManagementSbfmDefinitelyConfigJSON contains the JSON -// metadata for the struct -// [BotManagementGetResponseBotManagementSbfmDefinitelyConfig] -type botManagementGetResponseBotManagementSbfmDefinitelyConfigJSON struct { - EnableJs apijson.Field - OptimizeWordpress apijson.Field - SbfmDefinitelyAutomated apijson.Field - SbfmStaticResourceProtection apijson.Field - SbfmVerifiedBots apijson.Field - UsingLatestModel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *BotManagementGetResponseBotManagementSbfmDefinitelyConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r botManagementGetResponseBotManagementSbfmDefinitelyConfigJSON) RawJSON() string { - return r.raw -} - -func (r BotManagementGetResponseBotManagementSbfmDefinitelyConfig) implementsBotManagementBotManagementGetResponse() { -} - -// Super Bot Fight Mode (SBFM) action to take on definitely automated requests. -type BotManagementGetResponseBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomated string - -const ( - BotManagementGetResponseBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomatedAllow BotManagementGetResponseBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomated = "allow" - BotManagementGetResponseBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomatedBlock BotManagementGetResponseBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomated = "block" - BotManagementGetResponseBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomatedManagedChallenge BotManagementGetResponseBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomated = "managed_challenge" -) - -func (r BotManagementGetResponseBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomated) IsKnown() bool { - switch r { - case BotManagementGetResponseBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomatedAllow, BotManagementGetResponseBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomatedBlock, BotManagementGetResponseBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomatedManagedChallenge: - return true - } - return false -} - -// Super Bot Fight Mode (SBFM) action to take on verified bots requests. -type BotManagementGetResponseBotManagementSbfmDefinitelyConfigSbfmVerifiedBots string - -const ( - BotManagementGetResponseBotManagementSbfmDefinitelyConfigSbfmVerifiedBotsAllow BotManagementGetResponseBotManagementSbfmDefinitelyConfigSbfmVerifiedBots = "allow" - BotManagementGetResponseBotManagementSbfmDefinitelyConfigSbfmVerifiedBotsBlock BotManagementGetResponseBotManagementSbfmDefinitelyConfigSbfmVerifiedBots = "block" -) - -func (r BotManagementGetResponseBotManagementSbfmDefinitelyConfigSbfmVerifiedBots) IsKnown() bool { - switch r { - case BotManagementGetResponseBotManagementSbfmDefinitelyConfigSbfmVerifiedBotsAllow, BotManagementGetResponseBotManagementSbfmDefinitelyConfigSbfmVerifiedBotsBlock: - return true - } - return false -} - -type BotManagementGetResponseBotManagementSbfmLikelyConfig struct { - // Use lightweight, invisible JavaScript detections to improve Bot Management. - // [Learn more about JavaScript Detections](https://developers.cloudflare.com/bots/reference/javascript-detections/). - EnableJs bool `json:"enable_js"` - // Whether to optimize Super Bot Fight Mode protections for Wordpress. - OptimizeWordpress bool `json:"optimize_wordpress"` - // Super Bot Fight Mode (SBFM) action to take on definitely automated requests. - SbfmDefinitelyAutomated BotManagementGetResponseBotManagementSbfmLikelyConfigSbfmDefinitelyAutomated `json:"sbfm_definitely_automated"` - // Super Bot Fight Mode (SBFM) action to take on likely automated requests. - SbfmLikelyAutomated BotManagementGetResponseBotManagementSbfmLikelyConfigSbfmLikelyAutomated `json:"sbfm_likely_automated"` - // Super Bot Fight Mode (SBFM) to enable static resource protection. Enable if - // static resources on your application need bot protection. Note: Static resource - // protection can also result in legitimate traffic being blocked. - SbfmStaticResourceProtection bool `json:"sbfm_static_resource_protection"` - // Super Bot Fight Mode (SBFM) action to take on verified bots requests. - SbfmVerifiedBots BotManagementGetResponseBotManagementSbfmLikelyConfigSbfmVerifiedBots `json:"sbfm_verified_bots"` - // A read-only field that indicates whether the zone currently is running the - // latest ML model. - UsingLatestModel bool `json:"using_latest_model"` - JSON botManagementGetResponseBotManagementSbfmLikelyConfigJSON `json:"-"` -} - -// botManagementGetResponseBotManagementSbfmLikelyConfigJSON contains the JSON -// metadata for the struct [BotManagementGetResponseBotManagementSbfmLikelyConfig] -type botManagementGetResponseBotManagementSbfmLikelyConfigJSON struct { - EnableJs apijson.Field - OptimizeWordpress apijson.Field - SbfmDefinitelyAutomated apijson.Field - SbfmLikelyAutomated apijson.Field - SbfmStaticResourceProtection apijson.Field - SbfmVerifiedBots apijson.Field - UsingLatestModel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *BotManagementGetResponseBotManagementSbfmLikelyConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r botManagementGetResponseBotManagementSbfmLikelyConfigJSON) RawJSON() string { - return r.raw -} - -func (r BotManagementGetResponseBotManagementSbfmLikelyConfig) implementsBotManagementBotManagementGetResponse() { -} - -// Super Bot Fight Mode (SBFM) action to take on definitely automated requests. -type BotManagementGetResponseBotManagementSbfmLikelyConfigSbfmDefinitelyAutomated string - -const ( - BotManagementGetResponseBotManagementSbfmLikelyConfigSbfmDefinitelyAutomatedAllow BotManagementGetResponseBotManagementSbfmLikelyConfigSbfmDefinitelyAutomated = "allow" - BotManagementGetResponseBotManagementSbfmLikelyConfigSbfmDefinitelyAutomatedBlock BotManagementGetResponseBotManagementSbfmLikelyConfigSbfmDefinitelyAutomated = "block" - BotManagementGetResponseBotManagementSbfmLikelyConfigSbfmDefinitelyAutomatedManagedChallenge BotManagementGetResponseBotManagementSbfmLikelyConfigSbfmDefinitelyAutomated = "managed_challenge" -) - -func (r BotManagementGetResponseBotManagementSbfmLikelyConfigSbfmDefinitelyAutomated) IsKnown() bool { - switch r { - case BotManagementGetResponseBotManagementSbfmLikelyConfigSbfmDefinitelyAutomatedAllow, BotManagementGetResponseBotManagementSbfmLikelyConfigSbfmDefinitelyAutomatedBlock, BotManagementGetResponseBotManagementSbfmLikelyConfigSbfmDefinitelyAutomatedManagedChallenge: - return true - } - return false -} - -// Super Bot Fight Mode (SBFM) action to take on likely automated requests. -type BotManagementGetResponseBotManagementSbfmLikelyConfigSbfmLikelyAutomated string - -const ( - BotManagementGetResponseBotManagementSbfmLikelyConfigSbfmLikelyAutomatedAllow BotManagementGetResponseBotManagementSbfmLikelyConfigSbfmLikelyAutomated = "allow" - BotManagementGetResponseBotManagementSbfmLikelyConfigSbfmLikelyAutomatedBlock BotManagementGetResponseBotManagementSbfmLikelyConfigSbfmLikelyAutomated = "block" - BotManagementGetResponseBotManagementSbfmLikelyConfigSbfmLikelyAutomatedManagedChallenge BotManagementGetResponseBotManagementSbfmLikelyConfigSbfmLikelyAutomated = "managed_challenge" -) - -func (r BotManagementGetResponseBotManagementSbfmLikelyConfigSbfmLikelyAutomated) IsKnown() bool { - switch r { - case BotManagementGetResponseBotManagementSbfmLikelyConfigSbfmLikelyAutomatedAllow, BotManagementGetResponseBotManagementSbfmLikelyConfigSbfmLikelyAutomatedBlock, BotManagementGetResponseBotManagementSbfmLikelyConfigSbfmLikelyAutomatedManagedChallenge: - return true - } - return false -} - -// Super Bot Fight Mode (SBFM) action to take on verified bots requests. -type BotManagementGetResponseBotManagementSbfmLikelyConfigSbfmVerifiedBots string - -const ( - BotManagementGetResponseBotManagementSbfmLikelyConfigSbfmVerifiedBotsAllow BotManagementGetResponseBotManagementSbfmLikelyConfigSbfmVerifiedBots = "allow" - BotManagementGetResponseBotManagementSbfmLikelyConfigSbfmVerifiedBotsBlock BotManagementGetResponseBotManagementSbfmLikelyConfigSbfmVerifiedBots = "block" -) - -func (r BotManagementGetResponseBotManagementSbfmLikelyConfigSbfmVerifiedBots) IsKnown() bool { - switch r { - case BotManagementGetResponseBotManagementSbfmLikelyConfigSbfmVerifiedBotsAllow, BotManagementGetResponseBotManagementSbfmLikelyConfigSbfmVerifiedBotsBlock: - return true - } - return false -} - -type BotManagementGetResponseBotManagementBmSubscriptionConfig struct { - // Automatically update to the newest bot detection models created by Cloudflare as - // they are released. - // [Learn more.](https://developers.cloudflare.com/bots/reference/machine-learning-models#model-versions-and-release-notes) - AutoUpdateModel bool `json:"auto_update_model"` - // Use lightweight, invisible JavaScript detections to improve Bot Management. - // [Learn more about JavaScript Detections](https://developers.cloudflare.com/bots/reference/javascript-detections/). - EnableJs bool `json:"enable_js"` - // Whether to disable tracking the highest bot score for a session in the Bot - // Management cookie. - SuppressSessionScore bool `json:"suppress_session_score"` - // A read-only field that indicates whether the zone currently is running the - // latest ML model. - UsingLatestModel bool `json:"using_latest_model"` - JSON botManagementGetResponseBotManagementBmSubscriptionConfigJSON `json:"-"` -} - -// botManagementGetResponseBotManagementBmSubscriptionConfigJSON contains the JSON -// metadata for the struct -// [BotManagementGetResponseBotManagementBmSubscriptionConfig] -type botManagementGetResponseBotManagementBmSubscriptionConfigJSON struct { - AutoUpdateModel apijson.Field - EnableJs apijson.Field - SuppressSessionScore apijson.Field - UsingLatestModel apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *BotManagementGetResponseBotManagementBmSubscriptionConfig) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r botManagementGetResponseBotManagementBmSubscriptionConfigJSON) RawJSON() string { - return r.raw -} - -func (r BotManagementGetResponseBotManagementBmSubscriptionConfig) implementsBotManagementBotManagementGetResponse() { -} - // Super Bot Fight Mode (SBFM) action to take on definitely automated requests. type BotManagementGetResponseSbfmDefinitelyAutomated string @@ -863,17 +613,17 @@ func (r BotManagementGetResponseSbfmLikelyAutomated) IsKnown() bool { } // This interface is a union satisfied by one of the following: -// [BotManagementUpdateParamsBotManagementBotFightModeConfig], -// [BotManagementUpdateParamsBotManagementSbfmDefinitelyConfig], -// [BotManagementUpdateParamsBotManagementSbfmLikelyConfig], -// [BotManagementUpdateParamsBotManagementBmSubscriptionConfig]. +// [BotManagementUpdateParamsBotFightModeConfiguration], +// [BotManagementUpdateParamsSuperBotFightModeDefinitelyConfiguration], +// [BotManagementUpdateParamsSuperBotFightModeLikelyConfig], +// [BotManagementUpdateParamsSubscriptionConfiguration]. type BotManagementUpdateParams interface { ImplementsBotManagementUpdateParams() getZoneID() param.Field[string] } -type BotManagementUpdateParamsBotManagementBotFightModeConfig struct { +type BotManagementUpdateParamsBotFightModeConfiguration struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` // Use lightweight, invisible JavaScript detections to improve Bot Management. @@ -883,19 +633,19 @@ type BotManagementUpdateParamsBotManagementBotFightModeConfig struct { FightMode param.Field[bool] `json:"fight_mode"` } -func (r BotManagementUpdateParamsBotManagementBotFightModeConfig) MarshalJSON() (data []byte, err error) { +func (r BotManagementUpdateParamsBotFightModeConfiguration) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -func (r BotManagementUpdateParamsBotManagementBotFightModeConfig) getZoneID() param.Field[string] { +func (r BotManagementUpdateParamsBotFightModeConfiguration) getZoneID() param.Field[string] { return r.ZoneID } -func (BotManagementUpdateParamsBotManagementBotFightModeConfig) ImplementsBotManagementUpdateParams() { +func (BotManagementUpdateParamsBotFightModeConfiguration) ImplementsBotManagementUpdateParams() { } -type BotManagementUpdateParamsBotManagementSbfmDefinitelyConfig struct { +type BotManagementUpdateParamsSuperBotFightModeDefinitelyConfiguration struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` // Use lightweight, invisible JavaScript detections to improve Bot Management. @@ -904,61 +654,61 @@ type BotManagementUpdateParamsBotManagementSbfmDefinitelyConfig struct { // Whether to optimize Super Bot Fight Mode protections for Wordpress. OptimizeWordpress param.Field[bool] `json:"optimize_wordpress"` // Super Bot Fight Mode (SBFM) action to take on definitely automated requests. - SbfmDefinitelyAutomated param.Field[BotManagementUpdateParamsBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomated] `json:"sbfm_definitely_automated"` + SbfmDefinitelyAutomated param.Field[BotManagementUpdateParamsSuperBotFightModeDefinitelyConfigurationSbfmDefinitelyAutomated] `json:"sbfm_definitely_automated"` // Super Bot Fight Mode (SBFM) to enable static resource protection. Enable if // static resources on your application need bot protection. Note: Static resource // protection can also result in legitimate traffic being blocked. SbfmStaticResourceProtection param.Field[bool] `json:"sbfm_static_resource_protection"` // Super Bot Fight Mode (SBFM) action to take on verified bots requests. - SbfmVerifiedBots param.Field[BotManagementUpdateParamsBotManagementSbfmDefinitelyConfigSbfmVerifiedBots] `json:"sbfm_verified_bots"` + SbfmVerifiedBots param.Field[BotManagementUpdateParamsSuperBotFightModeDefinitelyConfigurationSbfmVerifiedBots] `json:"sbfm_verified_bots"` } -func (r BotManagementUpdateParamsBotManagementSbfmDefinitelyConfig) MarshalJSON() (data []byte, err error) { +func (r BotManagementUpdateParamsSuperBotFightModeDefinitelyConfiguration) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -func (r BotManagementUpdateParamsBotManagementSbfmDefinitelyConfig) getZoneID() param.Field[string] { +func (r BotManagementUpdateParamsSuperBotFightModeDefinitelyConfiguration) getZoneID() param.Field[string] { return r.ZoneID } -func (BotManagementUpdateParamsBotManagementSbfmDefinitelyConfig) ImplementsBotManagementUpdateParams() { +func (BotManagementUpdateParamsSuperBotFightModeDefinitelyConfiguration) ImplementsBotManagementUpdateParams() { } // Super Bot Fight Mode (SBFM) action to take on definitely automated requests. -type BotManagementUpdateParamsBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomated string +type BotManagementUpdateParamsSuperBotFightModeDefinitelyConfigurationSbfmDefinitelyAutomated string const ( - BotManagementUpdateParamsBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomatedAllow BotManagementUpdateParamsBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomated = "allow" - BotManagementUpdateParamsBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomatedBlock BotManagementUpdateParamsBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomated = "block" - BotManagementUpdateParamsBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomatedManagedChallenge BotManagementUpdateParamsBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomated = "managed_challenge" + BotManagementUpdateParamsSuperBotFightModeDefinitelyConfigurationSbfmDefinitelyAutomatedAllow BotManagementUpdateParamsSuperBotFightModeDefinitelyConfigurationSbfmDefinitelyAutomated = "allow" + BotManagementUpdateParamsSuperBotFightModeDefinitelyConfigurationSbfmDefinitelyAutomatedBlock BotManagementUpdateParamsSuperBotFightModeDefinitelyConfigurationSbfmDefinitelyAutomated = "block" + BotManagementUpdateParamsSuperBotFightModeDefinitelyConfigurationSbfmDefinitelyAutomatedManagedChallenge BotManagementUpdateParamsSuperBotFightModeDefinitelyConfigurationSbfmDefinitelyAutomated = "managed_challenge" ) -func (r BotManagementUpdateParamsBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomated) IsKnown() bool { +func (r BotManagementUpdateParamsSuperBotFightModeDefinitelyConfigurationSbfmDefinitelyAutomated) IsKnown() bool { switch r { - case BotManagementUpdateParamsBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomatedAllow, BotManagementUpdateParamsBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomatedBlock, BotManagementUpdateParamsBotManagementSbfmDefinitelyConfigSbfmDefinitelyAutomatedManagedChallenge: + case BotManagementUpdateParamsSuperBotFightModeDefinitelyConfigurationSbfmDefinitelyAutomatedAllow, BotManagementUpdateParamsSuperBotFightModeDefinitelyConfigurationSbfmDefinitelyAutomatedBlock, BotManagementUpdateParamsSuperBotFightModeDefinitelyConfigurationSbfmDefinitelyAutomatedManagedChallenge: return true } return false } // Super Bot Fight Mode (SBFM) action to take on verified bots requests. -type BotManagementUpdateParamsBotManagementSbfmDefinitelyConfigSbfmVerifiedBots string +type BotManagementUpdateParamsSuperBotFightModeDefinitelyConfigurationSbfmVerifiedBots string const ( - BotManagementUpdateParamsBotManagementSbfmDefinitelyConfigSbfmVerifiedBotsAllow BotManagementUpdateParamsBotManagementSbfmDefinitelyConfigSbfmVerifiedBots = "allow" - BotManagementUpdateParamsBotManagementSbfmDefinitelyConfigSbfmVerifiedBotsBlock BotManagementUpdateParamsBotManagementSbfmDefinitelyConfigSbfmVerifiedBots = "block" + BotManagementUpdateParamsSuperBotFightModeDefinitelyConfigurationSbfmVerifiedBotsAllow BotManagementUpdateParamsSuperBotFightModeDefinitelyConfigurationSbfmVerifiedBots = "allow" + BotManagementUpdateParamsSuperBotFightModeDefinitelyConfigurationSbfmVerifiedBotsBlock BotManagementUpdateParamsSuperBotFightModeDefinitelyConfigurationSbfmVerifiedBots = "block" ) -func (r BotManagementUpdateParamsBotManagementSbfmDefinitelyConfigSbfmVerifiedBots) IsKnown() bool { +func (r BotManagementUpdateParamsSuperBotFightModeDefinitelyConfigurationSbfmVerifiedBots) IsKnown() bool { switch r { - case BotManagementUpdateParamsBotManagementSbfmDefinitelyConfigSbfmVerifiedBotsAllow, BotManagementUpdateParamsBotManagementSbfmDefinitelyConfigSbfmVerifiedBotsBlock: + case BotManagementUpdateParamsSuperBotFightModeDefinitelyConfigurationSbfmVerifiedBotsAllow, BotManagementUpdateParamsSuperBotFightModeDefinitelyConfigurationSbfmVerifiedBotsBlock: return true } return false } -type BotManagementUpdateParamsBotManagementSbfmLikelyConfig struct { +type BotManagementUpdateParamsSuperBotFightModeLikelyConfig struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` // Use lightweight, invisible JavaScript detections to improve Bot Management. @@ -967,80 +717,80 @@ type BotManagementUpdateParamsBotManagementSbfmLikelyConfig struct { // Whether to optimize Super Bot Fight Mode protections for Wordpress. OptimizeWordpress param.Field[bool] `json:"optimize_wordpress"` // Super Bot Fight Mode (SBFM) action to take on definitely automated requests. - SbfmDefinitelyAutomated param.Field[BotManagementUpdateParamsBotManagementSbfmLikelyConfigSbfmDefinitelyAutomated] `json:"sbfm_definitely_automated"` + SbfmDefinitelyAutomated param.Field[BotManagementUpdateParamsSuperBotFightModeLikelyConfigSbfmDefinitelyAutomated] `json:"sbfm_definitely_automated"` // Super Bot Fight Mode (SBFM) action to take on likely automated requests. - SbfmLikelyAutomated param.Field[BotManagementUpdateParamsBotManagementSbfmLikelyConfigSbfmLikelyAutomated] `json:"sbfm_likely_automated"` + SbfmLikelyAutomated param.Field[BotManagementUpdateParamsSuperBotFightModeLikelyConfigSbfmLikelyAutomated] `json:"sbfm_likely_automated"` // Super Bot Fight Mode (SBFM) to enable static resource protection. Enable if // static resources on your application need bot protection. Note: Static resource // protection can also result in legitimate traffic being blocked. SbfmStaticResourceProtection param.Field[bool] `json:"sbfm_static_resource_protection"` // Super Bot Fight Mode (SBFM) action to take on verified bots requests. - SbfmVerifiedBots param.Field[BotManagementUpdateParamsBotManagementSbfmLikelyConfigSbfmVerifiedBots] `json:"sbfm_verified_bots"` + SbfmVerifiedBots param.Field[BotManagementUpdateParamsSuperBotFightModeLikelyConfigSbfmVerifiedBots] `json:"sbfm_verified_bots"` } -func (r BotManagementUpdateParamsBotManagementSbfmLikelyConfig) MarshalJSON() (data []byte, err error) { +func (r BotManagementUpdateParamsSuperBotFightModeLikelyConfig) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -func (r BotManagementUpdateParamsBotManagementSbfmLikelyConfig) getZoneID() param.Field[string] { +func (r BotManagementUpdateParamsSuperBotFightModeLikelyConfig) getZoneID() param.Field[string] { return r.ZoneID } -func (BotManagementUpdateParamsBotManagementSbfmLikelyConfig) ImplementsBotManagementUpdateParams() { +func (BotManagementUpdateParamsSuperBotFightModeLikelyConfig) ImplementsBotManagementUpdateParams() { } // Super Bot Fight Mode (SBFM) action to take on definitely automated requests. -type BotManagementUpdateParamsBotManagementSbfmLikelyConfigSbfmDefinitelyAutomated string +type BotManagementUpdateParamsSuperBotFightModeLikelyConfigSbfmDefinitelyAutomated string const ( - BotManagementUpdateParamsBotManagementSbfmLikelyConfigSbfmDefinitelyAutomatedAllow BotManagementUpdateParamsBotManagementSbfmLikelyConfigSbfmDefinitelyAutomated = "allow" - BotManagementUpdateParamsBotManagementSbfmLikelyConfigSbfmDefinitelyAutomatedBlock BotManagementUpdateParamsBotManagementSbfmLikelyConfigSbfmDefinitelyAutomated = "block" - BotManagementUpdateParamsBotManagementSbfmLikelyConfigSbfmDefinitelyAutomatedManagedChallenge BotManagementUpdateParamsBotManagementSbfmLikelyConfigSbfmDefinitelyAutomated = "managed_challenge" + BotManagementUpdateParamsSuperBotFightModeLikelyConfigSbfmDefinitelyAutomatedAllow BotManagementUpdateParamsSuperBotFightModeLikelyConfigSbfmDefinitelyAutomated = "allow" + BotManagementUpdateParamsSuperBotFightModeLikelyConfigSbfmDefinitelyAutomatedBlock BotManagementUpdateParamsSuperBotFightModeLikelyConfigSbfmDefinitelyAutomated = "block" + BotManagementUpdateParamsSuperBotFightModeLikelyConfigSbfmDefinitelyAutomatedManagedChallenge BotManagementUpdateParamsSuperBotFightModeLikelyConfigSbfmDefinitelyAutomated = "managed_challenge" ) -func (r BotManagementUpdateParamsBotManagementSbfmLikelyConfigSbfmDefinitelyAutomated) IsKnown() bool { +func (r BotManagementUpdateParamsSuperBotFightModeLikelyConfigSbfmDefinitelyAutomated) IsKnown() bool { switch r { - case BotManagementUpdateParamsBotManagementSbfmLikelyConfigSbfmDefinitelyAutomatedAllow, BotManagementUpdateParamsBotManagementSbfmLikelyConfigSbfmDefinitelyAutomatedBlock, BotManagementUpdateParamsBotManagementSbfmLikelyConfigSbfmDefinitelyAutomatedManagedChallenge: + case BotManagementUpdateParamsSuperBotFightModeLikelyConfigSbfmDefinitelyAutomatedAllow, BotManagementUpdateParamsSuperBotFightModeLikelyConfigSbfmDefinitelyAutomatedBlock, BotManagementUpdateParamsSuperBotFightModeLikelyConfigSbfmDefinitelyAutomatedManagedChallenge: return true } return false } // Super Bot Fight Mode (SBFM) action to take on likely automated requests. -type BotManagementUpdateParamsBotManagementSbfmLikelyConfigSbfmLikelyAutomated string +type BotManagementUpdateParamsSuperBotFightModeLikelyConfigSbfmLikelyAutomated string const ( - BotManagementUpdateParamsBotManagementSbfmLikelyConfigSbfmLikelyAutomatedAllow BotManagementUpdateParamsBotManagementSbfmLikelyConfigSbfmLikelyAutomated = "allow" - BotManagementUpdateParamsBotManagementSbfmLikelyConfigSbfmLikelyAutomatedBlock BotManagementUpdateParamsBotManagementSbfmLikelyConfigSbfmLikelyAutomated = "block" - BotManagementUpdateParamsBotManagementSbfmLikelyConfigSbfmLikelyAutomatedManagedChallenge BotManagementUpdateParamsBotManagementSbfmLikelyConfigSbfmLikelyAutomated = "managed_challenge" + BotManagementUpdateParamsSuperBotFightModeLikelyConfigSbfmLikelyAutomatedAllow BotManagementUpdateParamsSuperBotFightModeLikelyConfigSbfmLikelyAutomated = "allow" + BotManagementUpdateParamsSuperBotFightModeLikelyConfigSbfmLikelyAutomatedBlock BotManagementUpdateParamsSuperBotFightModeLikelyConfigSbfmLikelyAutomated = "block" + BotManagementUpdateParamsSuperBotFightModeLikelyConfigSbfmLikelyAutomatedManagedChallenge BotManagementUpdateParamsSuperBotFightModeLikelyConfigSbfmLikelyAutomated = "managed_challenge" ) -func (r BotManagementUpdateParamsBotManagementSbfmLikelyConfigSbfmLikelyAutomated) IsKnown() bool { +func (r BotManagementUpdateParamsSuperBotFightModeLikelyConfigSbfmLikelyAutomated) IsKnown() bool { switch r { - case BotManagementUpdateParamsBotManagementSbfmLikelyConfigSbfmLikelyAutomatedAllow, BotManagementUpdateParamsBotManagementSbfmLikelyConfigSbfmLikelyAutomatedBlock, BotManagementUpdateParamsBotManagementSbfmLikelyConfigSbfmLikelyAutomatedManagedChallenge: + case BotManagementUpdateParamsSuperBotFightModeLikelyConfigSbfmLikelyAutomatedAllow, BotManagementUpdateParamsSuperBotFightModeLikelyConfigSbfmLikelyAutomatedBlock, BotManagementUpdateParamsSuperBotFightModeLikelyConfigSbfmLikelyAutomatedManagedChallenge: return true } return false } // Super Bot Fight Mode (SBFM) action to take on verified bots requests. -type BotManagementUpdateParamsBotManagementSbfmLikelyConfigSbfmVerifiedBots string +type BotManagementUpdateParamsSuperBotFightModeLikelyConfigSbfmVerifiedBots string const ( - BotManagementUpdateParamsBotManagementSbfmLikelyConfigSbfmVerifiedBotsAllow BotManagementUpdateParamsBotManagementSbfmLikelyConfigSbfmVerifiedBots = "allow" - BotManagementUpdateParamsBotManagementSbfmLikelyConfigSbfmVerifiedBotsBlock BotManagementUpdateParamsBotManagementSbfmLikelyConfigSbfmVerifiedBots = "block" + BotManagementUpdateParamsSuperBotFightModeLikelyConfigSbfmVerifiedBotsAllow BotManagementUpdateParamsSuperBotFightModeLikelyConfigSbfmVerifiedBots = "allow" + BotManagementUpdateParamsSuperBotFightModeLikelyConfigSbfmVerifiedBotsBlock BotManagementUpdateParamsSuperBotFightModeLikelyConfigSbfmVerifiedBots = "block" ) -func (r BotManagementUpdateParamsBotManagementSbfmLikelyConfigSbfmVerifiedBots) IsKnown() bool { +func (r BotManagementUpdateParamsSuperBotFightModeLikelyConfigSbfmVerifiedBots) IsKnown() bool { switch r { - case BotManagementUpdateParamsBotManagementSbfmLikelyConfigSbfmVerifiedBotsAllow, BotManagementUpdateParamsBotManagementSbfmLikelyConfigSbfmVerifiedBotsBlock: + case BotManagementUpdateParamsSuperBotFightModeLikelyConfigSbfmVerifiedBotsAllow, BotManagementUpdateParamsSuperBotFightModeLikelyConfigSbfmVerifiedBotsBlock: return true } return false } -type BotManagementUpdateParamsBotManagementBmSubscriptionConfig struct { +type BotManagementUpdateParamsSubscriptionConfiguration struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` // Automatically update to the newest bot detection models created by Cloudflare as @@ -1055,15 +805,15 @@ type BotManagementUpdateParamsBotManagementBmSubscriptionConfig struct { SuppressSessionScore param.Field[bool] `json:"suppress_session_score"` } -func (r BotManagementUpdateParamsBotManagementBmSubscriptionConfig) MarshalJSON() (data []byte, err error) { +func (r BotManagementUpdateParamsSubscriptionConfiguration) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -func (r BotManagementUpdateParamsBotManagementBmSubscriptionConfig) getZoneID() param.Field[string] { +func (r BotManagementUpdateParamsSubscriptionConfiguration) getZoneID() param.Field[string] { return r.ZoneID } -func (BotManagementUpdateParamsBotManagementBmSubscriptionConfig) ImplementsBotManagementUpdateParams() { +func (BotManagementUpdateParamsSubscriptionConfiguration) ImplementsBotManagementUpdateParams() { } diff --git a/bot_management/botmanagement_test.go b/bot_management/botmanagement_test.go index 6037541dbc7..30ab7e51dbf 100644 --- a/bot_management/botmanagement_test.go +++ b/bot_management/botmanagement_test.go @@ -28,7 +28,7 @@ func TestBotManagementUpdateWithOptionalParams(t *testing.T) { option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), option.WithAPIEmail("user@example.com"), ) - _, err := client.BotManagement.Update(context.TODO(), bot_management.BotManagementUpdateParamsBotManagementBotFightModeConfig{ + _, err := client.BotManagement.Update(context.TODO(), bot_management.BotManagementUpdateParamsBotFightModeConfiguration{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), EnableJs: cloudflare.F(true), FightMode: cloudflare.F(true), diff --git a/certificate_authorities/hostnameassociation.go b/certificate_authorities/hostnameassociation.go index 41590b28641..901b3ba3e47 100644 --- a/certificate_authorities/hostnameassociation.go +++ b/certificate_authorities/hostnameassociation.go @@ -60,8 +60,12 @@ func (r *HostnameAssociationService) Get(ctx context.Context, params HostnameAss return } +type HostnameAssociationItem = string + +type HostnameAssociationItemParam = string + type HostnameAssociationUpdateResponse struct { - Hostnames []string `json:"hostnames"` + Hostnames []HostnameAssociationItem `json:"hostnames"` JSON hostnameAssociationUpdateResponseJSON `json:"-"` } @@ -82,7 +86,7 @@ func (r hostnameAssociationUpdateResponseJSON) RawJSON() string { } type HostnameAssociationGetResponse struct { - Hostnames []string `json:"hostnames"` + Hostnames []HostnameAssociationItem `json:"hostnames"` JSON hostnameAssociationGetResponseJSON `json:"-"` } @@ -104,8 +108,8 @@ func (r hostnameAssociationGetResponseJSON) RawJSON() string { type HostnameAssociationUpdateParams struct { // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - Hostnames param.Field[[]string] `json:"hostnames"` + ZoneID param.Field[string] `path:"zone_id,required"` + Hostnames param.Field[[]HostnameAssociationItemParam] `json:"hostnames"` // The UUID for a certificate that was uploaded to the mTLS Certificate Management // endpoint. If no mtls_certificate_id is given, the hostnames will be associated // to your active Cloudflare Managed CA. diff --git a/certificate_authorities/hostnameassociation_test.go b/certificate_authorities/hostnameassociation_test.go index a155eeb3020..315b67c32bd 100644 --- a/certificate_authorities/hostnameassociation_test.go +++ b/certificate_authorities/hostnameassociation_test.go @@ -30,7 +30,7 @@ func TestHostnameAssociationUpdateWithOptionalParams(t *testing.T) { ) _, err := client.CertificateAuthorities.HostnameAssociations.Update(context.TODO(), certificate_authorities.HostnameAssociationUpdateParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Hostnames: cloudflare.F([]string{"api.example.com", "api.example.com", "api.example.com"}), + Hostnames: cloudflare.F([]certificate_authorities.HostnameAssociationItemParam{"api.example.com", "api.example.com", "api.example.com"}), MTLSCertificateID: cloudflare.F("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"), }) if err != nil { diff --git a/challenges/widget.go b/challenges/widget.go index 60565573c58..48c76e1a375 100644 --- a/challenges/widget.go +++ b/challenges/widget.go @@ -337,10 +337,14 @@ func (r ChallengesWidgetListRegion) IsKnown() bool { return false } +type ChallengesWidgetListItem = string + +type ChallengesWidgetListItemParam = string + type WidgetNewParams struct { // Identifier - AccountID param.Field[string] `path:"account_id,required"` - Domains param.Field[[]string] `json:"domains,required"` + AccountID param.Field[string] `path:"account_id,required"` + Domains param.Field[[]ChallengesWidgetListItemParam] `json:"domains,required"` // Widget Mode Mode param.Field[WidgetNewParamsMode] `json:"mode,required"` // Human readable widget name. Not unique. Cloudflare suggests that you set this to @@ -529,8 +533,8 @@ func (r widgetNewResponseEnvelopeResultInfoJSON) RawJSON() string { type WidgetUpdateParams struct { // Identifier - AccountID param.Field[string] `path:"account_id,required"` - Domains param.Field[[]string] `json:"domains,required"` + AccountID param.Field[string] `path:"account_id,required"` + Domains param.Field[[]ChallengesWidgetListItemParam] `json:"domains,required"` // Widget Mode Mode param.Field[WidgetUpdateParamsMode] `json:"mode,required"` // Human readable widget name. Not unique. Cloudflare suggests that you set this to diff --git a/challenges/widget_test.go b/challenges/widget_test.go index 547baf57da9..ca0c4bbb624 100644 --- a/challenges/widget_test.go +++ b/challenges/widget_test.go @@ -30,7 +30,7 @@ func TestWidgetNewWithOptionalParams(t *testing.T) { ) _, err := client.Challenges.Widgets.New(context.TODO(), challenges.WidgetNewParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Domains: cloudflare.F([]string{"203.0.113.1", "cloudflare.com", "blog.example.com"}), + Domains: cloudflare.F([]challenges.ChallengesWidgetListItemParam{"203.0.113.1", "cloudflare.com", "blog.example.com"}), Mode: cloudflare.F(challenges.WidgetNewParamsModeInvisible), Name: cloudflare.F("blog.cloudflare.com login form"), Direction: cloudflare.F(challenges.WidgetNewParamsDirectionAsc), @@ -70,7 +70,7 @@ func TestWidgetUpdateWithOptionalParams(t *testing.T) { "0x4AAF00AAAABn0R22HWm-YUc", challenges.WidgetUpdateParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - Domains: cloudflare.F([]string{"203.0.113.1", "cloudflare.com", "blog.example.com"}), + Domains: cloudflare.F([]challenges.ChallengesWidgetListItemParam{"203.0.113.1", "cloudflare.com", "blog.example.com"}), Mode: cloudflare.F(challenges.WidgetUpdateParamsModeInvisible), Name: cloudflare.F("blog.cloudflare.com login form"), BotFightMode: cloudflare.F(false), diff --git a/custom_certificates/customcertificate.go b/custom_certificates/customcertificate.go index 62c75f3c1af..dee226aaf46 100644 --- a/custom_certificates/customcertificate.go +++ b/custom_certificates/customcertificate.go @@ -156,7 +156,7 @@ type CustomCertificate struct { // only to U.S. data centers, only to E.U. data centers, or only to highest // security data centers. Default distribution is to all Cloudflare datacenters, // for optimal performance. - GeoRestrictions CustomCertificateGeoRestrictions `json:"geo_restrictions"` + GeoRestrictions GeoRestrictions `json:"geo_restrictions"` KeylessServer keyless_certificates.KeylessCertificateHostname `json:"keyless_server"` // Specify the policy that determines the region where your private key will be // held locally. HTTPS connections to any excluded data center will still be fully @@ -226,43 +226,57 @@ func (r CustomCertificateStatus) IsKnown() bool { // only to U.S. data centers, only to E.U. data centers, or only to highest // security data centers. Default distribution is to all Cloudflare datacenters, // for optimal performance. -type CustomCertificateGeoRestrictions struct { - Label CustomCertificateGeoRestrictionsLabel `json:"label"` - JSON customCertificateGeoRestrictionsJSON `json:"-"` +type GeoRestrictions struct { + Label GeoRestrictionsLabel `json:"label"` + JSON geoRestrictionsJSON `json:"-"` } -// customCertificateGeoRestrictionsJSON contains the JSON metadata for the struct -// [CustomCertificateGeoRestrictions] -type customCertificateGeoRestrictionsJSON struct { +// geoRestrictionsJSON contains the JSON metadata for the struct [GeoRestrictions] +type geoRestrictionsJSON struct { Label apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *CustomCertificateGeoRestrictions) UnmarshalJSON(data []byte) (err error) { +func (r *GeoRestrictions) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r customCertificateGeoRestrictionsJSON) RawJSON() string { +func (r geoRestrictionsJSON) RawJSON() string { return r.raw } -type CustomCertificateGeoRestrictionsLabel string +type GeoRestrictionsLabel string const ( - CustomCertificateGeoRestrictionsLabelUs CustomCertificateGeoRestrictionsLabel = "us" - CustomCertificateGeoRestrictionsLabelEu CustomCertificateGeoRestrictionsLabel = "eu" - CustomCertificateGeoRestrictionsLabelHighestSecurity CustomCertificateGeoRestrictionsLabel = "highest_security" + GeoRestrictionsLabelUs GeoRestrictionsLabel = "us" + GeoRestrictionsLabelEu GeoRestrictionsLabel = "eu" + GeoRestrictionsLabelHighestSecurity GeoRestrictionsLabel = "highest_security" ) -func (r CustomCertificateGeoRestrictionsLabel) IsKnown() bool { +func (r GeoRestrictionsLabel) IsKnown() bool { switch r { - case CustomCertificateGeoRestrictionsLabelUs, CustomCertificateGeoRestrictionsLabelEu, CustomCertificateGeoRestrictionsLabelHighestSecurity: + case GeoRestrictionsLabelUs, GeoRestrictionsLabelEu, GeoRestrictionsLabelHighestSecurity: return true } return false } +// Specify the region where your private key can be held locally for optimal TLS +// performance. HTTPS connections to any excluded data center will still be fully +// encrypted, but will incur some latency while Keyless SSL is used to complete the +// handshake with the nearest allowed data center. Options allow distribution to +// only to U.S. data centers, only to E.U. data centers, or only to highest +// security data centers. Default distribution is to all Cloudflare datacenters, +// for optimal performance. +type GeoRestrictionsParam struct { + Label param.Field[GeoRestrictionsLabel] `json:"label"` +} + +func (r GeoRestrictionsParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + type CustomCertificateNewParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` @@ -282,7 +296,7 @@ type CustomCertificateNewParams struct { // only to U.S. data centers, only to E.U. data centers, or only to highest // security data centers. Default distribution is to all Cloudflare datacenters, // for optimal performance. - GeoRestrictions param.Field[CustomCertificateNewParamsGeoRestrictions] `json:"geo_restrictions"` + GeoRestrictions param.Field[GeoRestrictionsParam] `json:"geo_restrictions"` // Specify the policy that determines the region where your private key will be // held locally. HTTPS connections to any excluded data center will still be fully // encrypted, but will incur some latency while Keyless SSL is used to complete the @@ -302,37 +316,6 @@ func (r CustomCertificateNewParams) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -// Specify the region where your private key can be held locally for optimal TLS -// performance. HTTPS connections to any excluded data center will still be fully -// encrypted, but will incur some latency while Keyless SSL is used to complete the -// handshake with the nearest allowed data center. Options allow distribution to -// only to U.S. data centers, only to E.U. data centers, or only to highest -// security data centers. Default distribution is to all Cloudflare datacenters, -// for optimal performance. -type CustomCertificateNewParamsGeoRestrictions struct { - Label param.Field[CustomCertificateNewParamsGeoRestrictionsLabel] `json:"label"` -} - -func (r CustomCertificateNewParamsGeoRestrictions) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type CustomCertificateNewParamsGeoRestrictionsLabel string - -const ( - CustomCertificateNewParamsGeoRestrictionsLabelUs CustomCertificateNewParamsGeoRestrictionsLabel = "us" - CustomCertificateNewParamsGeoRestrictionsLabelEu CustomCertificateNewParamsGeoRestrictionsLabel = "eu" - CustomCertificateNewParamsGeoRestrictionsLabelHighestSecurity CustomCertificateNewParamsGeoRestrictionsLabel = "highest_security" -) - -func (r CustomCertificateNewParamsGeoRestrictionsLabel) IsKnown() bool { - switch r { - case CustomCertificateNewParamsGeoRestrictionsLabelUs, CustomCertificateNewParamsGeoRestrictionsLabelEu, CustomCertificateNewParamsGeoRestrictionsLabelHighestSecurity: - return true - } - return false -} - // The type 'legacy_custom' enables support for legacy clients which do not include // SNI in the TLS handshake. type CustomCertificateNewParamsType string @@ -520,7 +503,7 @@ type CustomCertificateEditParams struct { // only to U.S. data centers, only to E.U. data centers, or only to highest // security data centers. Default distribution is to all Cloudflare datacenters, // for optimal performance. - GeoRestrictions param.Field[CustomCertificateEditParamsGeoRestrictions] `json:"geo_restrictions"` + GeoRestrictions param.Field[GeoRestrictionsParam] `json:"geo_restrictions"` // Specify the policy that determines the region where your private key will be // held locally. HTTPS connections to any excluded data center will still be fully // encrypted, but will incur some latency while Keyless SSL is used to complete the @@ -539,37 +522,6 @@ func (r CustomCertificateEditParams) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -// Specify the region where your private key can be held locally for optimal TLS -// performance. HTTPS connections to any excluded data center will still be fully -// encrypted, but will incur some latency while Keyless SSL is used to complete the -// handshake with the nearest allowed data center. Options allow distribution to -// only to U.S. data centers, only to E.U. data centers, or only to highest -// security data centers. Default distribution is to all Cloudflare datacenters, -// for optimal performance. -type CustomCertificateEditParamsGeoRestrictions struct { - Label param.Field[CustomCertificateEditParamsGeoRestrictionsLabel] `json:"label"` -} - -func (r CustomCertificateEditParamsGeoRestrictions) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type CustomCertificateEditParamsGeoRestrictionsLabel string - -const ( - CustomCertificateEditParamsGeoRestrictionsLabelUs CustomCertificateEditParamsGeoRestrictionsLabel = "us" - CustomCertificateEditParamsGeoRestrictionsLabelEu CustomCertificateEditParamsGeoRestrictionsLabel = "eu" - CustomCertificateEditParamsGeoRestrictionsLabelHighestSecurity CustomCertificateEditParamsGeoRestrictionsLabel = "highest_security" -) - -func (r CustomCertificateEditParamsGeoRestrictionsLabel) IsKnown() bool { - switch r { - case CustomCertificateEditParamsGeoRestrictionsLabelUs, CustomCertificateEditParamsGeoRestrictionsLabelEu, CustomCertificateEditParamsGeoRestrictionsLabelHighestSecurity: - return true - } - return false -} - type CustomCertificateEditResponseEnvelope struct { Errors []shared.UnnamedSchemaRef3248f24329456e19dfa042fff9986f72 `json:"errors,required"` Messages []shared.UnnamedSchemaRef3248f24329456e19dfa042fff9986f72 `json:"messages,required"` diff --git a/custom_certificates/customcertificate_test.go b/custom_certificates/customcertificate_test.go index bba589f3bd9..9f3790e4673 100644 --- a/custom_certificates/customcertificate_test.go +++ b/custom_certificates/customcertificate_test.go @@ -34,8 +34,8 @@ func TestCustomCertificateNewWithOptionalParams(t *testing.T) { Certificate: cloudflare.F("-----BEGIN CERTIFICATE-----\nMIIDtTCCAp2gAwIBAgIJAMHAwfXZ5/PWMA0GCSqGSIb3DQEBCwUAMEUxCzAJBgNV\nBAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBX\naWRnaXRzIFB0eSBMdGQwHhcNMTYwODI0MTY0MzAxWhcNMTYxMTIyMTY0MzAxWjBF\nMQswCQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50\nZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB\nCgKCAQEAwQHoetcl9+5ikGzV6cMzWtWPJHqXT3wpbEkRU9Yz7lgvddmGdtcGbg/1\nCGZu0jJGkMoppoUo4c3dts3iwqRYmBikUP77wwY2QGmDZw2FvkJCJlKnabIRuGvB\nKwzESIXgKk2016aTP6/dAjEHyo6SeoK8lkIySUvK0fyOVlsiEsCmOpidtnKX/a+5\n0GjB79CJH4ER2lLVZnhePFR/zUOyPxZQQ4naHf7yu/b5jhO0f8fwt+pyFxIXjbEI\ndZliWRkRMtzrHOJIhrmJ2A1J7iOrirbbwillwjjNVUWPf3IJ3M12S9pEewooaeO2\nizNTERcG9HzAacbVRn2Y2SWIyT/18QIDAQABo4GnMIGkMB0GA1UdDgQWBBT/LbE4\n9rWf288N6sJA5BRb6FJIGDB1BgNVHSMEbjBsgBT/LbE49rWf288N6sJA5BRb6FJI\nGKFJpEcwRTELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNV\nBAoTGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZIIJAMHAwfXZ5/PWMAwGA1UdEwQF\nMAMBAf8wDQYJKoZIhvcNAQELBQADggEBAHHFwl0tH0quUYZYO0dZYt4R7SJ0pCm2\n2satiyzHl4OnXcHDpekAo7/a09c6Lz6AU83cKy/+x3/djYHXWba7HpEu0dR3ugQP\nMlr4zrhd9xKZ0KZKiYmtJH+ak4OM4L3FbT0owUZPyjLSlhMtJVcoRp5CJsjAMBUG\nSvD8RX+T01wzox/Qb+lnnNnOlaWpqu8eoOenybxKp1a9ULzIVvN/LAcc+14vioFq\n2swRWtmocBAs8QR9n4uvbpiYvS8eYueDCWMM4fvFfBhaDZ3N9IbtySh3SpFdQDhw\nYbjM2rxXiyLGxB4Bol7QTv4zHif7Zt89FReT/NBy4rzaskDJY5L6xmY=\n-----END CERTIFICATE-----\n"), PrivateKey: cloudflare.F("-----BEGIN RSA PRIVATE KEY-----\nMIIEowIBAAKCAQEAwQHoetcl9+5ikGzV6cMzWtWPJHqXT3wpbEkRU9Yz7lgvddmG\ndtcGbg/1CGZu0jJGkMoppoUo4c3dts3iwqRYmBikUP77wwY2QGmDZw2FvkJCJlKn\nabIRuGvBKwzESIXgKk2016aTP6/dAjEHyo6SeoK8lkIySUvK0fyOVlsiEsCmOpid\ntnKX/a+50GjB79CJH4ER2lLVZnhePFR/zUOyPxZQQ4naHf7yu/b5jhO0f8fwt+py\nFxIXjbEIdZliWRkRMtzrHOJIhrmJ2A1J7iOrirbbwillwjjNVUWPf3IJ3M12S9pE\newooaeO2izNTERcG9HzAacbVRn2Y2SWIyT/18QIDAQABAoIBACbhTYXBZYKmYPCb\nHBR1IBlCQA2nLGf0qRuJNJZg5iEzXows/6tc8YymZkQE7nolapWsQ+upk2y5Xdp/\naxiuprIs9JzkYK8Ox0r+dlwCG1kSW+UAbX0bQ/qUqlsTvU6muVuMP8vZYHxJ3wmb\n+ufRBKztPTQ/rYWaYQcgC0RWI20HTFBMxlTAyNxYNWzX7RKFkGVVyB9RsAtmcc8g\n+j4OdosbfNoJPS0HeIfNpAznDfHKdxDk2Yc1tV6RHBrC1ynyLE9+TaflIAdo2MVv\nKLMLq51GqYKtgJFIlBRPQqKoyXdz3fGvXrTkf/WY9QNq0J1Vk5ERePZ54mN8iZB7\n9lwy/AkCgYEA6FXzosxswaJ2wQLeoYc7ceaweX/SwTvxHgXzRyJIIT0eJWgx13Wo\n/WA3Iziimsjf6qE+SI/8laxPp2A86VMaIt3Z3mJN/CqSVGw8LK2AQst+OwdPyDMu\niacE8lj/IFGC8mwNUAb9CzGU3JpU4PxxGFjS/eMtGeRXCWkK4NE+G08CgYEA1Kp9\nN2JrVlqUz+gAX+LPmE9OEMAS9WQSQsfCHGogIFDGGcNf7+uwBM7GAaSJIP01zcoe\nVAgWdzXCv3FLhsaZoJ6RyLOLay5phbu1iaTr4UNYm5WtYTzMzqh8l1+MFFDl9xDB\nvULuCIIrglM5MeS/qnSg1uMoH2oVPj9TVst/ir8CgYEAxrI7Ws9Zc4Bt70N1As+U\nlySjaEVZCMkqvHJ6TCuVZFfQoE0r0whdLdRLU2PsLFP+q7qaeZQqgBaNSKeVcDYR\n9B+nY/jOmQoPewPVsp/vQTCnE/R81spu0mp0YI6cIheT1Z9zAy322svcc43JaWB7\nmEbeqyLOP4Z4qSOcmghZBSECgYACvR9Xs0DGn+wCsW4vze/2ei77MD4OQvepPIFX\ndFZtlBy5ADcgE9z0cuVB6CiL8DbdK5kwY9pGNr8HUCI03iHkW6Zs+0L0YmihfEVe\nPG19PSzK9CaDdhD9KFZSbLyVFmWfxOt50H7YRTTiPMgjyFpfi5j2q348yVT0tEQS\nfhRqaQKBgAcWPokmJ7EbYQGeMbS7HC8eWO/RyamlnSffdCdSc7ue3zdVJxpAkQ8W\nqu80pEIF6raIQfAf8MXiiZ7auFOSnHQTXUbhCpvDLKi0Mwq3G8Pl07l+2s6dQG6T\nlv6XTQaMyf6n1yjzL+fzDrH3qXMxHMO/b13EePXpDMpY7HQpoLDi\n-----END RSA PRIVATE KEY-----\n"), BundleMethod: cloudflare.F(custom_hostnames.UnnamedSchemaRef16aca57bde2963201c7e6e895436c1c1Ubiquitous), - GeoRestrictions: cloudflare.F(custom_certificates.CustomCertificateNewParamsGeoRestrictions{ - Label: cloudflare.F(custom_certificates.CustomCertificateNewParamsGeoRestrictionsLabelUs), + GeoRestrictions: cloudflare.F(custom_certificates.GeoRestrictionsParam{ + Label: cloudflare.F(custom_certificates.GeoRestrictionsLabelUs), }), Policy: cloudflare.F("(country: US) or (region: EU)"), Type: cloudflare.F(custom_certificates.CustomCertificateNewParamsTypeSniCustom), @@ -131,8 +131,8 @@ func TestCustomCertificateEditWithOptionalParams(t *testing.T) { ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), BundleMethod: cloudflare.F(custom_hostnames.UnnamedSchemaRef16aca57bde2963201c7e6e895436c1c1Ubiquitous), Certificate: cloudflare.F("-----BEGIN CERTIFICATE-----\nMIIDtTCCAp2gAwIBAgIJAMHAwfXZ5/PWMA0GCSqGSIb3DQEBCwUAMEUxCzAJBgNV\nBAYTAkFVMRMwEQYDVQQIEwpTb21lLVN0YXRlMSEwHwYDVQQKExhJbnRlcm5ldCBX\naWRnaXRzIFB0eSBMdGQwHhcNMTYwODI0MTY0MzAxWhcNMTYxMTIyMTY0MzAxWjBF\nMQswCQYDVQQGEwJBVTETMBEGA1UECBMKU29tZS1TdGF0ZTEhMB8GA1UEChMYSW50\nZXJuZXQgV2lkZ2l0cyBQdHkgTHRkMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIB\nCgKCAQEAwQHoetcl9+5ikGzV6cMzWtWPJHqXT3wpbEkRU9Yz7lgvddmGdtcGbg/1\nCGZu0jJGkMoppoUo4c3dts3iwqRYmBikUP77wwY2QGmDZw2FvkJCJlKnabIRuGvB\nKwzESIXgKk2016aTP6/dAjEHyo6SeoK8lkIySUvK0fyOVlsiEsCmOpidtnKX/a+5\n0GjB79CJH4ER2lLVZnhePFR/zUOyPxZQQ4naHf7yu/b5jhO0f8fwt+pyFxIXjbEI\ndZliWRkRMtzrHOJIhrmJ2A1J7iOrirbbwillwjjNVUWPf3IJ3M12S9pEewooaeO2\nizNTERcG9HzAacbVRn2Y2SWIyT/18QIDAQABo4GnMIGkMB0GA1UdDgQWBBT/LbE4\n9rWf288N6sJA5BRb6FJIGDB1BgNVHSMEbjBsgBT/LbE49rWf288N6sJA5BRb6FJI\nGKFJpEcwRTELMAkGA1UEBhMCQVUxEzARBgNVBAgTClNvbWUtU3RhdGUxITAfBgNV\nBAoTGEludGVybmV0IFdpZGdpdHMgUHR5IEx0ZIIJAMHAwfXZ5/PWMAwGA1UdEwQF\nMAMBAf8wDQYJKoZIhvcNAQELBQADggEBAHHFwl0tH0quUYZYO0dZYt4R7SJ0pCm2\n2satiyzHl4OnXcHDpekAo7/a09c6Lz6AU83cKy/+x3/djYHXWba7HpEu0dR3ugQP\nMlr4zrhd9xKZ0KZKiYmtJH+ak4OM4L3FbT0owUZPyjLSlhMtJVcoRp5CJsjAMBUG\nSvD8RX+T01wzox/Qb+lnnNnOlaWpqu8eoOenybxKp1a9ULzIVvN/LAcc+14vioFq\n2swRWtmocBAs8QR9n4uvbpiYvS8eYueDCWMM4fvFfBhaDZ3N9IbtySh3SpFdQDhw\nYbjM2rxXiyLGxB4Bol7QTv4zHif7Zt89FReT/NBy4rzaskDJY5L6xmY=\n-----END CERTIFICATE-----\n"), - GeoRestrictions: cloudflare.F(custom_certificates.CustomCertificateEditParamsGeoRestrictions{ - Label: cloudflare.F(custom_certificates.CustomCertificateEditParamsGeoRestrictionsLabelUs), + GeoRestrictions: cloudflare.F(custom_certificates.GeoRestrictionsParam{ + Label: cloudflare.F(custom_certificates.GeoRestrictionsLabelUs), }), Policy: cloudflare.F("(country: US) or (region: EU)"), PrivateKey: cloudflare.F("-----BEGIN RSA PRIVATE KEY-----\nMIIEowIBAAKCAQEAwQHoetcl9+5ikGzV6cMzWtWPJHqXT3wpbEkRU9Yz7lgvddmG\ndtcGbg/1CGZu0jJGkMoppoUo4c3dts3iwqRYmBikUP77wwY2QGmDZw2FvkJCJlKn\nabIRuGvBKwzESIXgKk2016aTP6/dAjEHyo6SeoK8lkIySUvK0fyOVlsiEsCmOpid\ntnKX/a+50GjB79CJH4ER2lLVZnhePFR/zUOyPxZQQ4naHf7yu/b5jhO0f8fwt+py\nFxIXjbEIdZliWRkRMtzrHOJIhrmJ2A1J7iOrirbbwillwjjNVUWPf3IJ3M12S9pE\newooaeO2izNTERcG9HzAacbVRn2Y2SWIyT/18QIDAQABAoIBACbhTYXBZYKmYPCb\nHBR1IBlCQA2nLGf0qRuJNJZg5iEzXows/6tc8YymZkQE7nolapWsQ+upk2y5Xdp/\naxiuprIs9JzkYK8Ox0r+dlwCG1kSW+UAbX0bQ/qUqlsTvU6muVuMP8vZYHxJ3wmb\n+ufRBKztPTQ/rYWaYQcgC0RWI20HTFBMxlTAyNxYNWzX7RKFkGVVyB9RsAtmcc8g\n+j4OdosbfNoJPS0HeIfNpAznDfHKdxDk2Yc1tV6RHBrC1ynyLE9+TaflIAdo2MVv\nKLMLq51GqYKtgJFIlBRPQqKoyXdz3fGvXrTkf/WY9QNq0J1Vk5ERePZ54mN8iZB7\n9lwy/AkCgYEA6FXzosxswaJ2wQLeoYc7ceaweX/SwTvxHgXzRyJIIT0eJWgx13Wo\n/WA3Iziimsjf6qE+SI/8laxPp2A86VMaIt3Z3mJN/CqSVGw8LK2AQst+OwdPyDMu\niacE8lj/IFGC8mwNUAb9CzGU3JpU4PxxGFjS/eMtGeRXCWkK4NE+G08CgYEA1Kp9\nN2JrVlqUz+gAX+LPmE9OEMAS9WQSQsfCHGogIFDGGcNf7+uwBM7GAaSJIP01zcoe\nVAgWdzXCv3FLhsaZoJ6RyLOLay5phbu1iaTr4UNYm5WtYTzMzqh8l1+MFFDl9xDB\nvULuCIIrglM5MeS/qnSg1uMoH2oVPj9TVst/ir8CgYEAxrI7Ws9Zc4Bt70N1As+U\nlySjaEVZCMkqvHJ6TCuVZFfQoE0r0whdLdRLU2PsLFP+q7qaeZQqgBaNSKeVcDYR\n9B+nY/jOmQoPewPVsp/vQTCnE/R81spu0mp0YI6cIheT1Z9zAy322svcc43JaWB7\nmEbeqyLOP4Z4qSOcmghZBSECgYACvR9Xs0DGn+wCsW4vze/2ei77MD4OQvepPIFX\ndFZtlBy5ADcgE9z0cuVB6CiL8DbdK5kwY9pGNr8HUCI03iHkW6Zs+0L0YmihfEVe\nPG19PSzK9CaDdhD9KFZSbLyVFmWfxOt50H7YRTTiPMgjyFpfi5j2q348yVT0tEQS\nfhRqaQKBgAcWPokmJ7EbYQGeMbS7HC8eWO/RyamlnSffdCdSc7ue3zdVJxpAkQ8W\nqu80pEIF6raIQfAf8MXiiZ7auFOSnHQTXUbhCpvDLKi0Mwq3G8Pl07l+2s6dQG6T\nlv6XTQaMyf6n1yjzL+fzDrH3qXMxHMO/b13EePXpDMpY7HQpoLDi\n-----END RSA PRIVATE KEY-----\n"), diff --git a/custom_hostnames/customhostname.go b/custom_hostnames/customhostname.go index 92bc3d4a58a..a8fe383f22e 100644 --- a/custom_hostnames/customhostname.go +++ b/custom_hostnames/customhostname.go @@ -117,89 +117,8 @@ func (r *CustomHostnameService) Get(ctx context.Context, customHostnameID string return } -// A ubiquitous bundle has the highest probability of being verified everywhere, -// even by clients using outdated or unusual trust stores. An optimal bundle uses -// the shortest chain and newest intermediates. And the force bundle verifies the -// chain, but does not otherwise modify it. -type UnnamedSchemaRef16aca57bde2963201c7e6e895436c1c1 string - -const ( - UnnamedSchemaRef16aca57bde2963201c7e6e895436c1c1Ubiquitous UnnamedSchemaRef16aca57bde2963201c7e6e895436c1c1 = "ubiquitous" - UnnamedSchemaRef16aca57bde2963201c7e6e895436c1c1Optimal UnnamedSchemaRef16aca57bde2963201c7e6e895436c1c1 = "optimal" - UnnamedSchemaRef16aca57bde2963201c7e6e895436c1c1Force UnnamedSchemaRef16aca57bde2963201c7e6e895436c1c1 = "force" -) - -func (r UnnamedSchemaRef16aca57bde2963201c7e6e895436c1c1) IsKnown() bool { - switch r { - case UnnamedSchemaRef16aca57bde2963201c7e6e895436c1c1Ubiquitous, UnnamedSchemaRef16aca57bde2963201c7e6e895436c1c1Optimal, UnnamedSchemaRef16aca57bde2963201c7e6e895436c1c1Force: - return true - } - return false -} - -// Domain control validation (DCV) method used for this hostname. -type UnnamedSchemaRef78adb375f06c6d462dd92b99e2ecf510 string - -const ( - UnnamedSchemaRef78adb375f06c6d462dd92b99e2ecf510HTTP UnnamedSchemaRef78adb375f06c6d462dd92b99e2ecf510 = "http" - UnnamedSchemaRef78adb375f06c6d462dd92b99e2ecf510TXT UnnamedSchemaRef78adb375f06c6d462dd92b99e2ecf510 = "txt" - UnnamedSchemaRef78adb375f06c6d462dd92b99e2ecf510Email UnnamedSchemaRef78adb375f06c6d462dd92b99e2ecf510 = "email" -) - -func (r UnnamedSchemaRef78adb375f06c6d462dd92b99e2ecf510) IsKnown() bool { - switch r { - case UnnamedSchemaRef78adb375f06c6d462dd92b99e2ecf510HTTP, UnnamedSchemaRef78adb375f06c6d462dd92b99e2ecf510TXT, UnnamedSchemaRef78adb375f06c6d462dd92b99e2ecf510Email: - return true - } - return false -} - -// Level of validation to be used for this hostname. Domain validation (dv) must be -// used. -type UnnamedSchemaRef9a9935a9a770967bb604ae41a81e42e1 string - -const ( - UnnamedSchemaRef9a9935a9a770967bb604ae41a81e42e1Dv UnnamedSchemaRef9a9935a9a770967bb604ae41a81e42e1 = "dv" -) - -func (r UnnamedSchemaRef9a9935a9a770967bb604ae41a81e42e1) IsKnown() bool { - switch r { - case UnnamedSchemaRef9a9935a9a770967bb604ae41a81e42e1Dv: - return true - } - return false -} - -type CustomHostnameNewResponse struct { - // Identifier - ID string `json:"id,required"` - // The custom hostname that will point to your hostname via CNAME. - Hostname string `json:"hostname,required"` - // SSL properties for the custom hostname. - SSL CustomHostnameNewResponseSSL `json:"ssl,required"` - JSON customHostnameNewResponseJSON `json:"-"` -} - -// customHostnameNewResponseJSON contains the JSON metadata for the struct -// [CustomHostnameNewResponse] -type customHostnameNewResponseJSON struct { - ID apijson.Field - Hostname apijson.Field - SSL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomHostnameNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customHostnameNewResponseJSON) RawJSON() string { - return r.raw -} - // SSL properties for the custom hostname. -type CustomHostnameNewResponseSSL struct { +type SSL struct { // Custom hostname SSL identifier tag. ID string `json:"id"` // A ubiquitous bundle has the highest probability of being verified everywhere, @@ -208,7 +127,7 @@ type CustomHostnameNewResponseSSL struct { // chain, but does not otherwise modify it. BundleMethod UnnamedSchemaRef16aca57bde2963201c7e6e895436c1c1 `json:"bundle_method"` // The Certificate Authority that will issue the certificate - CertificateAuthority CustomHostnameNewResponseSSLCertificateAuthority `json:"certificate_authority"` + CertificateAuthority SSLCertificateAuthority `json:"certificate_authority"` // If a custom uploaded certificate is used. CustomCertificate string `json:"custom_certificate"` // The identifier for the Custom CSR that was used. @@ -226,11 +145,11 @@ type CustomHostnameNewResponseSSL struct { // The serial number on a custom uploaded certificate. SerialNumber string `json:"serial_number"` // SSL specific settings. - Settings CustomHostnameNewResponseSSLSettings `json:"settings"` + Settings SSLSettings `json:"settings"` // The signature on a custom uploaded certificate. Signature string `json:"signature"` // Status of the hostname's SSL certificates. - Status CustomHostnameNewResponseSSLStatus `json:"status"` + Status SSLStatus `json:"status"` // Level of validation to be used for this hostname. Domain validation (dv) must be // used. Type UnnamedSchemaRef9a9935a9a770967bb604ae41a81e42e1 `json:"type"` @@ -238,16 +157,15 @@ type CustomHostnameNewResponseSSL struct { UploadedOn time.Time `json:"uploaded_on" format:"date-time"` // Domain validation errors that have been received by the certificate authority // (CA). - ValidationErrors []CustomHostnameNewResponseSSLValidationError `json:"validation_errors"` - ValidationRecords []CustomHostnameNewResponseSSLValidationRecord `json:"validation_records"` + ValidationErrors []SSLValidationError `json:"validation_errors"` + ValidationRecords []SSLValidationRecord `json:"validation_records"` // Indicates whether the certificate covers a wildcard. - Wildcard bool `json:"wildcard"` - JSON customHostnameNewResponseSSLJSON `json:"-"` + Wildcard bool `json:"wildcard"` + JSON sslJSON `json:"-"` } -// customHostnameNewResponseSSLJSON contains the JSON metadata for the struct -// [CustomHostnameNewResponseSSL] -type customHostnameNewResponseSSLJSON struct { +// sslJSON contains the JSON metadata for the struct [SSL] +type sslJSON struct { ID apijson.Field BundleMethod apijson.Field CertificateAuthority apijson.Field @@ -271,50 +189,49 @@ type customHostnameNewResponseSSLJSON struct { ExtraFields map[string]apijson.Field } -func (r *CustomHostnameNewResponseSSL) UnmarshalJSON(data []byte) (err error) { +func (r *SSL) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r customHostnameNewResponseSSLJSON) RawJSON() string { +func (r sslJSON) RawJSON() string { return r.raw } // The Certificate Authority that will issue the certificate -type CustomHostnameNewResponseSSLCertificateAuthority string +type SSLCertificateAuthority string const ( - CustomHostnameNewResponseSSLCertificateAuthorityDigicert CustomHostnameNewResponseSSLCertificateAuthority = "digicert" - CustomHostnameNewResponseSSLCertificateAuthorityGoogle CustomHostnameNewResponseSSLCertificateAuthority = "google" - CustomHostnameNewResponseSSLCertificateAuthorityLetsEncrypt CustomHostnameNewResponseSSLCertificateAuthority = "lets_encrypt" + SSLCertificateAuthorityDigicert SSLCertificateAuthority = "digicert" + SSLCertificateAuthorityGoogle SSLCertificateAuthority = "google" + SSLCertificateAuthorityLetsEncrypt SSLCertificateAuthority = "lets_encrypt" ) -func (r CustomHostnameNewResponseSSLCertificateAuthority) IsKnown() bool { +func (r SSLCertificateAuthority) IsKnown() bool { switch r { - case CustomHostnameNewResponseSSLCertificateAuthorityDigicert, CustomHostnameNewResponseSSLCertificateAuthorityGoogle, CustomHostnameNewResponseSSLCertificateAuthorityLetsEncrypt: + case SSLCertificateAuthorityDigicert, SSLCertificateAuthorityGoogle, SSLCertificateAuthorityLetsEncrypt: return true } return false } // SSL specific settings. -type CustomHostnameNewResponseSSLSettings struct { +type SSLSettings struct { // An allowlist of ciphers for TLS termination. These ciphers must be in the // BoringSSL format. Ciphers []string `json:"ciphers"` // Whether or not Early Hints is enabled. - EarlyHints CustomHostnameNewResponseSSLSettingsEarlyHints `json:"early_hints"` + EarlyHints SSLSettingsEarlyHints `json:"early_hints"` // Whether or not HTTP2 is enabled. - HTTP2 CustomHostnameNewResponseSSLSettingsHTTP2 `json:"http2"` + HTTP2 SSLSettingsHTTP2 `json:"http2"` // The minimum TLS version supported. - MinTLSVersion CustomHostnameNewResponseSSLSettingsMinTLSVersion `json:"min_tls_version"` + MinTLSVersion SSLSettingsMinTLSVersion `json:"min_tls_version"` // Whether or not TLS 1.3 is enabled. - TLS1_3 CustomHostnameNewResponseSSLSettingsTLS1_3 `json:"tls_1_3"` - JSON customHostnameNewResponseSSLSettingsJSON `json:"-"` + TLS1_3 SSLSettingsTLS1_3 `json:"tls_1_3"` + JSON sslSettingsJSON `json:"-"` } -// customHostnameNewResponseSSLSettingsJSON contains the JSON metadata for the -// struct [CustomHostnameNewResponseSSLSettings] -type customHostnameNewResponseSSLSettingsJSON struct { +// sslSettingsJSON contains the JSON metadata for the struct [SSLSettings] +type sslSettingsJSON struct { Ciphers apijson.Field EarlyHints apijson.Field HTTP2 apijson.Field @@ -324,139 +241,139 @@ type customHostnameNewResponseSSLSettingsJSON struct { ExtraFields map[string]apijson.Field } -func (r *CustomHostnameNewResponseSSLSettings) UnmarshalJSON(data []byte) (err error) { +func (r *SSLSettings) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r customHostnameNewResponseSSLSettingsJSON) RawJSON() string { +func (r sslSettingsJSON) RawJSON() string { return r.raw } // Whether or not Early Hints is enabled. -type CustomHostnameNewResponseSSLSettingsEarlyHints string +type SSLSettingsEarlyHints string const ( - CustomHostnameNewResponseSSLSettingsEarlyHintsOn CustomHostnameNewResponseSSLSettingsEarlyHints = "on" - CustomHostnameNewResponseSSLSettingsEarlyHintsOff CustomHostnameNewResponseSSLSettingsEarlyHints = "off" + SSLSettingsEarlyHintsOn SSLSettingsEarlyHints = "on" + SSLSettingsEarlyHintsOff SSLSettingsEarlyHints = "off" ) -func (r CustomHostnameNewResponseSSLSettingsEarlyHints) IsKnown() bool { +func (r SSLSettingsEarlyHints) IsKnown() bool { switch r { - case CustomHostnameNewResponseSSLSettingsEarlyHintsOn, CustomHostnameNewResponseSSLSettingsEarlyHintsOff: + case SSLSettingsEarlyHintsOn, SSLSettingsEarlyHintsOff: return true } return false } // Whether or not HTTP2 is enabled. -type CustomHostnameNewResponseSSLSettingsHTTP2 string +type SSLSettingsHTTP2 string const ( - CustomHostnameNewResponseSSLSettingsHTTP2On CustomHostnameNewResponseSSLSettingsHTTP2 = "on" - CustomHostnameNewResponseSSLSettingsHTTP2Off CustomHostnameNewResponseSSLSettingsHTTP2 = "off" + SSLSettingsHTTP2On SSLSettingsHTTP2 = "on" + SSLSettingsHTTP2Off SSLSettingsHTTP2 = "off" ) -func (r CustomHostnameNewResponseSSLSettingsHTTP2) IsKnown() bool { +func (r SSLSettingsHTTP2) IsKnown() bool { switch r { - case CustomHostnameNewResponseSSLSettingsHTTP2On, CustomHostnameNewResponseSSLSettingsHTTP2Off: + case SSLSettingsHTTP2On, SSLSettingsHTTP2Off: return true } return false } // The minimum TLS version supported. -type CustomHostnameNewResponseSSLSettingsMinTLSVersion string +type SSLSettingsMinTLSVersion string const ( - CustomHostnameNewResponseSSLSettingsMinTLSVersion1_0 CustomHostnameNewResponseSSLSettingsMinTLSVersion = "1.0" - CustomHostnameNewResponseSSLSettingsMinTLSVersion1_1 CustomHostnameNewResponseSSLSettingsMinTLSVersion = "1.1" - CustomHostnameNewResponseSSLSettingsMinTLSVersion1_2 CustomHostnameNewResponseSSLSettingsMinTLSVersion = "1.2" - CustomHostnameNewResponseSSLSettingsMinTLSVersion1_3 CustomHostnameNewResponseSSLSettingsMinTLSVersion = "1.3" + SSLSettingsMinTLSVersion1_0 SSLSettingsMinTLSVersion = "1.0" + SSLSettingsMinTLSVersion1_1 SSLSettingsMinTLSVersion = "1.1" + SSLSettingsMinTLSVersion1_2 SSLSettingsMinTLSVersion = "1.2" + SSLSettingsMinTLSVersion1_3 SSLSettingsMinTLSVersion = "1.3" ) -func (r CustomHostnameNewResponseSSLSettingsMinTLSVersion) IsKnown() bool { +func (r SSLSettingsMinTLSVersion) IsKnown() bool { switch r { - case CustomHostnameNewResponseSSLSettingsMinTLSVersion1_0, CustomHostnameNewResponseSSLSettingsMinTLSVersion1_1, CustomHostnameNewResponseSSLSettingsMinTLSVersion1_2, CustomHostnameNewResponseSSLSettingsMinTLSVersion1_3: + case SSLSettingsMinTLSVersion1_0, SSLSettingsMinTLSVersion1_1, SSLSettingsMinTLSVersion1_2, SSLSettingsMinTLSVersion1_3: return true } return false } // Whether or not TLS 1.3 is enabled. -type CustomHostnameNewResponseSSLSettingsTLS1_3 string +type SSLSettingsTLS1_3 string const ( - CustomHostnameNewResponseSSLSettingsTLS1_3On CustomHostnameNewResponseSSLSettingsTLS1_3 = "on" - CustomHostnameNewResponseSSLSettingsTLS1_3Off CustomHostnameNewResponseSSLSettingsTLS1_3 = "off" + SSLSettingsTLS1_3On SSLSettingsTLS1_3 = "on" + SSLSettingsTLS1_3Off SSLSettingsTLS1_3 = "off" ) -func (r CustomHostnameNewResponseSSLSettingsTLS1_3) IsKnown() bool { +func (r SSLSettingsTLS1_3) IsKnown() bool { switch r { - case CustomHostnameNewResponseSSLSettingsTLS1_3On, CustomHostnameNewResponseSSLSettingsTLS1_3Off: + case SSLSettingsTLS1_3On, SSLSettingsTLS1_3Off: return true } return false } // Status of the hostname's SSL certificates. -type CustomHostnameNewResponseSSLStatus string +type SSLStatus string const ( - CustomHostnameNewResponseSSLStatusInitializing CustomHostnameNewResponseSSLStatus = "initializing" - CustomHostnameNewResponseSSLStatusPendingValidation CustomHostnameNewResponseSSLStatus = "pending_validation" - CustomHostnameNewResponseSSLStatusDeleted CustomHostnameNewResponseSSLStatus = "deleted" - CustomHostnameNewResponseSSLStatusPendingIssuance CustomHostnameNewResponseSSLStatus = "pending_issuance" - CustomHostnameNewResponseSSLStatusPendingDeployment CustomHostnameNewResponseSSLStatus = "pending_deployment" - CustomHostnameNewResponseSSLStatusPendingDeletion CustomHostnameNewResponseSSLStatus = "pending_deletion" - CustomHostnameNewResponseSSLStatusPendingExpiration CustomHostnameNewResponseSSLStatus = "pending_expiration" - CustomHostnameNewResponseSSLStatusExpired CustomHostnameNewResponseSSLStatus = "expired" - CustomHostnameNewResponseSSLStatusActive CustomHostnameNewResponseSSLStatus = "active" - CustomHostnameNewResponseSSLStatusInitializingTimedOut CustomHostnameNewResponseSSLStatus = "initializing_timed_out" - CustomHostnameNewResponseSSLStatusValidationTimedOut CustomHostnameNewResponseSSLStatus = "validation_timed_out" - CustomHostnameNewResponseSSLStatusIssuanceTimedOut CustomHostnameNewResponseSSLStatus = "issuance_timed_out" - CustomHostnameNewResponseSSLStatusDeploymentTimedOut CustomHostnameNewResponseSSLStatus = "deployment_timed_out" - CustomHostnameNewResponseSSLStatusDeletionTimedOut CustomHostnameNewResponseSSLStatus = "deletion_timed_out" - CustomHostnameNewResponseSSLStatusPendingCleanup CustomHostnameNewResponseSSLStatus = "pending_cleanup" - CustomHostnameNewResponseSSLStatusStagingDeployment CustomHostnameNewResponseSSLStatus = "staging_deployment" - CustomHostnameNewResponseSSLStatusStagingActive CustomHostnameNewResponseSSLStatus = "staging_active" - CustomHostnameNewResponseSSLStatusDeactivating CustomHostnameNewResponseSSLStatus = "deactivating" - CustomHostnameNewResponseSSLStatusInactive CustomHostnameNewResponseSSLStatus = "inactive" - CustomHostnameNewResponseSSLStatusBackupIssued CustomHostnameNewResponseSSLStatus = "backup_issued" - CustomHostnameNewResponseSSLStatusHoldingDeployment CustomHostnameNewResponseSSLStatus = "holding_deployment" + SSLStatusInitializing SSLStatus = "initializing" + SSLStatusPendingValidation SSLStatus = "pending_validation" + SSLStatusDeleted SSLStatus = "deleted" + SSLStatusPendingIssuance SSLStatus = "pending_issuance" + SSLStatusPendingDeployment SSLStatus = "pending_deployment" + SSLStatusPendingDeletion SSLStatus = "pending_deletion" + SSLStatusPendingExpiration SSLStatus = "pending_expiration" + SSLStatusExpired SSLStatus = "expired" + SSLStatusActive SSLStatus = "active" + SSLStatusInitializingTimedOut SSLStatus = "initializing_timed_out" + SSLStatusValidationTimedOut SSLStatus = "validation_timed_out" + SSLStatusIssuanceTimedOut SSLStatus = "issuance_timed_out" + SSLStatusDeploymentTimedOut SSLStatus = "deployment_timed_out" + SSLStatusDeletionTimedOut SSLStatus = "deletion_timed_out" + SSLStatusPendingCleanup SSLStatus = "pending_cleanup" + SSLStatusStagingDeployment SSLStatus = "staging_deployment" + SSLStatusStagingActive SSLStatus = "staging_active" + SSLStatusDeactivating SSLStatus = "deactivating" + SSLStatusInactive SSLStatus = "inactive" + SSLStatusBackupIssued SSLStatus = "backup_issued" + SSLStatusHoldingDeployment SSLStatus = "holding_deployment" ) -func (r CustomHostnameNewResponseSSLStatus) IsKnown() bool { +func (r SSLStatus) IsKnown() bool { switch r { - case CustomHostnameNewResponseSSLStatusInitializing, CustomHostnameNewResponseSSLStatusPendingValidation, CustomHostnameNewResponseSSLStatusDeleted, CustomHostnameNewResponseSSLStatusPendingIssuance, CustomHostnameNewResponseSSLStatusPendingDeployment, CustomHostnameNewResponseSSLStatusPendingDeletion, CustomHostnameNewResponseSSLStatusPendingExpiration, CustomHostnameNewResponseSSLStatusExpired, CustomHostnameNewResponseSSLStatusActive, CustomHostnameNewResponseSSLStatusInitializingTimedOut, CustomHostnameNewResponseSSLStatusValidationTimedOut, CustomHostnameNewResponseSSLStatusIssuanceTimedOut, CustomHostnameNewResponseSSLStatusDeploymentTimedOut, CustomHostnameNewResponseSSLStatusDeletionTimedOut, CustomHostnameNewResponseSSLStatusPendingCleanup, CustomHostnameNewResponseSSLStatusStagingDeployment, CustomHostnameNewResponseSSLStatusStagingActive, CustomHostnameNewResponseSSLStatusDeactivating, CustomHostnameNewResponseSSLStatusInactive, CustomHostnameNewResponseSSLStatusBackupIssued, CustomHostnameNewResponseSSLStatusHoldingDeployment: + case SSLStatusInitializing, SSLStatusPendingValidation, SSLStatusDeleted, SSLStatusPendingIssuance, SSLStatusPendingDeployment, SSLStatusPendingDeletion, SSLStatusPendingExpiration, SSLStatusExpired, SSLStatusActive, SSLStatusInitializingTimedOut, SSLStatusValidationTimedOut, SSLStatusIssuanceTimedOut, SSLStatusDeploymentTimedOut, SSLStatusDeletionTimedOut, SSLStatusPendingCleanup, SSLStatusStagingDeployment, SSLStatusStagingActive, SSLStatusDeactivating, SSLStatusInactive, SSLStatusBackupIssued, SSLStatusHoldingDeployment: return true } return false } -type CustomHostnameNewResponseSSLValidationError struct { +type SSLValidationError struct { // A domain validation error. - Message string `json:"message"` - JSON customHostnameNewResponseSSLValidationErrorJSON `json:"-"` + Message string `json:"message"` + JSON sslValidationErrorJSON `json:"-"` } -// customHostnameNewResponseSSLValidationErrorJSON contains the JSON metadata for -// the struct [CustomHostnameNewResponseSSLValidationError] -type customHostnameNewResponseSSLValidationErrorJSON struct { +// sslValidationErrorJSON contains the JSON metadata for the struct +// [SSLValidationError] +type sslValidationErrorJSON struct { Message apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *CustomHostnameNewResponseSSLValidationError) UnmarshalJSON(data []byte) (err error) { +func (r *SSLValidationError) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r customHostnameNewResponseSSLValidationErrorJSON) RawJSON() string { +func (r sslValidationErrorJSON) RawJSON() string { return r.raw } // Certificate's required validation record. -type CustomHostnameNewResponseSSLValidationRecord struct { +type SSLValidationRecord struct { // The set of email addresses that the certificate authority (CA) will use to // complete domain validation. Emails []interface{} `json:"emails"` @@ -470,13 +387,13 @@ type CustomHostnameNewResponseSSLValidationRecord struct { TXTName string `json:"txt_name"` // The TXT record that the certificate authority (CA) will check during domain // validation. - TXTValue string `json:"txt_value"` - JSON customHostnameNewResponseSSLValidationRecordJSON `json:"-"` + TXTValue string `json:"txt_value"` + JSON sslValidationRecordJSON `json:"-"` } -// customHostnameNewResponseSSLValidationRecordJSON contains the JSON metadata for -// the struct [CustomHostnameNewResponseSSLValidationRecord] -type customHostnameNewResponseSSLValidationRecordJSON struct { +// sslValidationRecordJSON contains the JSON metadata for the struct +// [SSLValidationRecord] +type sslValidationRecordJSON struct { Emails apijson.Field HTTPBody apijson.Field HTTPURL apijson.Field @@ -486,11 +403,92 @@ type customHostnameNewResponseSSLValidationRecordJSON struct { ExtraFields map[string]apijson.Field } -func (r *CustomHostnameNewResponseSSLValidationRecord) UnmarshalJSON(data []byte) (err error) { +func (r *SSLValidationRecord) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r sslValidationRecordJSON) RawJSON() string { + return r.raw +} + +// A ubiquitous bundle has the highest probability of being verified everywhere, +// even by clients using outdated or unusual trust stores. An optimal bundle uses +// the shortest chain and newest intermediates. And the force bundle verifies the +// chain, but does not otherwise modify it. +type UnnamedSchemaRef16aca57bde2963201c7e6e895436c1c1 string + +const ( + UnnamedSchemaRef16aca57bde2963201c7e6e895436c1c1Ubiquitous UnnamedSchemaRef16aca57bde2963201c7e6e895436c1c1 = "ubiquitous" + UnnamedSchemaRef16aca57bde2963201c7e6e895436c1c1Optimal UnnamedSchemaRef16aca57bde2963201c7e6e895436c1c1 = "optimal" + UnnamedSchemaRef16aca57bde2963201c7e6e895436c1c1Force UnnamedSchemaRef16aca57bde2963201c7e6e895436c1c1 = "force" +) + +func (r UnnamedSchemaRef16aca57bde2963201c7e6e895436c1c1) IsKnown() bool { + switch r { + case UnnamedSchemaRef16aca57bde2963201c7e6e895436c1c1Ubiquitous, UnnamedSchemaRef16aca57bde2963201c7e6e895436c1c1Optimal, UnnamedSchemaRef16aca57bde2963201c7e6e895436c1c1Force: + return true + } + return false +} + +// Domain control validation (DCV) method used for this hostname. +type UnnamedSchemaRef78adb375f06c6d462dd92b99e2ecf510 string + +const ( + UnnamedSchemaRef78adb375f06c6d462dd92b99e2ecf510HTTP UnnamedSchemaRef78adb375f06c6d462dd92b99e2ecf510 = "http" + UnnamedSchemaRef78adb375f06c6d462dd92b99e2ecf510TXT UnnamedSchemaRef78adb375f06c6d462dd92b99e2ecf510 = "txt" + UnnamedSchemaRef78adb375f06c6d462dd92b99e2ecf510Email UnnamedSchemaRef78adb375f06c6d462dd92b99e2ecf510 = "email" +) + +func (r UnnamedSchemaRef78adb375f06c6d462dd92b99e2ecf510) IsKnown() bool { + switch r { + case UnnamedSchemaRef78adb375f06c6d462dd92b99e2ecf510HTTP, UnnamedSchemaRef78adb375f06c6d462dd92b99e2ecf510TXT, UnnamedSchemaRef78adb375f06c6d462dd92b99e2ecf510Email: + return true + } + return false +} + +// Level of validation to be used for this hostname. Domain validation (dv) must be +// used. +type UnnamedSchemaRef9a9935a9a770967bb604ae41a81e42e1 string + +const ( + UnnamedSchemaRef9a9935a9a770967bb604ae41a81e42e1Dv UnnamedSchemaRef9a9935a9a770967bb604ae41a81e42e1 = "dv" +) + +func (r UnnamedSchemaRef9a9935a9a770967bb604ae41a81e42e1) IsKnown() bool { + switch r { + case UnnamedSchemaRef9a9935a9a770967bb604ae41a81e42e1Dv: + return true + } + return false +} + +type CustomHostnameNewResponse struct { + // Identifier + ID string `json:"id,required"` + // The custom hostname that will point to your hostname via CNAME. + Hostname string `json:"hostname,required"` + // SSL properties for the custom hostname. + SSL SSL `json:"ssl,required"` + JSON customHostnameNewResponseJSON `json:"-"` +} + +// customHostnameNewResponseJSON contains the JSON metadata for the struct +// [CustomHostnameNewResponse] +type customHostnameNewResponseJSON struct { + ID apijson.Field + Hostname apijson.Field + SSL apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *CustomHostnameNewResponse) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r customHostnameNewResponseSSLValidationRecordJSON) RawJSON() string { +func (r customHostnameNewResponseJSON) RawJSON() string { return r.raw } @@ -500,7 +498,7 @@ type CustomHostnameListResponse struct { // The custom hostname that will point to your hostname via CNAME. Hostname string `json:"hostname,required"` // SSL properties for the custom hostname. - SSL CustomHostnameListResponseSSL `json:"ssl,required"` + SSL SSL `json:"ssl,required"` JSON customHostnameListResponseJSON `json:"-"` } @@ -522,634 +520,42 @@ func (r customHostnameListResponseJSON) RawJSON() string { return r.raw } -// SSL properties for the custom hostname. -type CustomHostnameListResponseSSL struct { - // Custom hostname SSL identifier tag. - ID string `json:"id"` - // A ubiquitous bundle has the highest probability of being verified everywhere, - // even by clients using outdated or unusual trust stores. An optimal bundle uses - // the shortest chain and newest intermediates. And the force bundle verifies the - // chain, but does not otherwise modify it. - BundleMethod UnnamedSchemaRef16aca57bde2963201c7e6e895436c1c1 `json:"bundle_method"` - // The Certificate Authority that will issue the certificate - CertificateAuthority CustomHostnameListResponseSSLCertificateAuthority `json:"certificate_authority"` - // If a custom uploaded certificate is used. - CustomCertificate string `json:"custom_certificate"` - // The identifier for the Custom CSR that was used. - CustomCsrID string `json:"custom_csr_id"` - // The key for a custom uploaded certificate. - CustomKey string `json:"custom_key"` - // The time the custom certificate expires on. - ExpiresOn time.Time `json:"expires_on" format:"date-time"` - // A list of Hostnames on a custom uploaded certificate. - Hosts []interface{} `json:"hosts"` - // The issuer on a custom uploaded certificate. - Issuer string `json:"issuer"` - // Domain control validation (DCV) method used for this hostname. - Method UnnamedSchemaRef78adb375f06c6d462dd92b99e2ecf510 `json:"method"` - // The serial number on a custom uploaded certificate. - SerialNumber string `json:"serial_number"` - // SSL specific settings. - Settings CustomHostnameListResponseSSLSettings `json:"settings"` - // The signature on a custom uploaded certificate. - Signature string `json:"signature"` - // Status of the hostname's SSL certificates. - Status CustomHostnameListResponseSSLStatus `json:"status"` - // Level of validation to be used for this hostname. Domain validation (dv) must be - // used. - Type UnnamedSchemaRef9a9935a9a770967bb604ae41a81e42e1 `json:"type"` - // The time the custom certificate was uploaded. - UploadedOn time.Time `json:"uploaded_on" format:"date-time"` - // Domain validation errors that have been received by the certificate authority - // (CA). - ValidationErrors []CustomHostnameListResponseSSLValidationError `json:"validation_errors"` - ValidationRecords []CustomHostnameListResponseSSLValidationRecord `json:"validation_records"` - // Indicates whether the certificate covers a wildcard. - Wildcard bool `json:"wildcard"` - JSON customHostnameListResponseSSLJSON `json:"-"` +type CustomHostnameEditResponse struct { + // Identifier + ID string `json:"id,required"` + // The custom hostname that will point to your hostname via CNAME. + Hostname string `json:"hostname,required"` + // SSL properties for the custom hostname. + SSL SSL `json:"ssl,required"` + JSON customHostnameEditResponseJSON `json:"-"` } -// customHostnameListResponseSSLJSON contains the JSON metadata for the struct -// [CustomHostnameListResponseSSL] -type customHostnameListResponseSSLJSON struct { - ID apijson.Field - BundleMethod apijson.Field - CertificateAuthority apijson.Field - CustomCertificate apijson.Field - CustomCsrID apijson.Field - CustomKey apijson.Field - ExpiresOn apijson.Field - Hosts apijson.Field - Issuer apijson.Field - Method apijson.Field - SerialNumber apijson.Field - Settings apijson.Field - Signature apijson.Field - Status apijson.Field - Type apijson.Field - UploadedOn apijson.Field - ValidationErrors apijson.Field - ValidationRecords apijson.Field - Wildcard apijson.Field - raw string - ExtraFields map[string]apijson.Field +// customHostnameEditResponseJSON contains the JSON metadata for the struct +// [CustomHostnameEditResponse] +type customHostnameEditResponseJSON struct { + ID apijson.Field + Hostname apijson.Field + SSL apijson.Field + raw string + ExtraFields map[string]apijson.Field } -func (r *CustomHostnameListResponseSSL) UnmarshalJSON(data []byte) (err error) { +func (r *CustomHostnameEditResponse) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r customHostnameListResponseSSLJSON) RawJSON() string { +func (r customHostnameEditResponseJSON) RawJSON() string { return r.raw } -// The Certificate Authority that will issue the certificate -type CustomHostnameListResponseSSLCertificateAuthority string - -const ( - CustomHostnameListResponseSSLCertificateAuthorityDigicert CustomHostnameListResponseSSLCertificateAuthority = "digicert" - CustomHostnameListResponseSSLCertificateAuthorityGoogle CustomHostnameListResponseSSLCertificateAuthority = "google" - CustomHostnameListResponseSSLCertificateAuthorityLetsEncrypt CustomHostnameListResponseSSLCertificateAuthority = "lets_encrypt" -) - -func (r CustomHostnameListResponseSSLCertificateAuthority) IsKnown() bool { - switch r { - case CustomHostnameListResponseSSLCertificateAuthorityDigicert, CustomHostnameListResponseSSLCertificateAuthorityGoogle, CustomHostnameListResponseSSLCertificateAuthorityLetsEncrypt: - return true - } - return false -} - -// SSL specific settings. -type CustomHostnameListResponseSSLSettings struct { - // An allowlist of ciphers for TLS termination. These ciphers must be in the - // BoringSSL format. - Ciphers []string `json:"ciphers"` - // Whether or not Early Hints is enabled. - EarlyHints CustomHostnameListResponseSSLSettingsEarlyHints `json:"early_hints"` - // Whether or not HTTP2 is enabled. - HTTP2 CustomHostnameListResponseSSLSettingsHTTP2 `json:"http2"` - // The minimum TLS version supported. - MinTLSVersion CustomHostnameListResponseSSLSettingsMinTLSVersion `json:"min_tls_version"` - // Whether or not TLS 1.3 is enabled. - TLS1_3 CustomHostnameListResponseSSLSettingsTLS1_3 `json:"tls_1_3"` - JSON customHostnameListResponseSSLSettingsJSON `json:"-"` -} - -// customHostnameListResponseSSLSettingsJSON contains the JSON metadata for the -// struct [CustomHostnameListResponseSSLSettings] -type customHostnameListResponseSSLSettingsJSON struct { - Ciphers apijson.Field - EarlyHints apijson.Field - HTTP2 apijson.Field - MinTLSVersion apijson.Field - TLS1_3 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomHostnameListResponseSSLSettings) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customHostnameListResponseSSLSettingsJSON) RawJSON() string { - return r.raw -} - -// Whether or not Early Hints is enabled. -type CustomHostnameListResponseSSLSettingsEarlyHints string - -const ( - CustomHostnameListResponseSSLSettingsEarlyHintsOn CustomHostnameListResponseSSLSettingsEarlyHints = "on" - CustomHostnameListResponseSSLSettingsEarlyHintsOff CustomHostnameListResponseSSLSettingsEarlyHints = "off" -) - -func (r CustomHostnameListResponseSSLSettingsEarlyHints) IsKnown() bool { - switch r { - case CustomHostnameListResponseSSLSettingsEarlyHintsOn, CustomHostnameListResponseSSLSettingsEarlyHintsOff: - return true - } - return false -} - -// Whether or not HTTP2 is enabled. -type CustomHostnameListResponseSSLSettingsHTTP2 string - -const ( - CustomHostnameListResponseSSLSettingsHTTP2On CustomHostnameListResponseSSLSettingsHTTP2 = "on" - CustomHostnameListResponseSSLSettingsHTTP2Off CustomHostnameListResponseSSLSettingsHTTP2 = "off" -) - -func (r CustomHostnameListResponseSSLSettingsHTTP2) IsKnown() bool { - switch r { - case CustomHostnameListResponseSSLSettingsHTTP2On, CustomHostnameListResponseSSLSettingsHTTP2Off: - return true - } - return false -} - -// The minimum TLS version supported. -type CustomHostnameListResponseSSLSettingsMinTLSVersion string - -const ( - CustomHostnameListResponseSSLSettingsMinTLSVersion1_0 CustomHostnameListResponseSSLSettingsMinTLSVersion = "1.0" - CustomHostnameListResponseSSLSettingsMinTLSVersion1_1 CustomHostnameListResponseSSLSettingsMinTLSVersion = "1.1" - CustomHostnameListResponseSSLSettingsMinTLSVersion1_2 CustomHostnameListResponseSSLSettingsMinTLSVersion = "1.2" - CustomHostnameListResponseSSLSettingsMinTLSVersion1_3 CustomHostnameListResponseSSLSettingsMinTLSVersion = "1.3" -) - -func (r CustomHostnameListResponseSSLSettingsMinTLSVersion) IsKnown() bool { - switch r { - case CustomHostnameListResponseSSLSettingsMinTLSVersion1_0, CustomHostnameListResponseSSLSettingsMinTLSVersion1_1, CustomHostnameListResponseSSLSettingsMinTLSVersion1_2, CustomHostnameListResponseSSLSettingsMinTLSVersion1_3: - return true - } - return false -} - -// Whether or not TLS 1.3 is enabled. -type CustomHostnameListResponseSSLSettingsTLS1_3 string - -const ( - CustomHostnameListResponseSSLSettingsTLS1_3On CustomHostnameListResponseSSLSettingsTLS1_3 = "on" - CustomHostnameListResponseSSLSettingsTLS1_3Off CustomHostnameListResponseSSLSettingsTLS1_3 = "off" -) - -func (r CustomHostnameListResponseSSLSettingsTLS1_3) IsKnown() bool { - switch r { - case CustomHostnameListResponseSSLSettingsTLS1_3On, CustomHostnameListResponseSSLSettingsTLS1_3Off: - return true - } - return false -} - -// Status of the hostname's SSL certificates. -type CustomHostnameListResponseSSLStatus string - -const ( - CustomHostnameListResponseSSLStatusInitializing CustomHostnameListResponseSSLStatus = "initializing" - CustomHostnameListResponseSSLStatusPendingValidation CustomHostnameListResponseSSLStatus = "pending_validation" - CustomHostnameListResponseSSLStatusDeleted CustomHostnameListResponseSSLStatus = "deleted" - CustomHostnameListResponseSSLStatusPendingIssuance CustomHostnameListResponseSSLStatus = "pending_issuance" - CustomHostnameListResponseSSLStatusPendingDeployment CustomHostnameListResponseSSLStatus = "pending_deployment" - CustomHostnameListResponseSSLStatusPendingDeletion CustomHostnameListResponseSSLStatus = "pending_deletion" - CustomHostnameListResponseSSLStatusPendingExpiration CustomHostnameListResponseSSLStatus = "pending_expiration" - CustomHostnameListResponseSSLStatusExpired CustomHostnameListResponseSSLStatus = "expired" - CustomHostnameListResponseSSLStatusActive CustomHostnameListResponseSSLStatus = "active" - CustomHostnameListResponseSSLStatusInitializingTimedOut CustomHostnameListResponseSSLStatus = "initializing_timed_out" - CustomHostnameListResponseSSLStatusValidationTimedOut CustomHostnameListResponseSSLStatus = "validation_timed_out" - CustomHostnameListResponseSSLStatusIssuanceTimedOut CustomHostnameListResponseSSLStatus = "issuance_timed_out" - CustomHostnameListResponseSSLStatusDeploymentTimedOut CustomHostnameListResponseSSLStatus = "deployment_timed_out" - CustomHostnameListResponseSSLStatusDeletionTimedOut CustomHostnameListResponseSSLStatus = "deletion_timed_out" - CustomHostnameListResponseSSLStatusPendingCleanup CustomHostnameListResponseSSLStatus = "pending_cleanup" - CustomHostnameListResponseSSLStatusStagingDeployment CustomHostnameListResponseSSLStatus = "staging_deployment" - CustomHostnameListResponseSSLStatusStagingActive CustomHostnameListResponseSSLStatus = "staging_active" - CustomHostnameListResponseSSLStatusDeactivating CustomHostnameListResponseSSLStatus = "deactivating" - CustomHostnameListResponseSSLStatusInactive CustomHostnameListResponseSSLStatus = "inactive" - CustomHostnameListResponseSSLStatusBackupIssued CustomHostnameListResponseSSLStatus = "backup_issued" - CustomHostnameListResponseSSLStatusHoldingDeployment CustomHostnameListResponseSSLStatus = "holding_deployment" -) - -func (r CustomHostnameListResponseSSLStatus) IsKnown() bool { - switch r { - case CustomHostnameListResponseSSLStatusInitializing, CustomHostnameListResponseSSLStatusPendingValidation, CustomHostnameListResponseSSLStatusDeleted, CustomHostnameListResponseSSLStatusPendingIssuance, CustomHostnameListResponseSSLStatusPendingDeployment, CustomHostnameListResponseSSLStatusPendingDeletion, CustomHostnameListResponseSSLStatusPendingExpiration, CustomHostnameListResponseSSLStatusExpired, CustomHostnameListResponseSSLStatusActive, CustomHostnameListResponseSSLStatusInitializingTimedOut, CustomHostnameListResponseSSLStatusValidationTimedOut, CustomHostnameListResponseSSLStatusIssuanceTimedOut, CustomHostnameListResponseSSLStatusDeploymentTimedOut, CustomHostnameListResponseSSLStatusDeletionTimedOut, CustomHostnameListResponseSSLStatusPendingCleanup, CustomHostnameListResponseSSLStatusStagingDeployment, CustomHostnameListResponseSSLStatusStagingActive, CustomHostnameListResponseSSLStatusDeactivating, CustomHostnameListResponseSSLStatusInactive, CustomHostnameListResponseSSLStatusBackupIssued, CustomHostnameListResponseSSLStatusHoldingDeployment: - return true - } - return false -} - -type CustomHostnameListResponseSSLValidationError struct { - // A domain validation error. - Message string `json:"message"` - JSON customHostnameListResponseSSLValidationErrorJSON `json:"-"` -} - -// customHostnameListResponseSSLValidationErrorJSON contains the JSON metadata for -// the struct [CustomHostnameListResponseSSLValidationError] -type customHostnameListResponseSSLValidationErrorJSON struct { - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomHostnameListResponseSSLValidationError) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customHostnameListResponseSSLValidationErrorJSON) RawJSON() string { - return r.raw -} - -// Certificate's required validation record. -type CustomHostnameListResponseSSLValidationRecord struct { - // The set of email addresses that the certificate authority (CA) will use to - // complete domain validation. - Emails []interface{} `json:"emails"` - // The content that the certificate authority (CA) will expect to find at the - // http_url during the domain validation. - HTTPBody string `json:"http_body"` - // The url that will be checked during domain validation. - HTTPURL string `json:"http_url"` - // The hostname that the certificate authority (CA) will check for a TXT record - // during domain validation . - TXTName string `json:"txt_name"` - // The TXT record that the certificate authority (CA) will check during domain - // validation. - TXTValue string `json:"txt_value"` - JSON customHostnameListResponseSSLValidationRecordJSON `json:"-"` -} - -// customHostnameListResponseSSLValidationRecordJSON contains the JSON metadata for -// the struct [CustomHostnameListResponseSSLValidationRecord] -type customHostnameListResponseSSLValidationRecordJSON struct { - Emails apijson.Field - HTTPBody apijson.Field - HTTPURL apijson.Field - TXTName apijson.Field - TXTValue apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomHostnameListResponseSSLValidationRecord) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customHostnameListResponseSSLValidationRecordJSON) RawJSON() string { - return r.raw -} - -type CustomHostnameEditResponse struct { - // Identifier - ID string `json:"id,required"` - // The custom hostname that will point to your hostname via CNAME. - Hostname string `json:"hostname,required"` - // SSL properties for the custom hostname. - SSL CustomHostnameEditResponseSSL `json:"ssl,required"` - JSON customHostnameEditResponseJSON `json:"-"` -} - -// customHostnameEditResponseJSON contains the JSON metadata for the struct -// [CustomHostnameEditResponse] -type customHostnameEditResponseJSON struct { - ID apijson.Field - Hostname apijson.Field - SSL apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomHostnameEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customHostnameEditResponseJSON) RawJSON() string { - return r.raw -} - -// SSL properties for the custom hostname. -type CustomHostnameEditResponseSSL struct { - // Custom hostname SSL identifier tag. - ID string `json:"id"` - // A ubiquitous bundle has the highest probability of being verified everywhere, - // even by clients using outdated or unusual trust stores. An optimal bundle uses - // the shortest chain and newest intermediates. And the force bundle verifies the - // chain, but does not otherwise modify it. - BundleMethod UnnamedSchemaRef16aca57bde2963201c7e6e895436c1c1 `json:"bundle_method"` - // The Certificate Authority that will issue the certificate - CertificateAuthority CustomHostnameEditResponseSSLCertificateAuthority `json:"certificate_authority"` - // If a custom uploaded certificate is used. - CustomCertificate string `json:"custom_certificate"` - // The identifier for the Custom CSR that was used. - CustomCsrID string `json:"custom_csr_id"` - // The key for a custom uploaded certificate. - CustomKey string `json:"custom_key"` - // The time the custom certificate expires on. - ExpiresOn time.Time `json:"expires_on" format:"date-time"` - // A list of Hostnames on a custom uploaded certificate. - Hosts []interface{} `json:"hosts"` - // The issuer on a custom uploaded certificate. - Issuer string `json:"issuer"` - // Domain control validation (DCV) method used for this hostname. - Method UnnamedSchemaRef78adb375f06c6d462dd92b99e2ecf510 `json:"method"` - // The serial number on a custom uploaded certificate. - SerialNumber string `json:"serial_number"` - // SSL specific settings. - Settings CustomHostnameEditResponseSSLSettings `json:"settings"` - // The signature on a custom uploaded certificate. - Signature string `json:"signature"` - // Status of the hostname's SSL certificates. - Status CustomHostnameEditResponseSSLStatus `json:"status"` - // Level of validation to be used for this hostname. Domain validation (dv) must be - // used. - Type UnnamedSchemaRef9a9935a9a770967bb604ae41a81e42e1 `json:"type"` - // The time the custom certificate was uploaded. - UploadedOn time.Time `json:"uploaded_on" format:"date-time"` - // Domain validation errors that have been received by the certificate authority - // (CA). - ValidationErrors []CustomHostnameEditResponseSSLValidationError `json:"validation_errors"` - ValidationRecords []CustomHostnameEditResponseSSLValidationRecord `json:"validation_records"` - // Indicates whether the certificate covers a wildcard. - Wildcard bool `json:"wildcard"` - JSON customHostnameEditResponseSSLJSON `json:"-"` -} - -// customHostnameEditResponseSSLJSON contains the JSON metadata for the struct -// [CustomHostnameEditResponseSSL] -type customHostnameEditResponseSSLJSON struct { - ID apijson.Field - BundleMethod apijson.Field - CertificateAuthority apijson.Field - CustomCertificate apijson.Field - CustomCsrID apijson.Field - CustomKey apijson.Field - ExpiresOn apijson.Field - Hosts apijson.Field - Issuer apijson.Field - Method apijson.Field - SerialNumber apijson.Field - Settings apijson.Field - Signature apijson.Field - Status apijson.Field - Type apijson.Field - UploadedOn apijson.Field - ValidationErrors apijson.Field - ValidationRecords apijson.Field - Wildcard apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomHostnameEditResponseSSL) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customHostnameEditResponseSSLJSON) RawJSON() string { - return r.raw -} - -// The Certificate Authority that will issue the certificate -type CustomHostnameEditResponseSSLCertificateAuthority string - -const ( - CustomHostnameEditResponseSSLCertificateAuthorityDigicert CustomHostnameEditResponseSSLCertificateAuthority = "digicert" - CustomHostnameEditResponseSSLCertificateAuthorityGoogle CustomHostnameEditResponseSSLCertificateAuthority = "google" - CustomHostnameEditResponseSSLCertificateAuthorityLetsEncrypt CustomHostnameEditResponseSSLCertificateAuthority = "lets_encrypt" -) - -func (r CustomHostnameEditResponseSSLCertificateAuthority) IsKnown() bool { - switch r { - case CustomHostnameEditResponseSSLCertificateAuthorityDigicert, CustomHostnameEditResponseSSLCertificateAuthorityGoogle, CustomHostnameEditResponseSSLCertificateAuthorityLetsEncrypt: - return true - } - return false -} - -// SSL specific settings. -type CustomHostnameEditResponseSSLSettings struct { - // An allowlist of ciphers for TLS termination. These ciphers must be in the - // BoringSSL format. - Ciphers []string `json:"ciphers"` - // Whether or not Early Hints is enabled. - EarlyHints CustomHostnameEditResponseSSLSettingsEarlyHints `json:"early_hints"` - // Whether or not HTTP2 is enabled. - HTTP2 CustomHostnameEditResponseSSLSettingsHTTP2 `json:"http2"` - // The minimum TLS version supported. - MinTLSVersion CustomHostnameEditResponseSSLSettingsMinTLSVersion `json:"min_tls_version"` - // Whether or not TLS 1.3 is enabled. - TLS1_3 CustomHostnameEditResponseSSLSettingsTLS1_3 `json:"tls_1_3"` - JSON customHostnameEditResponseSSLSettingsJSON `json:"-"` -} - -// customHostnameEditResponseSSLSettingsJSON contains the JSON metadata for the -// struct [CustomHostnameEditResponseSSLSettings] -type customHostnameEditResponseSSLSettingsJSON struct { - Ciphers apijson.Field - EarlyHints apijson.Field - HTTP2 apijson.Field - MinTLSVersion apijson.Field - TLS1_3 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomHostnameEditResponseSSLSettings) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customHostnameEditResponseSSLSettingsJSON) RawJSON() string { - return r.raw -} - -// Whether or not Early Hints is enabled. -type CustomHostnameEditResponseSSLSettingsEarlyHints string - -const ( - CustomHostnameEditResponseSSLSettingsEarlyHintsOn CustomHostnameEditResponseSSLSettingsEarlyHints = "on" - CustomHostnameEditResponseSSLSettingsEarlyHintsOff CustomHostnameEditResponseSSLSettingsEarlyHints = "off" -) - -func (r CustomHostnameEditResponseSSLSettingsEarlyHints) IsKnown() bool { - switch r { - case CustomHostnameEditResponseSSLSettingsEarlyHintsOn, CustomHostnameEditResponseSSLSettingsEarlyHintsOff: - return true - } - return false -} - -// Whether or not HTTP2 is enabled. -type CustomHostnameEditResponseSSLSettingsHTTP2 string - -const ( - CustomHostnameEditResponseSSLSettingsHTTP2On CustomHostnameEditResponseSSLSettingsHTTP2 = "on" - CustomHostnameEditResponseSSLSettingsHTTP2Off CustomHostnameEditResponseSSLSettingsHTTP2 = "off" -) - -func (r CustomHostnameEditResponseSSLSettingsHTTP2) IsKnown() bool { - switch r { - case CustomHostnameEditResponseSSLSettingsHTTP2On, CustomHostnameEditResponseSSLSettingsHTTP2Off: - return true - } - return false -} - -// The minimum TLS version supported. -type CustomHostnameEditResponseSSLSettingsMinTLSVersion string - -const ( - CustomHostnameEditResponseSSLSettingsMinTLSVersion1_0 CustomHostnameEditResponseSSLSettingsMinTLSVersion = "1.0" - CustomHostnameEditResponseSSLSettingsMinTLSVersion1_1 CustomHostnameEditResponseSSLSettingsMinTLSVersion = "1.1" - CustomHostnameEditResponseSSLSettingsMinTLSVersion1_2 CustomHostnameEditResponseSSLSettingsMinTLSVersion = "1.2" - CustomHostnameEditResponseSSLSettingsMinTLSVersion1_3 CustomHostnameEditResponseSSLSettingsMinTLSVersion = "1.3" -) - -func (r CustomHostnameEditResponseSSLSettingsMinTLSVersion) IsKnown() bool { - switch r { - case CustomHostnameEditResponseSSLSettingsMinTLSVersion1_0, CustomHostnameEditResponseSSLSettingsMinTLSVersion1_1, CustomHostnameEditResponseSSLSettingsMinTLSVersion1_2, CustomHostnameEditResponseSSLSettingsMinTLSVersion1_3: - return true - } - return false -} - -// Whether or not TLS 1.3 is enabled. -type CustomHostnameEditResponseSSLSettingsTLS1_3 string - -const ( - CustomHostnameEditResponseSSLSettingsTLS1_3On CustomHostnameEditResponseSSLSettingsTLS1_3 = "on" - CustomHostnameEditResponseSSLSettingsTLS1_3Off CustomHostnameEditResponseSSLSettingsTLS1_3 = "off" -) - -func (r CustomHostnameEditResponseSSLSettingsTLS1_3) IsKnown() bool { - switch r { - case CustomHostnameEditResponseSSLSettingsTLS1_3On, CustomHostnameEditResponseSSLSettingsTLS1_3Off: - return true - } - return false -} - -// Status of the hostname's SSL certificates. -type CustomHostnameEditResponseSSLStatus string - -const ( - CustomHostnameEditResponseSSLStatusInitializing CustomHostnameEditResponseSSLStatus = "initializing" - CustomHostnameEditResponseSSLStatusPendingValidation CustomHostnameEditResponseSSLStatus = "pending_validation" - CustomHostnameEditResponseSSLStatusDeleted CustomHostnameEditResponseSSLStatus = "deleted" - CustomHostnameEditResponseSSLStatusPendingIssuance CustomHostnameEditResponseSSLStatus = "pending_issuance" - CustomHostnameEditResponseSSLStatusPendingDeployment CustomHostnameEditResponseSSLStatus = "pending_deployment" - CustomHostnameEditResponseSSLStatusPendingDeletion CustomHostnameEditResponseSSLStatus = "pending_deletion" - CustomHostnameEditResponseSSLStatusPendingExpiration CustomHostnameEditResponseSSLStatus = "pending_expiration" - CustomHostnameEditResponseSSLStatusExpired CustomHostnameEditResponseSSLStatus = "expired" - CustomHostnameEditResponseSSLStatusActive CustomHostnameEditResponseSSLStatus = "active" - CustomHostnameEditResponseSSLStatusInitializingTimedOut CustomHostnameEditResponseSSLStatus = "initializing_timed_out" - CustomHostnameEditResponseSSLStatusValidationTimedOut CustomHostnameEditResponseSSLStatus = "validation_timed_out" - CustomHostnameEditResponseSSLStatusIssuanceTimedOut CustomHostnameEditResponseSSLStatus = "issuance_timed_out" - CustomHostnameEditResponseSSLStatusDeploymentTimedOut CustomHostnameEditResponseSSLStatus = "deployment_timed_out" - CustomHostnameEditResponseSSLStatusDeletionTimedOut CustomHostnameEditResponseSSLStatus = "deletion_timed_out" - CustomHostnameEditResponseSSLStatusPendingCleanup CustomHostnameEditResponseSSLStatus = "pending_cleanup" - CustomHostnameEditResponseSSLStatusStagingDeployment CustomHostnameEditResponseSSLStatus = "staging_deployment" - CustomHostnameEditResponseSSLStatusStagingActive CustomHostnameEditResponseSSLStatus = "staging_active" - CustomHostnameEditResponseSSLStatusDeactivating CustomHostnameEditResponseSSLStatus = "deactivating" - CustomHostnameEditResponseSSLStatusInactive CustomHostnameEditResponseSSLStatus = "inactive" - CustomHostnameEditResponseSSLStatusBackupIssued CustomHostnameEditResponseSSLStatus = "backup_issued" - CustomHostnameEditResponseSSLStatusHoldingDeployment CustomHostnameEditResponseSSLStatus = "holding_deployment" -) - -func (r CustomHostnameEditResponseSSLStatus) IsKnown() bool { - switch r { - case CustomHostnameEditResponseSSLStatusInitializing, CustomHostnameEditResponseSSLStatusPendingValidation, CustomHostnameEditResponseSSLStatusDeleted, CustomHostnameEditResponseSSLStatusPendingIssuance, CustomHostnameEditResponseSSLStatusPendingDeployment, CustomHostnameEditResponseSSLStatusPendingDeletion, CustomHostnameEditResponseSSLStatusPendingExpiration, CustomHostnameEditResponseSSLStatusExpired, CustomHostnameEditResponseSSLStatusActive, CustomHostnameEditResponseSSLStatusInitializingTimedOut, CustomHostnameEditResponseSSLStatusValidationTimedOut, CustomHostnameEditResponseSSLStatusIssuanceTimedOut, CustomHostnameEditResponseSSLStatusDeploymentTimedOut, CustomHostnameEditResponseSSLStatusDeletionTimedOut, CustomHostnameEditResponseSSLStatusPendingCleanup, CustomHostnameEditResponseSSLStatusStagingDeployment, CustomHostnameEditResponseSSLStatusStagingActive, CustomHostnameEditResponseSSLStatusDeactivating, CustomHostnameEditResponseSSLStatusInactive, CustomHostnameEditResponseSSLStatusBackupIssued, CustomHostnameEditResponseSSLStatusHoldingDeployment: - return true - } - return false -} - -type CustomHostnameEditResponseSSLValidationError struct { - // A domain validation error. - Message string `json:"message"` - JSON customHostnameEditResponseSSLValidationErrorJSON `json:"-"` -} - -// customHostnameEditResponseSSLValidationErrorJSON contains the JSON metadata for -// the struct [CustomHostnameEditResponseSSLValidationError] -type customHostnameEditResponseSSLValidationErrorJSON struct { - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomHostnameEditResponseSSLValidationError) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customHostnameEditResponseSSLValidationErrorJSON) RawJSON() string { - return r.raw -} - -// Certificate's required validation record. -type CustomHostnameEditResponseSSLValidationRecord struct { - // The set of email addresses that the certificate authority (CA) will use to - // complete domain validation. - Emails []interface{} `json:"emails"` - // The content that the certificate authority (CA) will expect to find at the - // http_url during the domain validation. - HTTPBody string `json:"http_body"` - // The url that will be checked during domain validation. - HTTPURL string `json:"http_url"` - // The hostname that the certificate authority (CA) will check for a TXT record - // during domain validation . - TXTName string `json:"txt_name"` - // The TXT record that the certificate authority (CA) will check during domain - // validation. - TXTValue string `json:"txt_value"` - JSON customHostnameEditResponseSSLValidationRecordJSON `json:"-"` -} - -// customHostnameEditResponseSSLValidationRecordJSON contains the JSON metadata for -// the struct [CustomHostnameEditResponseSSLValidationRecord] -type customHostnameEditResponseSSLValidationRecordJSON struct { - Emails apijson.Field - HTTPBody apijson.Field - HTTPURL apijson.Field - TXTName apijson.Field - TXTValue apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomHostnameEditResponseSSLValidationRecord) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customHostnameEditResponseSSLValidationRecordJSON) RawJSON() string { - return r.raw -} - -type CustomHostnameGetResponse struct { - // Identifier - ID string `json:"id,required"` - // The custom hostname that will point to your hostname via CNAME. - Hostname string `json:"hostname,required"` - // SSL properties for the custom hostname. - SSL CustomHostnameGetResponseSSL `json:"ssl,required"` - JSON customHostnameGetResponseJSON `json:"-"` +type CustomHostnameGetResponse struct { + // Identifier + ID string `json:"id,required"` + // The custom hostname that will point to your hostname via CNAME. + Hostname string `json:"hostname,required"` + // SSL properties for the custom hostname. + SSL SSL `json:"ssl,required"` + JSON customHostnameGetResponseJSON `json:"-"` } // customHostnameGetResponseJSON contains the JSON metadata for the struct @@ -1170,302 +576,6 @@ func (r customHostnameGetResponseJSON) RawJSON() string { return r.raw } -// SSL properties for the custom hostname. -type CustomHostnameGetResponseSSL struct { - // Custom hostname SSL identifier tag. - ID string `json:"id"` - // A ubiquitous bundle has the highest probability of being verified everywhere, - // even by clients using outdated or unusual trust stores. An optimal bundle uses - // the shortest chain and newest intermediates. And the force bundle verifies the - // chain, but does not otherwise modify it. - BundleMethod UnnamedSchemaRef16aca57bde2963201c7e6e895436c1c1 `json:"bundle_method"` - // The Certificate Authority that will issue the certificate - CertificateAuthority CustomHostnameGetResponseSSLCertificateAuthority `json:"certificate_authority"` - // If a custom uploaded certificate is used. - CustomCertificate string `json:"custom_certificate"` - // The identifier for the Custom CSR that was used. - CustomCsrID string `json:"custom_csr_id"` - // The key for a custom uploaded certificate. - CustomKey string `json:"custom_key"` - // The time the custom certificate expires on. - ExpiresOn time.Time `json:"expires_on" format:"date-time"` - // A list of Hostnames on a custom uploaded certificate. - Hosts []interface{} `json:"hosts"` - // The issuer on a custom uploaded certificate. - Issuer string `json:"issuer"` - // Domain control validation (DCV) method used for this hostname. - Method UnnamedSchemaRef78adb375f06c6d462dd92b99e2ecf510 `json:"method"` - // The serial number on a custom uploaded certificate. - SerialNumber string `json:"serial_number"` - // SSL specific settings. - Settings CustomHostnameGetResponseSSLSettings `json:"settings"` - // The signature on a custom uploaded certificate. - Signature string `json:"signature"` - // Status of the hostname's SSL certificates. - Status CustomHostnameGetResponseSSLStatus `json:"status"` - // Level of validation to be used for this hostname. Domain validation (dv) must be - // used. - Type UnnamedSchemaRef9a9935a9a770967bb604ae41a81e42e1 `json:"type"` - // The time the custom certificate was uploaded. - UploadedOn time.Time `json:"uploaded_on" format:"date-time"` - // Domain validation errors that have been received by the certificate authority - // (CA). - ValidationErrors []CustomHostnameGetResponseSSLValidationError `json:"validation_errors"` - ValidationRecords []CustomHostnameGetResponseSSLValidationRecord `json:"validation_records"` - // Indicates whether the certificate covers a wildcard. - Wildcard bool `json:"wildcard"` - JSON customHostnameGetResponseSSLJSON `json:"-"` -} - -// customHostnameGetResponseSSLJSON contains the JSON metadata for the struct -// [CustomHostnameGetResponseSSL] -type customHostnameGetResponseSSLJSON struct { - ID apijson.Field - BundleMethod apijson.Field - CertificateAuthority apijson.Field - CustomCertificate apijson.Field - CustomCsrID apijson.Field - CustomKey apijson.Field - ExpiresOn apijson.Field - Hosts apijson.Field - Issuer apijson.Field - Method apijson.Field - SerialNumber apijson.Field - Settings apijson.Field - Signature apijson.Field - Status apijson.Field - Type apijson.Field - UploadedOn apijson.Field - ValidationErrors apijson.Field - ValidationRecords apijson.Field - Wildcard apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomHostnameGetResponseSSL) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customHostnameGetResponseSSLJSON) RawJSON() string { - return r.raw -} - -// The Certificate Authority that will issue the certificate -type CustomHostnameGetResponseSSLCertificateAuthority string - -const ( - CustomHostnameGetResponseSSLCertificateAuthorityDigicert CustomHostnameGetResponseSSLCertificateAuthority = "digicert" - CustomHostnameGetResponseSSLCertificateAuthorityGoogle CustomHostnameGetResponseSSLCertificateAuthority = "google" - CustomHostnameGetResponseSSLCertificateAuthorityLetsEncrypt CustomHostnameGetResponseSSLCertificateAuthority = "lets_encrypt" -) - -func (r CustomHostnameGetResponseSSLCertificateAuthority) IsKnown() bool { - switch r { - case CustomHostnameGetResponseSSLCertificateAuthorityDigicert, CustomHostnameGetResponseSSLCertificateAuthorityGoogle, CustomHostnameGetResponseSSLCertificateAuthorityLetsEncrypt: - return true - } - return false -} - -// SSL specific settings. -type CustomHostnameGetResponseSSLSettings struct { - // An allowlist of ciphers for TLS termination. These ciphers must be in the - // BoringSSL format. - Ciphers []string `json:"ciphers"` - // Whether or not Early Hints is enabled. - EarlyHints CustomHostnameGetResponseSSLSettingsEarlyHints `json:"early_hints"` - // Whether or not HTTP2 is enabled. - HTTP2 CustomHostnameGetResponseSSLSettingsHTTP2 `json:"http2"` - // The minimum TLS version supported. - MinTLSVersion CustomHostnameGetResponseSSLSettingsMinTLSVersion `json:"min_tls_version"` - // Whether or not TLS 1.3 is enabled. - TLS1_3 CustomHostnameGetResponseSSLSettingsTLS1_3 `json:"tls_1_3"` - JSON customHostnameGetResponseSSLSettingsJSON `json:"-"` -} - -// customHostnameGetResponseSSLSettingsJSON contains the JSON metadata for the -// struct [CustomHostnameGetResponseSSLSettings] -type customHostnameGetResponseSSLSettingsJSON struct { - Ciphers apijson.Field - EarlyHints apijson.Field - HTTP2 apijson.Field - MinTLSVersion apijson.Field - TLS1_3 apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomHostnameGetResponseSSLSettings) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customHostnameGetResponseSSLSettingsJSON) RawJSON() string { - return r.raw -} - -// Whether or not Early Hints is enabled. -type CustomHostnameGetResponseSSLSettingsEarlyHints string - -const ( - CustomHostnameGetResponseSSLSettingsEarlyHintsOn CustomHostnameGetResponseSSLSettingsEarlyHints = "on" - CustomHostnameGetResponseSSLSettingsEarlyHintsOff CustomHostnameGetResponseSSLSettingsEarlyHints = "off" -) - -func (r CustomHostnameGetResponseSSLSettingsEarlyHints) IsKnown() bool { - switch r { - case CustomHostnameGetResponseSSLSettingsEarlyHintsOn, CustomHostnameGetResponseSSLSettingsEarlyHintsOff: - return true - } - return false -} - -// Whether or not HTTP2 is enabled. -type CustomHostnameGetResponseSSLSettingsHTTP2 string - -const ( - CustomHostnameGetResponseSSLSettingsHTTP2On CustomHostnameGetResponseSSLSettingsHTTP2 = "on" - CustomHostnameGetResponseSSLSettingsHTTP2Off CustomHostnameGetResponseSSLSettingsHTTP2 = "off" -) - -func (r CustomHostnameGetResponseSSLSettingsHTTP2) IsKnown() bool { - switch r { - case CustomHostnameGetResponseSSLSettingsHTTP2On, CustomHostnameGetResponseSSLSettingsHTTP2Off: - return true - } - return false -} - -// The minimum TLS version supported. -type CustomHostnameGetResponseSSLSettingsMinTLSVersion string - -const ( - CustomHostnameGetResponseSSLSettingsMinTLSVersion1_0 CustomHostnameGetResponseSSLSettingsMinTLSVersion = "1.0" - CustomHostnameGetResponseSSLSettingsMinTLSVersion1_1 CustomHostnameGetResponseSSLSettingsMinTLSVersion = "1.1" - CustomHostnameGetResponseSSLSettingsMinTLSVersion1_2 CustomHostnameGetResponseSSLSettingsMinTLSVersion = "1.2" - CustomHostnameGetResponseSSLSettingsMinTLSVersion1_3 CustomHostnameGetResponseSSLSettingsMinTLSVersion = "1.3" -) - -func (r CustomHostnameGetResponseSSLSettingsMinTLSVersion) IsKnown() bool { - switch r { - case CustomHostnameGetResponseSSLSettingsMinTLSVersion1_0, CustomHostnameGetResponseSSLSettingsMinTLSVersion1_1, CustomHostnameGetResponseSSLSettingsMinTLSVersion1_2, CustomHostnameGetResponseSSLSettingsMinTLSVersion1_3: - return true - } - return false -} - -// Whether or not TLS 1.3 is enabled. -type CustomHostnameGetResponseSSLSettingsTLS1_3 string - -const ( - CustomHostnameGetResponseSSLSettingsTLS1_3On CustomHostnameGetResponseSSLSettingsTLS1_3 = "on" - CustomHostnameGetResponseSSLSettingsTLS1_3Off CustomHostnameGetResponseSSLSettingsTLS1_3 = "off" -) - -func (r CustomHostnameGetResponseSSLSettingsTLS1_3) IsKnown() bool { - switch r { - case CustomHostnameGetResponseSSLSettingsTLS1_3On, CustomHostnameGetResponseSSLSettingsTLS1_3Off: - return true - } - return false -} - -// Status of the hostname's SSL certificates. -type CustomHostnameGetResponseSSLStatus string - -const ( - CustomHostnameGetResponseSSLStatusInitializing CustomHostnameGetResponseSSLStatus = "initializing" - CustomHostnameGetResponseSSLStatusPendingValidation CustomHostnameGetResponseSSLStatus = "pending_validation" - CustomHostnameGetResponseSSLStatusDeleted CustomHostnameGetResponseSSLStatus = "deleted" - CustomHostnameGetResponseSSLStatusPendingIssuance CustomHostnameGetResponseSSLStatus = "pending_issuance" - CustomHostnameGetResponseSSLStatusPendingDeployment CustomHostnameGetResponseSSLStatus = "pending_deployment" - CustomHostnameGetResponseSSLStatusPendingDeletion CustomHostnameGetResponseSSLStatus = "pending_deletion" - CustomHostnameGetResponseSSLStatusPendingExpiration CustomHostnameGetResponseSSLStatus = "pending_expiration" - CustomHostnameGetResponseSSLStatusExpired CustomHostnameGetResponseSSLStatus = "expired" - CustomHostnameGetResponseSSLStatusActive CustomHostnameGetResponseSSLStatus = "active" - CustomHostnameGetResponseSSLStatusInitializingTimedOut CustomHostnameGetResponseSSLStatus = "initializing_timed_out" - CustomHostnameGetResponseSSLStatusValidationTimedOut CustomHostnameGetResponseSSLStatus = "validation_timed_out" - CustomHostnameGetResponseSSLStatusIssuanceTimedOut CustomHostnameGetResponseSSLStatus = "issuance_timed_out" - CustomHostnameGetResponseSSLStatusDeploymentTimedOut CustomHostnameGetResponseSSLStatus = "deployment_timed_out" - CustomHostnameGetResponseSSLStatusDeletionTimedOut CustomHostnameGetResponseSSLStatus = "deletion_timed_out" - CustomHostnameGetResponseSSLStatusPendingCleanup CustomHostnameGetResponseSSLStatus = "pending_cleanup" - CustomHostnameGetResponseSSLStatusStagingDeployment CustomHostnameGetResponseSSLStatus = "staging_deployment" - CustomHostnameGetResponseSSLStatusStagingActive CustomHostnameGetResponseSSLStatus = "staging_active" - CustomHostnameGetResponseSSLStatusDeactivating CustomHostnameGetResponseSSLStatus = "deactivating" - CustomHostnameGetResponseSSLStatusInactive CustomHostnameGetResponseSSLStatus = "inactive" - CustomHostnameGetResponseSSLStatusBackupIssued CustomHostnameGetResponseSSLStatus = "backup_issued" - CustomHostnameGetResponseSSLStatusHoldingDeployment CustomHostnameGetResponseSSLStatus = "holding_deployment" -) - -func (r CustomHostnameGetResponseSSLStatus) IsKnown() bool { - switch r { - case CustomHostnameGetResponseSSLStatusInitializing, CustomHostnameGetResponseSSLStatusPendingValidation, CustomHostnameGetResponseSSLStatusDeleted, CustomHostnameGetResponseSSLStatusPendingIssuance, CustomHostnameGetResponseSSLStatusPendingDeployment, CustomHostnameGetResponseSSLStatusPendingDeletion, CustomHostnameGetResponseSSLStatusPendingExpiration, CustomHostnameGetResponseSSLStatusExpired, CustomHostnameGetResponseSSLStatusActive, CustomHostnameGetResponseSSLStatusInitializingTimedOut, CustomHostnameGetResponseSSLStatusValidationTimedOut, CustomHostnameGetResponseSSLStatusIssuanceTimedOut, CustomHostnameGetResponseSSLStatusDeploymentTimedOut, CustomHostnameGetResponseSSLStatusDeletionTimedOut, CustomHostnameGetResponseSSLStatusPendingCleanup, CustomHostnameGetResponseSSLStatusStagingDeployment, CustomHostnameGetResponseSSLStatusStagingActive, CustomHostnameGetResponseSSLStatusDeactivating, CustomHostnameGetResponseSSLStatusInactive, CustomHostnameGetResponseSSLStatusBackupIssued, CustomHostnameGetResponseSSLStatusHoldingDeployment: - return true - } - return false -} - -type CustomHostnameGetResponseSSLValidationError struct { - // A domain validation error. - Message string `json:"message"` - JSON customHostnameGetResponseSSLValidationErrorJSON `json:"-"` -} - -// customHostnameGetResponseSSLValidationErrorJSON contains the JSON metadata for -// the struct [CustomHostnameGetResponseSSLValidationError] -type customHostnameGetResponseSSLValidationErrorJSON struct { - Message apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomHostnameGetResponseSSLValidationError) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customHostnameGetResponseSSLValidationErrorJSON) RawJSON() string { - return r.raw -} - -// Certificate's required validation record. -type CustomHostnameGetResponseSSLValidationRecord struct { - // The set of email addresses that the certificate authority (CA) will use to - // complete domain validation. - Emails []interface{} `json:"emails"` - // The content that the certificate authority (CA) will expect to find at the - // http_url during the domain validation. - HTTPBody string `json:"http_body"` - // The url that will be checked during domain validation. - HTTPURL string `json:"http_url"` - // The hostname that the certificate authority (CA) will check for a TXT record - // during domain validation . - TXTName string `json:"txt_name"` - // The TXT record that the certificate authority (CA) will check during domain - // validation. - TXTValue string `json:"txt_value"` - JSON customHostnameGetResponseSSLValidationRecordJSON `json:"-"` -} - -// customHostnameGetResponseSSLValidationRecordJSON contains the JSON metadata for -// the struct [CustomHostnameGetResponseSSLValidationRecord] -type customHostnameGetResponseSSLValidationRecordJSON struct { - Emails apijson.Field - HTTPBody apijson.Field - HTTPURL apijson.Field - TXTName apijson.Field - TXTValue apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *CustomHostnameGetResponseSSLValidationRecord) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r customHostnameGetResponseSSLValidationRecordJSON) RawJSON() string { - return r.raw -} - type CustomHostnameNewParams struct { // Identifier ZoneID param.Field[string] `path:"zone_id,required"` diff --git a/dns/firewall.go b/dns/firewall.go index f4b12fae277..c445e5141d1 100644 --- a/dns/firewall.go +++ b/dns/firewall.go @@ -114,6 +114,46 @@ func (r *FirewallService) Get(ctx context.Context, dnsFirewallID string, query F return } +// Attack mitigation settings. +type AttackMitigation struct { + // When enabled, random-prefix attacks are automatically mitigated and the upstream + // DNS servers protected. + Enabled bool `json:"enabled"` + // Only mitigate attacks when upstream servers seem unhealthy. + OnlyWhenUpstreamUnhealthy bool `json:"only_when_upstream_unhealthy"` + JSON attackMitigationJSON `json:"-"` +} + +// attackMitigationJSON contains the JSON metadata for the struct +// [AttackMitigation] +type attackMitigationJSON struct { + Enabled apijson.Field + OnlyWhenUpstreamUnhealthy apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *AttackMitigation) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r attackMitigationJSON) RawJSON() string { + return r.raw +} + +// Attack mitigation settings. +type AttackMitigationParam struct { + // When enabled, random-prefix attacks are automatically mitigated and the upstream + // DNS servers protected. + Enabled param.Field[bool] `json:"enabled"` + // Only mitigate attacks when upstream servers seem unhealthy. + OnlyWhenUpstreamUnhealthy param.Field[bool] `json:"only_when_upstream_unhealthy"` +} + +func (r AttackMitigationParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + type DNSFirewall struct { // Identifier ID string `json:"id,required"` @@ -132,7 +172,7 @@ type DNSFirewall struct { Name string `json:"name,required"` UpstreamIPs []DNSFirewallUpstreamIPsUnion `json:"upstream_ips,required" format:"ipv4"` // Attack mitigation settings. - AttackMitigation DNSFirewallAttackMitigation `json:"attack_mitigation,nullable"` + AttackMitigation AttackMitigation `json:"attack_mitigation,nullable"` // Negative DNS Cache TTL. NegativeCacheTTL float64 `json:"negative_cache_ttl,nullable"` // Ratelimit in queries per second per datacenter (applies to DNS queries sent to @@ -215,31 +255,62 @@ func init() { ) } -// Attack mitigation settings. -type DNSFirewallAttackMitigation struct { - // When enabled, random-prefix attacks are automatically mitigated and the upstream - // DNS servers protected. - Enabled bool `json:"enabled"` - // Only mitigate attacks when upstream servers seem unhealthy. - OnlyWhenUpstreamUnhealthy bool `json:"only_when_upstream_unhealthy"` - JSON dnsFirewallAttackMitigationJSON `json:"-"` +// Cloudflare-assigned DNS IPv4 Address. +// +// Union satisfied by [shared.UnionString] or [shared.UnionString]. +type FirewallIPsItemUnion interface { + ImplementsDNSFirewallIPsItemUnion() } -// dnsFirewallAttackMitigationJSON contains the JSON metadata for the struct -// [DNSFirewallAttackMitigation] -type dnsFirewallAttackMitigationJSON struct { - Enabled apijson.Field - OnlyWhenUpstreamUnhealthy apijson.Field - raw string - ExtraFields map[string]apijson.Field +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*FirewallIPsItemUnion)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) } -func (r *DNSFirewallAttackMitigation) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) +// Cloudflare-assigned DNS IPv4 Address. +// +// Satisfied by [shared.UnionString], [shared.UnionString]. +type FirewallIPsItemUnionParam interface { + ImplementsDNSFirewallIPsItemUnionParam() } -func (r dnsFirewallAttackMitigationJSON) RawJSON() string { - return r.raw +// Upstream DNS Server IPv4 Address. +// +// Union satisfied by [shared.UnionString] or [shared.UnionString]. +type UpstreamIPsItemsUnion interface { + ImplementsDNSUpstreamIPsItemsUnion() +} + +func init() { + apijson.RegisterUnion( + reflect.TypeOf((*UpstreamIPsItemsUnion)(nil)).Elem(), + "", + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + apijson.UnionVariant{ + TypeFilter: gjson.String, + Type: reflect.TypeOf(shared.UnionString("")), + }, + ) +} + +// Upstream DNS Server IPv4 Address. +// +// Satisfied by [shared.UnionString], [shared.UnionString]. +type UpstreamIPsItemsUnionParam interface { + ImplementsDNSUpstreamIPsItemsUnionParam() } type FirewallDeleteResponse struct { @@ -268,10 +339,10 @@ type FirewallNewParams struct { // Identifier AccountID param.Field[string] `path:"account_id,required"` // DNS Firewall Cluster Name. - Name param.Field[string] `json:"name,required"` - UpstreamIPs param.Field[[]FirewallNewParamsUpstreamIPUnion] `json:"upstream_ips,required" format:"ipv4"` + Name param.Field[string] `json:"name,required"` + UpstreamIPs param.Field[[]UpstreamIPsItemsUnionParam] `json:"upstream_ips,required" format:"ipv4"` // Attack mitigation settings. - AttackMitigation param.Field[FirewallNewParamsAttackMitigation] `json:"attack_mitigation"` + AttackMitigation param.Field[AttackMitigationParam] `json:"attack_mitigation"` // Deprecate the response to ANY requests. DeprecateAnyRequests param.Field[bool] `json:"deprecate_any_requests"` // Forward client IP (resolver) subnet if no EDNS Client Subnet is sent. @@ -294,26 +365,6 @@ func (r FirewallNewParams) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -// Upstream DNS Server IPv4 Address. -// -// Satisfied by [shared.UnionString], [shared.UnionString]. -type FirewallNewParamsUpstreamIPUnion interface { - ImplementsDNSFirewallNewParamsUpstreamIPUnion() -} - -// Attack mitigation settings. -type FirewallNewParamsAttackMitigation struct { - // When enabled, random-prefix attacks are automatically mitigated and the upstream - // DNS servers protected. - Enabled param.Field[bool] `json:"enabled"` - // Only mitigate attacks when upstream servers seem unhealthy. - OnlyWhenUpstreamUnhealthy param.Field[bool] `json:"only_when_upstream_unhealthy"` -} - -func (r FirewallNewParamsAttackMitigation) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - type FirewallNewResponseEnvelope struct { Errors []shared.UnnamedSchemaRef3248f24329456e19dfa042fff9986f72 `json:"errors,required"` Messages []shared.UnnamedSchemaRef3248f24329456e19dfa042fff9986f72 `json:"messages,required"` @@ -431,8 +482,8 @@ type FirewallEditParams struct { // Identifier AccountID param.Field[string] `path:"account_id,required"` // Deprecate the response to ANY requests. - DeprecateAnyRequests param.Field[bool] `json:"deprecate_any_requests,required"` - DNSFirewallIPs param.Field[[]FirewallEditParamsDNSFirewallIPUnion] `json:"dns_firewall_ips,required" format:"ipv4"` + DeprecateAnyRequests param.Field[bool] `json:"deprecate_any_requests,required"` + DNSFirewallIPs param.Field[[]FirewallIPsItemUnionParam] `json:"dns_firewall_ips,required" format:"ipv4"` // Forward client IP (resolver) subnet if no EDNS Client Subnet is sent. EcsFallback param.Field[bool] `json:"ecs_fallback,required"` // Maximum DNS Cache TTL. @@ -440,10 +491,10 @@ type FirewallEditParams struct { // Minimum DNS Cache TTL. MinimumCacheTTL param.Field[float64] `json:"minimum_cache_ttl,required"` // DNS Firewall Cluster Name. - Name param.Field[string] `json:"name,required"` - UpstreamIPs param.Field[[]FirewallEditParamsUpstreamIPUnion] `json:"upstream_ips,required" format:"ipv4"` + Name param.Field[string] `json:"name,required"` + UpstreamIPs param.Field[[]UpstreamIPsItemsUnionParam] `json:"upstream_ips,required" format:"ipv4"` // Attack mitigation settings. - AttackMitigation param.Field[FirewallEditParamsAttackMitigation] `json:"attack_mitigation"` + AttackMitigation param.Field[AttackMitigationParam] `json:"attack_mitigation"` // Negative DNS Cache TTL. NegativeCacheTTL param.Field[float64] `json:"negative_cache_ttl"` // Ratelimit in queries per second per datacenter (applies to DNS queries sent to @@ -458,33 +509,6 @@ func (r FirewallEditParams) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -// Cloudflare-assigned DNS IPv4 Address. -// -// Satisfied by [shared.UnionString], [shared.UnionString]. -type FirewallEditParamsDNSFirewallIPUnion interface { - ImplementsDNSFirewallEditParamsDNSFirewallIPUnion() -} - -// Upstream DNS Server IPv4 Address. -// -// Satisfied by [shared.UnionString], [shared.UnionString]. -type FirewallEditParamsUpstreamIPUnion interface { - ImplementsDNSFirewallEditParamsUpstreamIPUnion() -} - -// Attack mitigation settings. -type FirewallEditParamsAttackMitigation struct { - // When enabled, random-prefix attacks are automatically mitigated and the upstream - // DNS servers protected. - Enabled param.Field[bool] `json:"enabled"` - // Only mitigate attacks when upstream servers seem unhealthy. - OnlyWhenUpstreamUnhealthy param.Field[bool] `json:"only_when_upstream_unhealthy"` -} - -func (r FirewallEditParamsAttackMitigation) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - type FirewallEditResponseEnvelope struct { Errors []shared.UnnamedSchemaRef3248f24329456e19dfa042fff9986f72 `json:"errors,required"` Messages []shared.UnnamedSchemaRef3248f24329456e19dfa042fff9986f72 `json:"messages,required"` diff --git a/dns/firewall_test.go b/dns/firewall_test.go index eb0816fcf20..ed55996aa41 100644 --- a/dns/firewall_test.go +++ b/dns/firewall_test.go @@ -32,8 +32,8 @@ func TestFirewallNewWithOptionalParams(t *testing.T) { _, err := client.DNS.Firewall.New(context.TODO(), dns.FirewallNewParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Name: cloudflare.F("My Awesome DNS Firewall cluster"), - UpstreamIPs: cloudflare.F([]dns.FirewallNewParamsUpstreamIPUnion{shared.UnionString("192.0.2.1"), shared.UnionString("198.51.100.1"), shared.UnionString("2001:DB8:100::CF")}), - AttackMitigation: cloudflare.F(dns.FirewallNewParamsAttackMitigation{ + UpstreamIPs: cloudflare.F([]dns.UpstreamIPsItemsUnionParam{shared.UnionString("192.0.2.1"), shared.UnionString("198.51.100.1"), shared.UnionString("2001:DB8:100::CF")}), + AttackMitigation: cloudflare.F(dns.AttackMitigationParam{ Enabled: cloudflare.F(true), OnlyWhenUpstreamUnhealthy: cloudflare.F(false), }), @@ -133,13 +133,13 @@ func TestFirewallEditWithOptionalParams(t *testing.T) { dns.FirewallEditParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), DeprecateAnyRequests: cloudflare.F(true), - DNSFirewallIPs: cloudflare.F([]dns.FirewallEditParamsDNSFirewallIPUnion{shared.UnionString("203.0.113.1"), shared.UnionString("203.0.113.254"), shared.UnionString("2001:DB8:AB::CF"), shared.UnionString("2001:DB8:CD::CF")}), + DNSFirewallIPs: cloudflare.F([]dns.FirewallIPsItemUnionParam{shared.UnionString("203.0.113.1"), shared.UnionString("203.0.113.254"), shared.UnionString("2001:DB8:AB::CF"), shared.UnionString("2001:DB8:CD::CF")}), EcsFallback: cloudflare.F(false), MaximumCacheTTL: cloudflare.F(900.000000), MinimumCacheTTL: cloudflare.F(60.000000), Name: cloudflare.F("My Awesome DNS Firewall cluster"), - UpstreamIPs: cloudflare.F([]dns.FirewallEditParamsUpstreamIPUnion{shared.UnionString("192.0.2.1"), shared.UnionString("198.51.100.1"), shared.UnionString("2001:DB8:100::CF")}), - AttackMitigation: cloudflare.F(dns.FirewallEditParamsAttackMitigation{ + UpstreamIPs: cloudflare.F([]dns.UpstreamIPsItemsUnionParam{shared.UnionString("192.0.2.1"), shared.UnionString("198.51.100.1"), shared.UnionString("2001:DB8:100::CF")}), + AttackMitigation: cloudflare.F(dns.AttackMitigationParam{ Enabled: cloudflare.F(true), OnlyWhenUpstreamUnhealthy: cloudflare.F(false), }), diff --git a/email_routing/address.go b/email_routing/address.go index 47286a616b4..799f9125d4b 100644 --- a/email_routing/address.go +++ b/email_routing/address.go @@ -37,7 +37,7 @@ func NewAddressService(opts ...option.RequestOption) (r *AddressService) { // Create a destination address to forward your emails to. Destination addresses // need to be verified before they can be used. -func (r *AddressService) New(ctx context.Context, accountIdentifier string, body AddressNewParams, opts ...option.RequestOption) (res *AddressNewResponse, err error) { +func (r *AddressService) New(ctx context.Context, accountIdentifier string, body AddressNewParams, opts ...option.RequestOption) (res *DestinationAddress, err error) { opts = append(r.Options[:], opts...) var env AddressNewResponseEnvelope path := fmt.Sprintf("accounts/%s/email/routing/addresses", accountIdentifier) @@ -50,7 +50,7 @@ func (r *AddressService) New(ctx context.Context, accountIdentifier string, body } // Lists existing destination addresses. -func (r *AddressService) List(ctx context.Context, accountIdentifier string, query AddressListParams, opts ...option.RequestOption) (res *pagination.V4PagePaginationArray[AddressListResponse], err error) { +func (r *AddressService) List(ctx context.Context, accountIdentifier string, query AddressListParams, opts ...option.RequestOption) (res *pagination.V4PagePaginationArray[DestinationAddress], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -68,12 +68,12 @@ func (r *AddressService) List(ctx context.Context, accountIdentifier string, que } // Lists existing destination addresses. -func (r *AddressService) ListAutoPaging(ctx context.Context, accountIdentifier string, query AddressListParams, opts ...option.RequestOption) *pagination.V4PagePaginationArrayAutoPager[AddressListResponse] { +func (r *AddressService) ListAutoPaging(ctx context.Context, accountIdentifier string, query AddressListParams, opts ...option.RequestOption) *pagination.V4PagePaginationArrayAutoPager[DestinationAddress] { return pagination.NewV4PagePaginationArrayAutoPager(r.List(ctx, accountIdentifier, query, opts...)) } // Deletes a specific destination address. -func (r *AddressService) Delete(ctx context.Context, accountIdentifier string, destinationAddressIdentifier string, opts ...option.RequestOption) (res *AddressDeleteResponse, err error) { +func (r *AddressService) Delete(ctx context.Context, accountIdentifier string, destinationAddressIdentifier string, opts ...option.RequestOption) (res *DestinationAddress, err error) { opts = append(r.Options[:], opts...) var env AddressDeleteResponseEnvelope path := fmt.Sprintf("accounts/%s/email/routing/addresses/%s", accountIdentifier, destinationAddressIdentifier) @@ -86,7 +86,7 @@ func (r *AddressService) Delete(ctx context.Context, accountIdentifier string, d } // Gets information for a specific destination email already created. -func (r *AddressService) Get(ctx context.Context, accountIdentifier string, destinationAddressIdentifier string, opts ...option.RequestOption) (res *AddressGetResponse, err error) { +func (r *AddressService) Get(ctx context.Context, accountIdentifier string, destinationAddressIdentifier string, opts ...option.RequestOption) (res *DestinationAddress, err error) { opts = append(r.Options[:], opts...) var env AddressGetResponseEnvelope path := fmt.Sprintf("accounts/%s/email/routing/addresses/%s", accountIdentifier, destinationAddressIdentifier) @@ -98,7 +98,7 @@ func (r *AddressService) Get(ctx context.Context, accountIdentifier string, dest return } -type AddressNewResponse struct { +type DestinationAddress struct { // Destination address identifier. ID string `json:"id"` // The date and time the destination address has been created. @@ -113,12 +113,12 @@ type AddressNewResponse struct { // The date and time the destination address has been verified. Null means not // verified yet. Verified time.Time `json:"verified" format:"date-time"` - JSON addressNewResponseJSON `json:"-"` + JSON destinationAddressJSON `json:"-"` } -// addressNewResponseJSON contains the JSON metadata for the struct -// [AddressNewResponse] -type addressNewResponseJSON struct { +// destinationAddressJSON contains the JSON metadata for the struct +// [DestinationAddress] +type destinationAddressJSON struct { ID apijson.Field Created apijson.Field Email apijson.Field @@ -129,128 +129,11 @@ type addressNewResponseJSON struct { ExtraFields map[string]apijson.Field } -func (r *AddressNewResponse) UnmarshalJSON(data []byte) (err error) { +func (r *DestinationAddress) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r addressNewResponseJSON) RawJSON() string { - return r.raw -} - -type AddressListResponse struct { - // Destination address identifier. - ID string `json:"id"` - // The date and time the destination address has been created. - Created time.Time `json:"created" format:"date-time"` - // The contact email address of the user. - Email string `json:"email"` - // The date and time the destination address was last modified. - Modified time.Time `json:"modified" format:"date-time"` - // Destination address tag. (Deprecated, replaced by destination address - // identifier) - Tag string `json:"tag"` - // The date and time the destination address has been verified. Null means not - // verified yet. - Verified time.Time `json:"verified" format:"date-time"` - JSON addressListResponseJSON `json:"-"` -} - -// addressListResponseJSON contains the JSON metadata for the struct -// [AddressListResponse] -type addressListResponseJSON struct { - ID apijson.Field - Created apijson.Field - Email apijson.Field - Modified apijson.Field - Tag apijson.Field - Verified apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressListResponseJSON) RawJSON() string { - return r.raw -} - -type AddressDeleteResponse struct { - // Destination address identifier. - ID string `json:"id"` - // The date and time the destination address has been created. - Created time.Time `json:"created" format:"date-time"` - // The contact email address of the user. - Email string `json:"email"` - // The date and time the destination address was last modified. - Modified time.Time `json:"modified" format:"date-time"` - // Destination address tag. (Deprecated, replaced by destination address - // identifier) - Tag string `json:"tag"` - // The date and time the destination address has been verified. Null means not - // verified yet. - Verified time.Time `json:"verified" format:"date-time"` - JSON addressDeleteResponseJSON `json:"-"` -} - -// addressDeleteResponseJSON contains the JSON metadata for the struct -// [AddressDeleteResponse] -type addressDeleteResponseJSON struct { - ID apijson.Field - Created apijson.Field - Email apijson.Field - Modified apijson.Field - Tag apijson.Field - Verified apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressDeleteResponseJSON) RawJSON() string { - return r.raw -} - -type AddressGetResponse struct { - // Destination address identifier. - ID string `json:"id"` - // The date and time the destination address has been created. - Created time.Time `json:"created" format:"date-time"` - // The contact email address of the user. - Email string `json:"email"` - // The date and time the destination address was last modified. - Modified time.Time `json:"modified" format:"date-time"` - // Destination address tag. (Deprecated, replaced by destination address - // identifier) - Tag string `json:"tag"` - // The date and time the destination address has been verified. Null means not - // verified yet. - Verified time.Time `json:"verified" format:"date-time"` - JSON addressGetResponseJSON `json:"-"` -} - -// addressGetResponseJSON contains the JSON metadata for the struct -// [AddressGetResponse] -type addressGetResponseJSON struct { - ID apijson.Field - Created apijson.Field - Email apijson.Field - Modified apijson.Field - Tag apijson.Field - Verified apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *AddressGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r addressGetResponseJSON) RawJSON() string { +func (r destinationAddressJSON) RawJSON() string { return r.raw } @@ -266,7 +149,7 @@ func (r AddressNewParams) MarshalJSON() (data []byte, err error) { type AddressNewResponseEnvelope struct { Errors []shared.UnnamedSchemaRef3248f24329456e19dfa042fff9986f72 `json:"errors,required"` Messages []shared.UnnamedSchemaRef3248f24329456e19dfa042fff9986f72 `json:"messages,required"` - Result AddressNewResponse `json:"result,required"` + Result DestinationAddress `json:"result,required"` // Whether the API call was successful Success AddressNewResponseEnvelopeSuccess `json:"success,required"` JSON addressNewResponseEnvelopeJSON `json:"-"` @@ -360,7 +243,7 @@ func (r AddressListParamsVerified) IsKnown() bool { type AddressDeleteResponseEnvelope struct { Errors []shared.UnnamedSchemaRef3248f24329456e19dfa042fff9986f72 `json:"errors,required"` Messages []shared.UnnamedSchemaRef3248f24329456e19dfa042fff9986f72 `json:"messages,required"` - Result AddressDeleteResponse `json:"result,required"` + Result DestinationAddress `json:"result,required"` // Whether the API call was successful Success AddressDeleteResponseEnvelopeSuccess `json:"success,required"` JSON addressDeleteResponseEnvelopeJSON `json:"-"` @@ -403,7 +286,7 @@ func (r AddressDeleteResponseEnvelopeSuccess) IsKnown() bool { type AddressGetResponseEnvelope struct { Errors []shared.UnnamedSchemaRef3248f24329456e19dfa042fff9986f72 `json:"errors,required"` Messages []shared.UnnamedSchemaRef3248f24329456e19dfa042fff9986f72 `json:"messages,required"` - Result AddressGetResponse `json:"result,required"` + Result DestinationAddress `json:"result,required"` // Whether the API call was successful Success AddressGetResponseEnvelopeSuccess `json:"success,required"` JSON addressGetResponseEnvelopeJSON `json:"-"` diff --git a/email_routing/emailrouting.go b/email_routing/emailrouting.go index 3a00456bfa3..6f789e2a22e 100644 --- a/email_routing/emailrouting.go +++ b/email_routing/emailrouting.go @@ -41,7 +41,7 @@ func NewEmailRoutingService(opts ...option.RequestOption) (r *EmailRoutingServic // Disable your Email Routing zone. Also removes additional MX records previously // required for Email Routing to work. -func (r *EmailRoutingService) Disable(ctx context.Context, zoneIdentifier string, body EmailRoutingDisableParams, opts ...option.RequestOption) (res *EmailRoutingDisableResponse, err error) { +func (r *EmailRoutingService) Disable(ctx context.Context, zoneIdentifier string, body EmailRoutingDisableParams, opts ...option.RequestOption) (res *EmailSettings, err error) { opts = append(r.Options[:], opts...) var env EmailRoutingDisableResponseEnvelope path := fmt.Sprintf("zones/%s/email/routing/disable", zoneIdentifier) @@ -54,7 +54,7 @@ func (r *EmailRoutingService) Disable(ctx context.Context, zoneIdentifier string } // Enable you Email Routing zone. Add and lock the necessary MX and SPF records. -func (r *EmailRoutingService) Enable(ctx context.Context, zoneIdentifier string, body EmailRoutingEnableParams, opts ...option.RequestOption) (res *EmailRoutingEnableResponse, err error) { +func (r *EmailRoutingService) Enable(ctx context.Context, zoneIdentifier string, body EmailRoutingEnableParams, opts ...option.RequestOption) (res *EmailSettings, err error) { opts = append(r.Options[:], opts...) var env EmailRoutingEnableResponseEnvelope path := fmt.Sprintf("zones/%s/email/routing/enable", zoneIdentifier) @@ -67,7 +67,7 @@ func (r *EmailRoutingService) Enable(ctx context.Context, zoneIdentifier string, } // Get information about the settings for your Email Routing zone. -func (r *EmailRoutingService) Get(ctx context.Context, zoneIdentifier string, opts ...option.RequestOption) (res *EmailRoutingGetResponse, err error) { +func (r *EmailRoutingService) Get(ctx context.Context, zoneIdentifier string, opts ...option.RequestOption) (res *EmailSettings, err error) { opts = append(r.Options[:], opts...) var env EmailRoutingGetResponseEnvelope path := fmt.Sprintf("zones/%s/email/routing", zoneIdentifier) @@ -79,30 +79,29 @@ func (r *EmailRoutingService) Get(ctx context.Context, zoneIdentifier string, op return } -type EmailRoutingDisableResponse struct { +type EmailSettings struct { // Email Routing settings identifier. ID string `json:"id"` // The date and time the settings have been created. Created time.Time `json:"created" format:"date-time"` // State of the zone settings for Email Routing. - Enabled EmailRoutingDisableResponseEnabled `json:"enabled"` + Enabled EmailSettingsEnabled `json:"enabled"` // The date and time the settings have been modified. Modified time.Time `json:"modified" format:"date-time"` // Domain of your zone. Name string `json:"name"` // Flag to check if the user skipped the configuration wizard. - SkipWizard EmailRoutingDisableResponseSkipWizard `json:"skip_wizard"` + SkipWizard EmailSettingsSkipWizard `json:"skip_wizard"` // Show the state of your account, and the type or configuration error. - Status EmailRoutingDisableResponseStatus `json:"status"` + Status EmailSettingsStatus `json:"status"` // Email Routing settings tag. (Deprecated, replaced by Email Routing settings // identifier) - Tag string `json:"tag"` - JSON emailRoutingDisableResponseJSON `json:"-"` + Tag string `json:"tag"` + JSON emailSettingsJSON `json:"-"` } -// emailRoutingDisableResponseJSON contains the JSON metadata for the struct -// [EmailRoutingDisableResponse] -type emailRoutingDisableResponseJSON struct { +// emailSettingsJSON contains the JSON metadata for the struct [EmailSettings] +type emailSettingsJSON struct { ID apijson.Field Created apijson.Field Enabled apijson.Field @@ -115,250 +114,60 @@ type emailRoutingDisableResponseJSON struct { ExtraFields map[string]apijson.Field } -func (r *EmailRoutingDisableResponse) UnmarshalJSON(data []byte) (err error) { +func (r *EmailSettings) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r emailRoutingDisableResponseJSON) RawJSON() string { +func (r emailSettingsJSON) RawJSON() string { return r.raw } // State of the zone settings for Email Routing. -type EmailRoutingDisableResponseEnabled bool +type EmailSettingsEnabled bool const ( - EmailRoutingDisableResponseEnabledTrue EmailRoutingDisableResponseEnabled = true - EmailRoutingDisableResponseEnabledFalse EmailRoutingDisableResponseEnabled = false + EmailSettingsEnabledTrue EmailSettingsEnabled = true + EmailSettingsEnabledFalse EmailSettingsEnabled = false ) -func (r EmailRoutingDisableResponseEnabled) IsKnown() bool { +func (r EmailSettingsEnabled) IsKnown() bool { switch r { - case EmailRoutingDisableResponseEnabledTrue, EmailRoutingDisableResponseEnabledFalse: + case EmailSettingsEnabledTrue, EmailSettingsEnabledFalse: return true } return false } // Flag to check if the user skipped the configuration wizard. -type EmailRoutingDisableResponseSkipWizard bool +type EmailSettingsSkipWizard bool const ( - EmailRoutingDisableResponseSkipWizardTrue EmailRoutingDisableResponseSkipWizard = true - EmailRoutingDisableResponseSkipWizardFalse EmailRoutingDisableResponseSkipWizard = false + EmailSettingsSkipWizardTrue EmailSettingsSkipWizard = true + EmailSettingsSkipWizardFalse EmailSettingsSkipWizard = false ) -func (r EmailRoutingDisableResponseSkipWizard) IsKnown() bool { +func (r EmailSettingsSkipWizard) IsKnown() bool { switch r { - case EmailRoutingDisableResponseSkipWizardTrue, EmailRoutingDisableResponseSkipWizardFalse: + case EmailSettingsSkipWizardTrue, EmailSettingsSkipWizardFalse: return true } return false } // Show the state of your account, and the type or configuration error. -type EmailRoutingDisableResponseStatus string +type EmailSettingsStatus string const ( - EmailRoutingDisableResponseStatusReady EmailRoutingDisableResponseStatus = "ready" - EmailRoutingDisableResponseStatusUnconfigured EmailRoutingDisableResponseStatus = "unconfigured" - EmailRoutingDisableResponseStatusMisconfigured EmailRoutingDisableResponseStatus = "misconfigured" - EmailRoutingDisableResponseStatusMisconfiguredLocked EmailRoutingDisableResponseStatus = "misconfigured/locked" - EmailRoutingDisableResponseStatusUnlocked EmailRoutingDisableResponseStatus = "unlocked" + EmailSettingsStatusReady EmailSettingsStatus = "ready" + EmailSettingsStatusUnconfigured EmailSettingsStatus = "unconfigured" + EmailSettingsStatusMisconfigured EmailSettingsStatus = "misconfigured" + EmailSettingsStatusMisconfiguredLocked EmailSettingsStatus = "misconfigured/locked" + EmailSettingsStatusUnlocked EmailSettingsStatus = "unlocked" ) -func (r EmailRoutingDisableResponseStatus) IsKnown() bool { +func (r EmailSettingsStatus) IsKnown() bool { switch r { - case EmailRoutingDisableResponseStatusReady, EmailRoutingDisableResponseStatusUnconfigured, EmailRoutingDisableResponseStatusMisconfigured, EmailRoutingDisableResponseStatusMisconfiguredLocked, EmailRoutingDisableResponseStatusUnlocked: - return true - } - return false -} - -type EmailRoutingEnableResponse struct { - // Email Routing settings identifier. - ID string `json:"id"` - // The date and time the settings have been created. - Created time.Time `json:"created" format:"date-time"` - // State of the zone settings for Email Routing. - Enabled EmailRoutingEnableResponseEnabled `json:"enabled"` - // The date and time the settings have been modified. - Modified time.Time `json:"modified" format:"date-time"` - // Domain of your zone. - Name string `json:"name"` - // Flag to check if the user skipped the configuration wizard. - SkipWizard EmailRoutingEnableResponseSkipWizard `json:"skip_wizard"` - // Show the state of your account, and the type or configuration error. - Status EmailRoutingEnableResponseStatus `json:"status"` - // Email Routing settings tag. (Deprecated, replaced by Email Routing settings - // identifier) - Tag string `json:"tag"` - JSON emailRoutingEnableResponseJSON `json:"-"` -} - -// emailRoutingEnableResponseJSON contains the JSON metadata for the struct -// [EmailRoutingEnableResponse] -type emailRoutingEnableResponseJSON struct { - ID apijson.Field - Created apijson.Field - Enabled apijson.Field - Modified apijson.Field - Name apijson.Field - SkipWizard apijson.Field - Status apijson.Field - Tag apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingEnableResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingEnableResponseJSON) RawJSON() string { - return r.raw -} - -// State of the zone settings for Email Routing. -type EmailRoutingEnableResponseEnabled bool - -const ( - EmailRoutingEnableResponseEnabledTrue EmailRoutingEnableResponseEnabled = true - EmailRoutingEnableResponseEnabledFalse EmailRoutingEnableResponseEnabled = false -) - -func (r EmailRoutingEnableResponseEnabled) IsKnown() bool { - switch r { - case EmailRoutingEnableResponseEnabledTrue, EmailRoutingEnableResponseEnabledFalse: - return true - } - return false -} - -// Flag to check if the user skipped the configuration wizard. -type EmailRoutingEnableResponseSkipWizard bool - -const ( - EmailRoutingEnableResponseSkipWizardTrue EmailRoutingEnableResponseSkipWizard = true - EmailRoutingEnableResponseSkipWizardFalse EmailRoutingEnableResponseSkipWizard = false -) - -func (r EmailRoutingEnableResponseSkipWizard) IsKnown() bool { - switch r { - case EmailRoutingEnableResponseSkipWizardTrue, EmailRoutingEnableResponseSkipWizardFalse: - return true - } - return false -} - -// Show the state of your account, and the type or configuration error. -type EmailRoutingEnableResponseStatus string - -const ( - EmailRoutingEnableResponseStatusReady EmailRoutingEnableResponseStatus = "ready" - EmailRoutingEnableResponseStatusUnconfigured EmailRoutingEnableResponseStatus = "unconfigured" - EmailRoutingEnableResponseStatusMisconfigured EmailRoutingEnableResponseStatus = "misconfigured" - EmailRoutingEnableResponseStatusMisconfiguredLocked EmailRoutingEnableResponseStatus = "misconfigured/locked" - EmailRoutingEnableResponseStatusUnlocked EmailRoutingEnableResponseStatus = "unlocked" -) - -func (r EmailRoutingEnableResponseStatus) IsKnown() bool { - switch r { - case EmailRoutingEnableResponseStatusReady, EmailRoutingEnableResponseStatusUnconfigured, EmailRoutingEnableResponseStatusMisconfigured, EmailRoutingEnableResponseStatusMisconfiguredLocked, EmailRoutingEnableResponseStatusUnlocked: - return true - } - return false -} - -type EmailRoutingGetResponse struct { - // Email Routing settings identifier. - ID string `json:"id"` - // The date and time the settings have been created. - Created time.Time `json:"created" format:"date-time"` - // State of the zone settings for Email Routing. - Enabled EmailRoutingGetResponseEnabled `json:"enabled"` - // The date and time the settings have been modified. - Modified time.Time `json:"modified" format:"date-time"` - // Domain of your zone. - Name string `json:"name"` - // Flag to check if the user skipped the configuration wizard. - SkipWizard EmailRoutingGetResponseSkipWizard `json:"skip_wizard"` - // Show the state of your account, and the type or configuration error. - Status EmailRoutingGetResponseStatus `json:"status"` - // Email Routing settings tag. (Deprecated, replaced by Email Routing settings - // identifier) - Tag string `json:"tag"` - JSON emailRoutingGetResponseJSON `json:"-"` -} - -// emailRoutingGetResponseJSON contains the JSON metadata for the struct -// [EmailRoutingGetResponse] -type emailRoutingGetResponseJSON struct { - ID apijson.Field - Created apijson.Field - Enabled apijson.Field - Modified apijson.Field - Name apijson.Field - SkipWizard apijson.Field - Status apijson.Field - Tag apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailRoutingGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailRoutingGetResponseJSON) RawJSON() string { - return r.raw -} - -// State of the zone settings for Email Routing. -type EmailRoutingGetResponseEnabled bool - -const ( - EmailRoutingGetResponseEnabledTrue EmailRoutingGetResponseEnabled = true - EmailRoutingGetResponseEnabledFalse EmailRoutingGetResponseEnabled = false -) - -func (r EmailRoutingGetResponseEnabled) IsKnown() bool { - switch r { - case EmailRoutingGetResponseEnabledTrue, EmailRoutingGetResponseEnabledFalse: - return true - } - return false -} - -// Flag to check if the user skipped the configuration wizard. -type EmailRoutingGetResponseSkipWizard bool - -const ( - EmailRoutingGetResponseSkipWizardTrue EmailRoutingGetResponseSkipWizard = true - EmailRoutingGetResponseSkipWizardFalse EmailRoutingGetResponseSkipWizard = false -) - -func (r EmailRoutingGetResponseSkipWizard) IsKnown() bool { - switch r { - case EmailRoutingGetResponseSkipWizardTrue, EmailRoutingGetResponseSkipWizardFalse: - return true - } - return false -} - -// Show the state of your account, and the type or configuration error. -type EmailRoutingGetResponseStatus string - -const ( - EmailRoutingGetResponseStatusReady EmailRoutingGetResponseStatus = "ready" - EmailRoutingGetResponseStatusUnconfigured EmailRoutingGetResponseStatus = "unconfigured" - EmailRoutingGetResponseStatusMisconfigured EmailRoutingGetResponseStatus = "misconfigured" - EmailRoutingGetResponseStatusMisconfiguredLocked EmailRoutingGetResponseStatus = "misconfigured/locked" - EmailRoutingGetResponseStatusUnlocked EmailRoutingGetResponseStatus = "unlocked" -) - -func (r EmailRoutingGetResponseStatus) IsKnown() bool { - switch r { - case EmailRoutingGetResponseStatusReady, EmailRoutingGetResponseStatusUnconfigured, EmailRoutingGetResponseStatusMisconfigured, EmailRoutingGetResponseStatusMisconfiguredLocked, EmailRoutingGetResponseStatusUnlocked: + case EmailSettingsStatusReady, EmailSettingsStatusUnconfigured, EmailSettingsStatusMisconfigured, EmailSettingsStatusMisconfiguredLocked, EmailSettingsStatusUnlocked: return true } return false @@ -375,7 +184,7 @@ func (r EmailRoutingDisableParams) MarshalJSON() (data []byte, err error) { type EmailRoutingDisableResponseEnvelope struct { Errors []shared.UnnamedSchemaRef3248f24329456e19dfa042fff9986f72 `json:"errors,required"` Messages []shared.UnnamedSchemaRef3248f24329456e19dfa042fff9986f72 `json:"messages,required"` - Result EmailRoutingDisableResponse `json:"result,required"` + Result EmailSettings `json:"result,required"` // Whether the API call was successful Success EmailRoutingDisableResponseEnvelopeSuccess `json:"success,required"` JSON emailRoutingDisableResponseEnvelopeJSON `json:"-"` @@ -426,7 +235,7 @@ func (r EmailRoutingEnableParams) MarshalJSON() (data []byte, err error) { type EmailRoutingEnableResponseEnvelope struct { Errors []shared.UnnamedSchemaRef3248f24329456e19dfa042fff9986f72 `json:"errors,required"` Messages []shared.UnnamedSchemaRef3248f24329456e19dfa042fff9986f72 `json:"messages,required"` - Result EmailRoutingEnableResponse `json:"result,required"` + Result EmailSettings `json:"result,required"` // Whether the API call was successful Success EmailRoutingEnableResponseEnvelopeSuccess `json:"success,required"` JSON emailRoutingEnableResponseEnvelopeJSON `json:"-"` @@ -469,7 +278,7 @@ func (r EmailRoutingEnableResponseEnvelopeSuccess) IsKnown() bool { type EmailRoutingGetResponseEnvelope struct { Errors []shared.UnnamedSchemaRef3248f24329456e19dfa042fff9986f72 `json:"errors,required"` Messages []shared.UnnamedSchemaRef3248f24329456e19dfa042fff9986f72 `json:"messages,required"` - Result EmailRoutingGetResponse `json:"result,required"` + Result EmailSettings `json:"result,required"` // Whether the API call was successful Success EmailRoutingGetResponseEnvelopeSuccess `json:"success,required"` JSON emailRoutingGetResponseEnvelopeJSON `json:"-"` diff --git a/email_routing/rule.go b/email_routing/rule.go index 44a17fd1fea..7a340c6d76b 100644 --- a/email_routing/rule.go +++ b/email_routing/rule.go @@ -39,7 +39,7 @@ func NewRuleService(opts ...option.RequestOption) (r *RuleService) { // Rules consist of a set of criteria for matching emails (such as an email being // sent to a specific custom email address) plus a set of actions to take on the // email (like forwarding it to a specific destination address). -func (r *RuleService) New(ctx context.Context, zoneIdentifier string, body RuleNewParams, opts ...option.RequestOption) (res *RuleNewResponse, err error) { +func (r *RuleService) New(ctx context.Context, zoneIdentifier string, body RuleNewParams, opts ...option.RequestOption) (res *Properties, err error) { opts = append(r.Options[:], opts...) var env RuleNewResponseEnvelope path := fmt.Sprintf("zones/%s/email/routing/rules", zoneIdentifier) @@ -52,7 +52,7 @@ func (r *RuleService) New(ctx context.Context, zoneIdentifier string, body RuleN } // Update actions and matches, or enable/disable specific routing rules. -func (r *RuleService) Update(ctx context.Context, zoneIdentifier string, ruleIdentifier string, body RuleUpdateParams, opts ...option.RequestOption) (res *RuleUpdateResponse, err error) { +func (r *RuleService) Update(ctx context.Context, zoneIdentifier string, ruleIdentifier string, body RuleUpdateParams, opts ...option.RequestOption) (res *Properties, err error) { opts = append(r.Options[:], opts...) var env RuleUpdateResponseEnvelope path := fmt.Sprintf("zones/%s/email/routing/rules/%s", zoneIdentifier, ruleIdentifier) @@ -65,7 +65,7 @@ func (r *RuleService) Update(ctx context.Context, zoneIdentifier string, ruleIde } // Lists existing routing rules. -func (r *RuleService) List(ctx context.Context, zoneIdentifier string, query RuleListParams, opts ...option.RequestOption) (res *pagination.V4PagePaginationArray[RuleListResponse], err error) { +func (r *RuleService) List(ctx context.Context, zoneIdentifier string, query RuleListParams, opts ...option.RequestOption) (res *pagination.V4PagePaginationArray[Properties], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -83,12 +83,12 @@ func (r *RuleService) List(ctx context.Context, zoneIdentifier string, query Rul } // Lists existing routing rules. -func (r *RuleService) ListAutoPaging(ctx context.Context, zoneIdentifier string, query RuleListParams, opts ...option.RequestOption) *pagination.V4PagePaginationArrayAutoPager[RuleListResponse] { +func (r *RuleService) ListAutoPaging(ctx context.Context, zoneIdentifier string, query RuleListParams, opts ...option.RequestOption) *pagination.V4PagePaginationArrayAutoPager[Properties] { return pagination.NewV4PagePaginationArrayAutoPager(r.List(ctx, zoneIdentifier, query, opts...)) } // Delete a specific routing rule. -func (r *RuleService) Delete(ctx context.Context, zoneIdentifier string, ruleIdentifier string, opts ...option.RequestOption) (res *RuleDeleteResponse, err error) { +func (r *RuleService) Delete(ctx context.Context, zoneIdentifier string, ruleIdentifier string, opts ...option.RequestOption) (res *Properties, err error) { opts = append(r.Options[:], opts...) var env RuleDeleteResponseEnvelope path := fmt.Sprintf("zones/%s/email/routing/rules/%s", zoneIdentifier, ruleIdentifier) @@ -101,7 +101,7 @@ func (r *RuleService) Delete(ctx context.Context, zoneIdentifier string, ruleIde } // Get information for a specific routing rule already created. -func (r *RuleService) Get(ctx context.Context, zoneIdentifier string, ruleIdentifier string, opts ...option.RequestOption) (res *RuleGetResponse, err error) { +func (r *RuleService) Get(ctx context.Context, zoneIdentifier string, ruleIdentifier string, opts ...option.RequestOption) (res *Properties, err error) { opts = append(r.Options[:], opts...) var env RuleGetResponseEnvelope path := fmt.Sprintf("zones/%s/email/routing/rules/%s", zoneIdentifier, ruleIdentifier) @@ -113,274 +113,123 @@ func (r *RuleService) Get(ctx context.Context, zoneIdentifier string, ruleIdenti return } -type RuleNewResponse struct { - // Routing rule identifier. - ID string `json:"id"` - // List actions patterns. - Actions []RuleNewResponseAction `json:"actions"` - // Routing rule status. - Enabled RuleNewResponseEnabled `json:"enabled"` - // Matching patterns to forward to your actions. - Matchers []RuleNewResponseMatcher `json:"matchers"` - // Routing rule name. - Name string `json:"name"` - // Priority of the routing rule. - Priority float64 `json:"priority"` - // Routing rule tag. (Deprecated, replaced by routing rule identifier) - Tag string `json:"tag"` - JSON ruleNewResponseJSON `json:"-"` -} - -// ruleNewResponseJSON contains the JSON metadata for the struct [RuleNewResponse] -type ruleNewResponseJSON struct { - ID apijson.Field - Actions apijson.Field - Enabled apijson.Field - Matchers apijson.Field - Name apijson.Field - Priority apijson.Field - Tag apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleNewResponseJSON) RawJSON() string { - return r.raw -} - // Actions pattern. -type RuleNewResponseAction struct { +type Action struct { // Type of supported action. - Type RuleNewResponseActionsType `json:"type,required"` - Value []string `json:"value,required"` - JSON ruleNewResponseActionJSON `json:"-"` + Type ActionType `json:"type,required"` + Value []string `json:"value,required"` + JSON actionJSON `json:"-"` } -// ruleNewResponseActionJSON contains the JSON metadata for the struct -// [RuleNewResponseAction] -type ruleNewResponseActionJSON struct { +// actionJSON contains the JSON metadata for the struct [Action] +type actionJSON struct { Type apijson.Field Value apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *RuleNewResponseAction) UnmarshalJSON(data []byte) (err error) { +func (r *Action) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r ruleNewResponseActionJSON) RawJSON() string { +func (r actionJSON) RawJSON() string { return r.raw } // Type of supported action. -type RuleNewResponseActionsType string +type ActionType string const ( - RuleNewResponseActionsTypeDrop RuleNewResponseActionsType = "drop" - RuleNewResponseActionsTypeForward RuleNewResponseActionsType = "forward" - RuleNewResponseActionsTypeWorker RuleNewResponseActionsType = "worker" + ActionTypeDrop ActionType = "drop" + ActionTypeForward ActionType = "forward" + ActionTypeWorker ActionType = "worker" ) -func (r RuleNewResponseActionsType) IsKnown() bool { +func (r ActionType) IsKnown() bool { switch r { - case RuleNewResponseActionsTypeDrop, RuleNewResponseActionsTypeForward, RuleNewResponseActionsTypeWorker: + case ActionTypeDrop, ActionTypeForward, ActionTypeWorker: return true } return false } -// Routing rule status. -type RuleNewResponseEnabled bool - -const ( - RuleNewResponseEnabledTrue RuleNewResponseEnabled = true - RuleNewResponseEnabledFalse RuleNewResponseEnabled = false -) - -func (r RuleNewResponseEnabled) IsKnown() bool { - switch r { - case RuleNewResponseEnabledTrue, RuleNewResponseEnabledFalse: - return true - } - return false -} - -// Matching pattern to forward your actions. -type RuleNewResponseMatcher struct { - // Field for type matcher. - Field RuleNewResponseMatchersField `json:"field,required"` - // Type of matcher. - Type RuleNewResponseMatchersType `json:"type,required"` - // Value for matcher. - Value string `json:"value,required"` - JSON ruleNewResponseMatcherJSON `json:"-"` -} - -// ruleNewResponseMatcherJSON contains the JSON metadata for the struct -// [RuleNewResponseMatcher] -type ruleNewResponseMatcherJSON struct { - Field apijson.Field - Type apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleNewResponseMatcher) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleNewResponseMatcherJSON) RawJSON() string { - return r.raw -} - -// Field for type matcher. -type RuleNewResponseMatchersField string - -const ( - RuleNewResponseMatchersFieldTo RuleNewResponseMatchersField = "to" -) - -func (r RuleNewResponseMatchersField) IsKnown() bool { - switch r { - case RuleNewResponseMatchersFieldTo: - return true - } - return false -} - -// Type of matcher. -type RuleNewResponseMatchersType string - -const ( - RuleNewResponseMatchersTypeLiteral RuleNewResponseMatchersType = "literal" -) - -func (r RuleNewResponseMatchersType) IsKnown() bool { - switch r { - case RuleNewResponseMatchersTypeLiteral: - return true - } - return false -} - -type RuleUpdateResponse struct { - // Routing rule identifier. - ID string `json:"id"` - // List actions patterns. - Actions []RuleUpdateResponseAction `json:"actions"` - // Routing rule status. - Enabled RuleUpdateResponseEnabled `json:"enabled"` - // Matching patterns to forward to your actions. - Matchers []RuleUpdateResponseMatcher `json:"matchers"` - // Routing rule name. - Name string `json:"name"` - // Priority of the routing rule. - Priority float64 `json:"priority"` - // Routing rule tag. (Deprecated, replaced by routing rule identifier) - Tag string `json:"tag"` - JSON ruleUpdateResponseJSON `json:"-"` -} - -// ruleUpdateResponseJSON contains the JSON metadata for the struct -// [RuleUpdateResponse] -type ruleUpdateResponseJSON struct { - ID apijson.Field - Actions apijson.Field - Enabled apijson.Field - Matchers apijson.Field - Name apijson.Field - Priority apijson.Field - Tag apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) +// Actions pattern. +type ActionParam struct { + // Type of supported action. + Type param.Field[ActionType] `json:"type,required"` + Value param.Field[[]string] `json:"value,required"` } -func (r ruleUpdateResponseJSON) RawJSON() string { - return r.raw +func (r ActionParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } // Actions pattern. -type RuleUpdateResponseAction struct { +type ActionItem struct { // Type of supported action. - Type RuleUpdateResponseActionsType `json:"type,required"` - Value []string `json:"value,required"` - JSON ruleUpdateResponseActionJSON `json:"-"` + Type ActionItemType `json:"type,required"` + Value []string `json:"value,required"` + JSON actionItemJSON `json:"-"` } -// ruleUpdateResponseActionJSON contains the JSON metadata for the struct -// [RuleUpdateResponseAction] -type ruleUpdateResponseActionJSON struct { +// actionItemJSON contains the JSON metadata for the struct [ActionItem] +type actionItemJSON struct { Type apijson.Field Value apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *RuleUpdateResponseAction) UnmarshalJSON(data []byte) (err error) { +func (r *ActionItem) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r ruleUpdateResponseActionJSON) RawJSON() string { +func (r actionItemJSON) RawJSON() string { return r.raw } // Type of supported action. -type RuleUpdateResponseActionsType string +type ActionItemType string const ( - RuleUpdateResponseActionsTypeDrop RuleUpdateResponseActionsType = "drop" - RuleUpdateResponseActionsTypeForward RuleUpdateResponseActionsType = "forward" - RuleUpdateResponseActionsTypeWorker RuleUpdateResponseActionsType = "worker" + ActionItemTypeDrop ActionItemType = "drop" + ActionItemTypeForward ActionItemType = "forward" + ActionItemTypeWorker ActionItemType = "worker" ) -func (r RuleUpdateResponseActionsType) IsKnown() bool { +func (r ActionItemType) IsKnown() bool { switch r { - case RuleUpdateResponseActionsTypeDrop, RuleUpdateResponseActionsTypeForward, RuleUpdateResponseActionsTypeWorker: + case ActionItemTypeDrop, ActionItemTypeForward, ActionItemTypeWorker: return true } return false } -// Routing rule status. -type RuleUpdateResponseEnabled bool - -const ( - RuleUpdateResponseEnabledTrue RuleUpdateResponseEnabled = true - RuleUpdateResponseEnabledFalse RuleUpdateResponseEnabled = false -) +// Actions pattern. +type ActionItemParam struct { + // Type of supported action. + Type param.Field[ActionItemType] `json:"type,required"` + Value param.Field[[]string] `json:"value,required"` +} -func (r RuleUpdateResponseEnabled) IsKnown() bool { - switch r { - case RuleUpdateResponseEnabledTrue, RuleUpdateResponseEnabledFalse: - return true - } - return false +func (r ActionItemParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } // Matching pattern to forward your actions. -type RuleUpdateResponseMatcher struct { +type Matcher struct { // Field for type matcher. - Field RuleUpdateResponseMatchersField `json:"field,required"` + Field MatcherField `json:"field,required"` // Type of matcher. - Type RuleUpdateResponseMatchersType `json:"type,required"` + Type MatcherType `json:"type,required"` // Value for matcher. - Value string `json:"value,required"` - JSON ruleUpdateResponseMatcherJSON `json:"-"` + Value string `json:"value,required"` + JSON matcherJSON `json:"-"` } -// ruleUpdateResponseMatcherJSON contains the JSON metadata for the struct -// [RuleUpdateResponseMatcher] -type ruleUpdateResponseMatcherJSON struct { +// matcherJSON contains the JSON metadata for the struct [Matcher] +type matcherJSON struct { Field apijson.Field Type apijson.Field Value apijson.Field @@ -388,156 +237,71 @@ type ruleUpdateResponseMatcherJSON struct { ExtraFields map[string]apijson.Field } -func (r *RuleUpdateResponseMatcher) UnmarshalJSON(data []byte) (err error) { +func (r *Matcher) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r ruleUpdateResponseMatcherJSON) RawJSON() string { +func (r matcherJSON) RawJSON() string { return r.raw } // Field for type matcher. -type RuleUpdateResponseMatchersField string +type MatcherField string const ( - RuleUpdateResponseMatchersFieldTo RuleUpdateResponseMatchersField = "to" + MatcherFieldTo MatcherField = "to" ) -func (r RuleUpdateResponseMatchersField) IsKnown() bool { +func (r MatcherField) IsKnown() bool { switch r { - case RuleUpdateResponseMatchersFieldTo: + case MatcherFieldTo: return true } return false } // Type of matcher. -type RuleUpdateResponseMatchersType string +type MatcherType string const ( - RuleUpdateResponseMatchersTypeLiteral RuleUpdateResponseMatchersType = "literal" + MatcherTypeLiteral MatcherType = "literal" ) -func (r RuleUpdateResponseMatchersType) IsKnown() bool { +func (r MatcherType) IsKnown() bool { switch r { - case RuleUpdateResponseMatchersTypeLiteral: + case MatcherTypeLiteral: return true } return false } -type RuleListResponse struct { - // Routing rule identifier. - ID string `json:"id"` - // List actions patterns. - Actions []RuleListResponseAction `json:"actions"` - // Routing rule status. - Enabled RuleListResponseEnabled `json:"enabled"` - // Matching patterns to forward to your actions. - Matchers []RuleListResponseMatcher `json:"matchers"` - // Routing rule name. - Name string `json:"name"` - // Priority of the routing rule. - Priority float64 `json:"priority"` - // Routing rule tag. (Deprecated, replaced by routing rule identifier) - Tag string `json:"tag"` - JSON ruleListResponseJSON `json:"-"` -} - -// ruleListResponseJSON contains the JSON metadata for the struct -// [RuleListResponse] -type ruleListResponseJSON struct { - ID apijson.Field - Actions apijson.Field - Enabled apijson.Field - Matchers apijson.Field - Name apijson.Field - Priority apijson.Field - Tag apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleListResponseJSON) RawJSON() string { - return r.raw -} - -// Actions pattern. -type RuleListResponseAction struct { - // Type of supported action. - Type RuleListResponseActionsType `json:"type,required"` - Value []string `json:"value,required"` - JSON ruleListResponseActionJSON `json:"-"` -} - -// ruleListResponseActionJSON contains the JSON metadata for the struct -// [RuleListResponseAction] -type ruleListResponseActionJSON struct { - Type apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleListResponseAction) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleListResponseActionJSON) RawJSON() string { - return r.raw -} - -// Type of supported action. -type RuleListResponseActionsType string - -const ( - RuleListResponseActionsTypeDrop RuleListResponseActionsType = "drop" - RuleListResponseActionsTypeForward RuleListResponseActionsType = "forward" - RuleListResponseActionsTypeWorker RuleListResponseActionsType = "worker" -) - -func (r RuleListResponseActionsType) IsKnown() bool { - switch r { - case RuleListResponseActionsTypeDrop, RuleListResponseActionsTypeForward, RuleListResponseActionsTypeWorker: - return true - } - return false +// Matching pattern to forward your actions. +type MatcherParam struct { + // Field for type matcher. + Field param.Field[MatcherField] `json:"field,required"` + // Type of matcher. + Type param.Field[MatcherType] `json:"type,required"` + // Value for matcher. + Value param.Field[string] `json:"value,required"` } -// Routing rule status. -type RuleListResponseEnabled bool - -const ( - RuleListResponseEnabledTrue RuleListResponseEnabled = true - RuleListResponseEnabledFalse RuleListResponseEnabled = false -) - -func (r RuleListResponseEnabled) IsKnown() bool { - switch r { - case RuleListResponseEnabledTrue, RuleListResponseEnabledFalse: - return true - } - return false +func (r MatcherParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } // Matching pattern to forward your actions. -type RuleListResponseMatcher struct { +type MatcherItem struct { // Field for type matcher. - Field RuleListResponseMatchersField `json:"field,required"` + Field MatcherItemField `json:"field,required"` // Type of matcher. - Type RuleListResponseMatchersType `json:"type,required"` + Type MatcherItemType `json:"type,required"` // Value for matcher. - Value string `json:"value,required"` - JSON ruleListResponseMatcherJSON `json:"-"` + Value string `json:"value,required"` + JSON matcherItemJSON `json:"-"` } -// ruleListResponseMatcherJSON contains the JSON metadata for the struct -// [RuleListResponseMatcher] -type ruleListResponseMatcherJSON struct { +// matcherItemJSON contains the JSON metadata for the struct [MatcherItem] +type matcherItemJSON struct { Field apijson.Field Type apijson.Field Value apijson.Field @@ -545,221 +309,78 @@ type ruleListResponseMatcherJSON struct { ExtraFields map[string]apijson.Field } -func (r *RuleListResponseMatcher) UnmarshalJSON(data []byte) (err error) { +func (r *MatcherItem) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r ruleListResponseMatcherJSON) RawJSON() string { +func (r matcherItemJSON) RawJSON() string { return r.raw } // Field for type matcher. -type RuleListResponseMatchersField string +type MatcherItemField string const ( - RuleListResponseMatchersFieldTo RuleListResponseMatchersField = "to" + MatcherItemFieldTo MatcherItemField = "to" ) -func (r RuleListResponseMatchersField) IsKnown() bool { +func (r MatcherItemField) IsKnown() bool { switch r { - case RuleListResponseMatchersFieldTo: + case MatcherItemFieldTo: return true } return false } // Type of matcher. -type RuleListResponseMatchersType string - -const ( - RuleListResponseMatchersTypeLiteral RuleListResponseMatchersType = "literal" -) - -func (r RuleListResponseMatchersType) IsKnown() bool { - switch r { - case RuleListResponseMatchersTypeLiteral: - return true - } - return false -} - -type RuleDeleteResponse struct { - // Routing rule identifier. - ID string `json:"id"` - // List actions patterns. - Actions []RuleDeleteResponseAction `json:"actions"` - // Routing rule status. - Enabled RuleDeleteResponseEnabled `json:"enabled"` - // Matching patterns to forward to your actions. - Matchers []RuleDeleteResponseMatcher `json:"matchers"` - // Routing rule name. - Name string `json:"name"` - // Priority of the routing rule. - Priority float64 `json:"priority"` - // Routing rule tag. (Deprecated, replaced by routing rule identifier) - Tag string `json:"tag"` - JSON ruleDeleteResponseJSON `json:"-"` -} - -// ruleDeleteResponseJSON contains the JSON metadata for the struct -// [RuleDeleteResponse] -type ruleDeleteResponseJSON struct { - ID apijson.Field - Actions apijson.Field - Enabled apijson.Field - Matchers apijson.Field - Name apijson.Field - Priority apijson.Field - Tag apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleDeleteResponseJSON) RawJSON() string { - return r.raw -} - -// Actions pattern. -type RuleDeleteResponseAction struct { - // Type of supported action. - Type RuleDeleteResponseActionsType `json:"type,required"` - Value []string `json:"value,required"` - JSON ruleDeleteResponseActionJSON `json:"-"` -} - -// ruleDeleteResponseActionJSON contains the JSON metadata for the struct -// [RuleDeleteResponseAction] -type ruleDeleteResponseActionJSON struct { - Type apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleDeleteResponseAction) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleDeleteResponseActionJSON) RawJSON() string { - return r.raw -} - -// Type of supported action. -type RuleDeleteResponseActionsType string - -const ( - RuleDeleteResponseActionsTypeDrop RuleDeleteResponseActionsType = "drop" - RuleDeleteResponseActionsTypeForward RuleDeleteResponseActionsType = "forward" - RuleDeleteResponseActionsTypeWorker RuleDeleteResponseActionsType = "worker" -) - -func (r RuleDeleteResponseActionsType) IsKnown() bool { - switch r { - case RuleDeleteResponseActionsTypeDrop, RuleDeleteResponseActionsTypeForward, RuleDeleteResponseActionsTypeWorker: - return true - } - return false -} - -// Routing rule status. -type RuleDeleteResponseEnabled bool +type MatcherItemType string const ( - RuleDeleteResponseEnabledTrue RuleDeleteResponseEnabled = true - RuleDeleteResponseEnabledFalse RuleDeleteResponseEnabled = false + MatcherItemTypeLiteral MatcherItemType = "literal" ) -func (r RuleDeleteResponseEnabled) IsKnown() bool { +func (r MatcherItemType) IsKnown() bool { switch r { - case RuleDeleteResponseEnabledTrue, RuleDeleteResponseEnabledFalse: + case MatcherItemTypeLiteral: return true } return false } // Matching pattern to forward your actions. -type RuleDeleteResponseMatcher struct { +type MatcherItemParam struct { // Field for type matcher. - Field RuleDeleteResponseMatchersField `json:"field,required"` + Field param.Field[MatcherItemField] `json:"field,required"` // Type of matcher. - Type RuleDeleteResponseMatchersType `json:"type,required"` + Type param.Field[MatcherItemType] `json:"type,required"` // Value for matcher. - Value string `json:"value,required"` - JSON ruleDeleteResponseMatcherJSON `json:"-"` -} - -// ruleDeleteResponseMatcherJSON contains the JSON metadata for the struct -// [RuleDeleteResponseMatcher] -type ruleDeleteResponseMatcherJSON struct { - Field apijson.Field - Type apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleDeleteResponseMatcher) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleDeleteResponseMatcherJSON) RawJSON() string { - return r.raw -} - -// Field for type matcher. -type RuleDeleteResponseMatchersField string - -const ( - RuleDeleteResponseMatchersFieldTo RuleDeleteResponseMatchersField = "to" -) - -func (r RuleDeleteResponseMatchersField) IsKnown() bool { - switch r { - case RuleDeleteResponseMatchersFieldTo: - return true - } - return false + Value param.Field[string] `json:"value,required"` } -// Type of matcher. -type RuleDeleteResponseMatchersType string - -const ( - RuleDeleteResponseMatchersTypeLiteral RuleDeleteResponseMatchersType = "literal" -) - -func (r RuleDeleteResponseMatchersType) IsKnown() bool { - switch r { - case RuleDeleteResponseMatchersTypeLiteral: - return true - } - return false +func (r MatcherItemParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -type RuleGetResponse struct { +type Properties struct { // Routing rule identifier. ID string `json:"id"` // List actions patterns. - Actions []RuleGetResponseAction `json:"actions"` + Actions []ActionItem `json:"actions"` // Routing rule status. - Enabled RuleGetResponseEnabled `json:"enabled"` + Enabled PropertiesEnabled `json:"enabled"` // Matching patterns to forward to your actions. - Matchers []RuleGetResponseMatcher `json:"matchers"` + Matchers []MatcherItem `json:"matchers"` // Routing rule name. Name string `json:"name"` // Priority of the routing rule. Priority float64 `json:"priority"` // Routing rule tag. (Deprecated, replaced by routing rule identifier) - Tag string `json:"tag"` - JSON ruleGetResponseJSON `json:"-"` + Tag string `json:"tag"` + JSON propertiesJSON `json:"-"` } -// ruleGetResponseJSON contains the JSON metadata for the struct [RuleGetResponse] -type ruleGetResponseJSON struct { +// propertiesJSON contains the JSON metadata for the struct [Properties] +type propertiesJSON struct { ID apijson.Field Actions apijson.Field Enabled apijson.Field @@ -771,126 +392,25 @@ type ruleGetResponseJSON struct { ExtraFields map[string]apijson.Field } -func (r *RuleGetResponse) UnmarshalJSON(data []byte) (err error) { +func (r *Properties) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r ruleGetResponseJSON) RawJSON() string { +func (r propertiesJSON) RawJSON() string { return r.raw } -// Actions pattern. -type RuleGetResponseAction struct { - // Type of supported action. - Type RuleGetResponseActionsType `json:"type,required"` - Value []string `json:"value,required"` - JSON ruleGetResponseActionJSON `json:"-"` -} - -// ruleGetResponseActionJSON contains the JSON metadata for the struct -// [RuleGetResponseAction] -type ruleGetResponseActionJSON struct { - Type apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleGetResponseAction) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleGetResponseActionJSON) RawJSON() string { - return r.raw -} - -// Type of supported action. -type RuleGetResponseActionsType string - -const ( - RuleGetResponseActionsTypeDrop RuleGetResponseActionsType = "drop" - RuleGetResponseActionsTypeForward RuleGetResponseActionsType = "forward" - RuleGetResponseActionsTypeWorker RuleGetResponseActionsType = "worker" -) - -func (r RuleGetResponseActionsType) IsKnown() bool { - switch r { - case RuleGetResponseActionsTypeDrop, RuleGetResponseActionsTypeForward, RuleGetResponseActionsTypeWorker: - return true - } - return false -} - // Routing rule status. -type RuleGetResponseEnabled bool - -const ( - RuleGetResponseEnabledTrue RuleGetResponseEnabled = true - RuleGetResponseEnabledFalse RuleGetResponseEnabled = false -) - -func (r RuleGetResponseEnabled) IsKnown() bool { - switch r { - case RuleGetResponseEnabledTrue, RuleGetResponseEnabledFalse: - return true - } - return false -} - -// Matching pattern to forward your actions. -type RuleGetResponseMatcher struct { - // Field for type matcher. - Field RuleGetResponseMatchersField `json:"field,required"` - // Type of matcher. - Type RuleGetResponseMatchersType `json:"type,required"` - // Value for matcher. - Value string `json:"value,required"` - JSON ruleGetResponseMatcherJSON `json:"-"` -} - -// ruleGetResponseMatcherJSON contains the JSON metadata for the struct -// [RuleGetResponseMatcher] -type ruleGetResponseMatcherJSON struct { - Field apijson.Field - Type apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *RuleGetResponseMatcher) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r ruleGetResponseMatcherJSON) RawJSON() string { - return r.raw -} - -// Field for type matcher. -type RuleGetResponseMatchersField string - -const ( - RuleGetResponseMatchersFieldTo RuleGetResponseMatchersField = "to" -) - -func (r RuleGetResponseMatchersField) IsKnown() bool { - switch r { - case RuleGetResponseMatchersFieldTo: - return true - } - return false -} - -// Type of matcher. -type RuleGetResponseMatchersType string +type PropertiesEnabled bool const ( - RuleGetResponseMatchersTypeLiteral RuleGetResponseMatchersType = "literal" + PropertiesEnabledTrue PropertiesEnabled = true + PropertiesEnabledFalse PropertiesEnabled = false ) -func (r RuleGetResponseMatchersType) IsKnown() bool { +func (r PropertiesEnabled) IsKnown() bool { switch r { - case RuleGetResponseMatchersTypeLiteral: + case PropertiesEnabledTrue, PropertiesEnabledFalse: return true } return false @@ -898,9 +418,9 @@ func (r RuleGetResponseMatchersType) IsKnown() bool { type RuleNewParams struct { // List actions patterns. - Actions param.Field[[]RuleNewParamsAction] `json:"actions,required"` + Actions param.Field[[]ActionParam] `json:"actions,required"` // Matching patterns to forward to your actions. - Matchers param.Field[[]RuleNewParamsMatcher] `json:"matchers,required"` + Matchers param.Field[[]MatcherParam] `json:"matchers,required"` // Routing rule status. Enabled param.Field[RuleNewParamsEnabled] `json:"enabled"` // Routing rule name. @@ -913,78 +433,6 @@ func (r RuleNewParams) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -// Actions pattern. -type RuleNewParamsAction struct { - // Type of supported action. - Type param.Field[RuleNewParamsActionsType] `json:"type,required"` - Value param.Field[[]string] `json:"value,required"` -} - -func (r RuleNewParamsAction) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Type of supported action. -type RuleNewParamsActionsType string - -const ( - RuleNewParamsActionsTypeDrop RuleNewParamsActionsType = "drop" - RuleNewParamsActionsTypeForward RuleNewParamsActionsType = "forward" - RuleNewParamsActionsTypeWorker RuleNewParamsActionsType = "worker" -) - -func (r RuleNewParamsActionsType) IsKnown() bool { - switch r { - case RuleNewParamsActionsTypeDrop, RuleNewParamsActionsTypeForward, RuleNewParamsActionsTypeWorker: - return true - } - return false -} - -// Matching pattern to forward your actions. -type RuleNewParamsMatcher struct { - // Field for type matcher. - Field param.Field[RuleNewParamsMatchersField] `json:"field,required"` - // Type of matcher. - Type param.Field[RuleNewParamsMatchersType] `json:"type,required"` - // Value for matcher. - Value param.Field[string] `json:"value,required"` -} - -func (r RuleNewParamsMatcher) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Field for type matcher. -type RuleNewParamsMatchersField string - -const ( - RuleNewParamsMatchersFieldTo RuleNewParamsMatchersField = "to" -) - -func (r RuleNewParamsMatchersField) IsKnown() bool { - switch r { - case RuleNewParamsMatchersFieldTo: - return true - } - return false -} - -// Type of matcher. -type RuleNewParamsMatchersType string - -const ( - RuleNewParamsMatchersTypeLiteral RuleNewParamsMatchersType = "literal" -) - -func (r RuleNewParamsMatchersType) IsKnown() bool { - switch r { - case RuleNewParamsMatchersTypeLiteral: - return true - } - return false -} - // Routing rule status. type RuleNewParamsEnabled bool @@ -1004,7 +452,7 @@ func (r RuleNewParamsEnabled) IsKnown() bool { type RuleNewResponseEnvelope struct { Errors []shared.UnnamedSchemaRef3248f24329456e19dfa042fff9986f72 `json:"errors,required"` Messages []shared.UnnamedSchemaRef3248f24329456e19dfa042fff9986f72 `json:"messages,required"` - Result RuleNewResponse `json:"result,required"` + Result Properties `json:"result,required"` // Whether the API call was successful Success RuleNewResponseEnvelopeSuccess `json:"success,required"` JSON ruleNewResponseEnvelopeJSON `json:"-"` @@ -1046,9 +494,9 @@ func (r RuleNewResponseEnvelopeSuccess) IsKnown() bool { type RuleUpdateParams struct { // List actions patterns. - Actions param.Field[[]RuleUpdateParamsAction] `json:"actions,required"` + Actions param.Field[[]ActionItemParam] `json:"actions,required"` // Matching patterns to forward to your actions. - Matchers param.Field[[]RuleUpdateParamsMatcher] `json:"matchers,required"` + Matchers param.Field[[]MatcherItemParam] `json:"matchers,required"` // Routing rule status. Enabled param.Field[RuleUpdateParamsEnabled] `json:"enabled"` // Routing rule name. @@ -1061,78 +509,6 @@ func (r RuleUpdateParams) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -// Actions pattern. -type RuleUpdateParamsAction struct { - // Type of supported action. - Type param.Field[RuleUpdateParamsActionsType] `json:"type,required"` - Value param.Field[[]string] `json:"value,required"` -} - -func (r RuleUpdateParamsAction) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Type of supported action. -type RuleUpdateParamsActionsType string - -const ( - RuleUpdateParamsActionsTypeDrop RuleUpdateParamsActionsType = "drop" - RuleUpdateParamsActionsTypeForward RuleUpdateParamsActionsType = "forward" - RuleUpdateParamsActionsTypeWorker RuleUpdateParamsActionsType = "worker" -) - -func (r RuleUpdateParamsActionsType) IsKnown() bool { - switch r { - case RuleUpdateParamsActionsTypeDrop, RuleUpdateParamsActionsTypeForward, RuleUpdateParamsActionsTypeWorker: - return true - } - return false -} - -// Matching pattern to forward your actions. -type RuleUpdateParamsMatcher struct { - // Field for type matcher. - Field param.Field[RuleUpdateParamsMatchersField] `json:"field,required"` - // Type of matcher. - Type param.Field[RuleUpdateParamsMatchersType] `json:"type,required"` - // Value for matcher. - Value param.Field[string] `json:"value,required"` -} - -func (r RuleUpdateParamsMatcher) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Field for type matcher. -type RuleUpdateParamsMatchersField string - -const ( - RuleUpdateParamsMatchersFieldTo RuleUpdateParamsMatchersField = "to" -) - -func (r RuleUpdateParamsMatchersField) IsKnown() bool { - switch r { - case RuleUpdateParamsMatchersFieldTo: - return true - } - return false -} - -// Type of matcher. -type RuleUpdateParamsMatchersType string - -const ( - RuleUpdateParamsMatchersTypeLiteral RuleUpdateParamsMatchersType = "literal" -) - -func (r RuleUpdateParamsMatchersType) IsKnown() bool { - switch r { - case RuleUpdateParamsMatchersTypeLiteral: - return true - } - return false -} - // Routing rule status. type RuleUpdateParamsEnabled bool @@ -1152,7 +528,7 @@ func (r RuleUpdateParamsEnabled) IsKnown() bool { type RuleUpdateResponseEnvelope struct { Errors []shared.UnnamedSchemaRef3248f24329456e19dfa042fff9986f72 `json:"errors,required"` Messages []shared.UnnamedSchemaRef3248f24329456e19dfa042fff9986f72 `json:"messages,required"` - Result RuleUpdateResponse `json:"result,required"` + Result Properties `json:"result,required"` // Whether the API call was successful Success RuleUpdateResponseEnvelopeSuccess `json:"success,required"` JSON ruleUpdateResponseEnvelopeJSON `json:"-"` @@ -1228,7 +604,7 @@ func (r RuleListParamsEnabled) IsKnown() bool { type RuleDeleteResponseEnvelope struct { Errors []shared.UnnamedSchemaRef3248f24329456e19dfa042fff9986f72 `json:"errors,required"` Messages []shared.UnnamedSchemaRef3248f24329456e19dfa042fff9986f72 `json:"messages,required"` - Result RuleDeleteResponse `json:"result,required"` + Result Properties `json:"result,required"` // Whether the API call was successful Success RuleDeleteResponseEnvelopeSuccess `json:"success,required"` JSON ruleDeleteResponseEnvelopeJSON `json:"-"` @@ -1271,7 +647,7 @@ func (r RuleDeleteResponseEnvelopeSuccess) IsKnown() bool { type RuleGetResponseEnvelope struct { Errors []shared.UnnamedSchemaRef3248f24329456e19dfa042fff9986f72 `json:"errors,required"` Messages []shared.UnnamedSchemaRef3248f24329456e19dfa042fff9986f72 `json:"messages,required"` - Result RuleGetResponse `json:"result,required"` + Result Properties `json:"result,required"` // Whether the API call was successful Success RuleGetResponseEnvelopeSuccess `json:"success,required"` JSON ruleGetResponseEnvelopeJSON `json:"-"` diff --git a/email_routing/rule_test.go b/email_routing/rule_test.go index e0c99186cdf..8ad7fd30d89 100644 --- a/email_routing/rule_test.go +++ b/email_routing/rule_test.go @@ -32,27 +32,27 @@ func TestRuleNewWithOptionalParams(t *testing.T) { context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", email_routing.RuleNewParams{ - Actions: cloudflare.F([]email_routing.RuleNewParamsAction{{ - Type: cloudflare.F(email_routing.RuleNewParamsActionsTypeForward), + Actions: cloudflare.F([]email_routing.ActionParam{{ + Type: cloudflare.F(email_routing.ActionTypeForward), Value: cloudflare.F([]string{"destinationaddress@example.net", "destinationaddress@example.net", "destinationaddress@example.net"}), }, { - Type: cloudflare.F(email_routing.RuleNewParamsActionsTypeForward), + Type: cloudflare.F(email_routing.ActionTypeForward), Value: cloudflare.F([]string{"destinationaddress@example.net", "destinationaddress@example.net", "destinationaddress@example.net"}), }, { - Type: cloudflare.F(email_routing.RuleNewParamsActionsTypeForward), + Type: cloudflare.F(email_routing.ActionTypeForward), Value: cloudflare.F([]string{"destinationaddress@example.net", "destinationaddress@example.net", "destinationaddress@example.net"}), }}), - Matchers: cloudflare.F([]email_routing.RuleNewParamsMatcher{{ - Field: cloudflare.F(email_routing.RuleNewParamsMatchersFieldTo), - Type: cloudflare.F(email_routing.RuleNewParamsMatchersTypeLiteral), + Matchers: cloudflare.F([]email_routing.MatcherParam{{ + Field: cloudflare.F(email_routing.MatcherFieldTo), + Type: cloudflare.F(email_routing.MatcherTypeLiteral), Value: cloudflare.F("test@example.com"), }, { - Field: cloudflare.F(email_routing.RuleNewParamsMatchersFieldTo), - Type: cloudflare.F(email_routing.RuleNewParamsMatchersTypeLiteral), + Field: cloudflare.F(email_routing.MatcherFieldTo), + Type: cloudflare.F(email_routing.MatcherTypeLiteral), Value: cloudflare.F("test@example.com"), }, { - Field: cloudflare.F(email_routing.RuleNewParamsMatchersFieldTo), - Type: cloudflare.F(email_routing.RuleNewParamsMatchersTypeLiteral), + Field: cloudflare.F(email_routing.MatcherFieldTo), + Type: cloudflare.F(email_routing.MatcherTypeLiteral), Value: cloudflare.F("test@example.com"), }}), Enabled: cloudflare.F(email_routing.RuleNewParamsEnabledTrue), @@ -88,27 +88,27 @@ func TestRuleUpdateWithOptionalParams(t *testing.T) { "023e105f4ecef8ad9ca31a8372d0c353", "a7e6fb77503c41d8a7f3113c6918f10c", email_routing.RuleUpdateParams{ - Actions: cloudflare.F([]email_routing.RuleUpdateParamsAction{{ - Type: cloudflare.F(email_routing.RuleUpdateParamsActionsTypeForward), + Actions: cloudflare.F([]email_routing.ActionItemParam{{ + Type: cloudflare.F(email_routing.ActionItemTypeForward), Value: cloudflare.F([]string{"destinationaddress@example.net", "destinationaddress@example.net", "destinationaddress@example.net"}), }, { - Type: cloudflare.F(email_routing.RuleUpdateParamsActionsTypeForward), + Type: cloudflare.F(email_routing.ActionItemTypeForward), Value: cloudflare.F([]string{"destinationaddress@example.net", "destinationaddress@example.net", "destinationaddress@example.net"}), }, { - Type: cloudflare.F(email_routing.RuleUpdateParamsActionsTypeForward), + Type: cloudflare.F(email_routing.ActionItemTypeForward), Value: cloudflare.F([]string{"destinationaddress@example.net", "destinationaddress@example.net", "destinationaddress@example.net"}), }}), - Matchers: cloudflare.F([]email_routing.RuleUpdateParamsMatcher{{ - Field: cloudflare.F(email_routing.RuleUpdateParamsMatchersFieldTo), - Type: cloudflare.F(email_routing.RuleUpdateParamsMatchersTypeLiteral), + Matchers: cloudflare.F([]email_routing.MatcherItemParam{{ + Field: cloudflare.F(email_routing.MatcherItemFieldTo), + Type: cloudflare.F(email_routing.MatcherItemTypeLiteral), Value: cloudflare.F("test@example.com"), }, { - Field: cloudflare.F(email_routing.RuleUpdateParamsMatchersFieldTo), - Type: cloudflare.F(email_routing.RuleUpdateParamsMatchersTypeLiteral), + Field: cloudflare.F(email_routing.MatcherItemFieldTo), + Type: cloudflare.F(email_routing.MatcherItemTypeLiteral), Value: cloudflare.F("test@example.com"), }, { - Field: cloudflare.F(email_routing.RuleUpdateParamsMatchersFieldTo), - Type: cloudflare.F(email_routing.RuleUpdateParamsMatchersTypeLiteral), + Field: cloudflare.F(email_routing.MatcherItemFieldTo), + Type: cloudflare.F(email_routing.MatcherItemTypeLiteral), Value: cloudflare.F("test@example.com"), }}), Enabled: cloudflare.F(email_routing.RuleUpdateParamsEnabledTrue), diff --git a/email_routing/rulecatchall.go b/email_routing/rulecatchall.go index e3f6dd22253..944e1e39527 100644 --- a/email_routing/rulecatchall.go +++ b/email_routing/rulecatchall.go @@ -59,15 +59,67 @@ func (r *RuleCatchAllService) Get(ctx context.Context, zoneIdentifier string, op return } +// Action for the catch-all routing rule. +type Action struct { + // Type of action for catch-all rule. + Type ActionType `json:"type,required"` + Value []string `json:"value"` + JSON actionJSON `json:"-"` +} + +// actionJSON contains the JSON metadata for the struct [Action] +type actionJSON struct { + Type apijson.Field + Value apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *Action) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r actionJSON) RawJSON() string { + return r.raw +} + +// Type of action for catch-all rule. +type ActionType string + +const ( + ActionTypeDrop ActionType = "drop" + ActionTypeForward ActionType = "forward" + ActionTypeWorker ActionType = "worker" +) + +func (r ActionType) IsKnown() bool { + switch r { + case ActionTypeDrop, ActionTypeForward, ActionTypeWorker: + return true + } + return false +} + +// Action for the catch-all routing rule. +type ActionParam struct { + // Type of action for catch-all rule. + Type param.Field[ActionType] `json:"type,required"` + Value param.Field[[]string] `json:"value"` +} + +func (r ActionParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + type EmailCatchAllRule struct { // Routing rule identifier. ID string `json:"id"` // List actions for the catch-all routing rule. - Actions []EmailCatchAllRuleAction `json:"actions"` + Actions []Action `json:"actions"` // Routing rule status. Enabled EmailCatchAllRuleEnabled `json:"enabled"` // List of matchers for the catch-all routing rule. - Matchers []EmailCatchAllRuleMatcher `json:"matchers"` + Matchers []Matcher `json:"matchers"` // Routing rule name. Name string `json:"name"` // Routing rule tag. (Deprecated, replaced by routing rule identifier) @@ -96,48 +148,6 @@ func (r emailCatchAllRuleJSON) RawJSON() string { return r.raw } -// Action for the catch-all routing rule. -type EmailCatchAllRuleAction struct { - // Type of action for catch-all rule. - Type EmailCatchAllRuleActionsType `json:"type,required"` - Value []string `json:"value"` - JSON emailCatchAllRuleActionJSON `json:"-"` -} - -// emailCatchAllRuleActionJSON contains the JSON metadata for the struct -// [EmailCatchAllRuleAction] -type emailCatchAllRuleActionJSON struct { - Type apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *EmailCatchAllRuleAction) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r emailCatchAllRuleActionJSON) RawJSON() string { - return r.raw -} - -// Type of action for catch-all rule. -type EmailCatchAllRuleActionsType string - -const ( - EmailCatchAllRuleActionsTypeDrop EmailCatchAllRuleActionsType = "drop" - EmailCatchAllRuleActionsTypeForward EmailCatchAllRuleActionsType = "forward" - EmailCatchAllRuleActionsTypeWorker EmailCatchAllRuleActionsType = "worker" -) - -func (r EmailCatchAllRuleActionsType) IsKnown() bool { - switch r { - case EmailCatchAllRuleActionsTypeDrop, EmailCatchAllRuleActionsTypeForward, EmailCatchAllRuleActionsTypeWorker: - return true - } - return false -} - // Routing rule status. type EmailCatchAllRuleEnabled bool @@ -155,48 +165,57 @@ func (r EmailCatchAllRuleEnabled) IsKnown() bool { } // Matcher for catch-all routing rule. -type EmailCatchAllRuleMatcher struct { +type Matcher struct { // Type of matcher. Default is 'all'. - Type EmailCatchAllRuleMatchersType `json:"type,required"` - JSON emailCatchAllRuleMatcherJSON `json:"-"` + Type MatcherType `json:"type,required"` + JSON matcherJSON `json:"-"` } -// emailCatchAllRuleMatcherJSON contains the JSON metadata for the struct -// [EmailCatchAllRuleMatcher] -type emailCatchAllRuleMatcherJSON struct { +// matcherJSON contains the JSON metadata for the struct [Matcher] +type matcherJSON struct { Type apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *EmailCatchAllRuleMatcher) UnmarshalJSON(data []byte) (err error) { +func (r *Matcher) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r emailCatchAllRuleMatcherJSON) RawJSON() string { +func (r matcherJSON) RawJSON() string { return r.raw } // Type of matcher. Default is 'all'. -type EmailCatchAllRuleMatchersType string +type MatcherType string const ( - EmailCatchAllRuleMatchersTypeAll EmailCatchAllRuleMatchersType = "all" + MatcherTypeAll MatcherType = "all" ) -func (r EmailCatchAllRuleMatchersType) IsKnown() bool { +func (r MatcherType) IsKnown() bool { switch r { - case EmailCatchAllRuleMatchersTypeAll: + case MatcherTypeAll: return true } return false } +// Matcher for catch-all routing rule. +type MatcherParam struct { + // Type of matcher. Default is 'all'. + Type param.Field[MatcherType] `json:"type,required"` +} + +func (r MatcherParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + type RuleCatchAllUpdateParams struct { // List actions for the catch-all routing rule. - Actions param.Field[[]RuleCatchAllUpdateParamsAction] `json:"actions,required"` + Actions param.Field[[]ActionParam] `json:"actions,required"` // List of matchers for the catch-all routing rule. - Matchers param.Field[[]RuleCatchAllUpdateParamsMatcher] `json:"matchers,required"` + Matchers param.Field[[]MatcherParam] `json:"matchers,required"` // Routing rule status. Enabled param.Field[RuleCatchAllUpdateParamsEnabled] `json:"enabled"` // Routing rule name. @@ -207,59 +226,6 @@ func (r RuleCatchAllUpdateParams) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -// Action for the catch-all routing rule. -type RuleCatchAllUpdateParamsAction struct { - // Type of action for catch-all rule. - Type param.Field[RuleCatchAllUpdateParamsActionsType] `json:"type,required"` - Value param.Field[[]string] `json:"value"` -} - -func (r RuleCatchAllUpdateParamsAction) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Type of action for catch-all rule. -type RuleCatchAllUpdateParamsActionsType string - -const ( - RuleCatchAllUpdateParamsActionsTypeDrop RuleCatchAllUpdateParamsActionsType = "drop" - RuleCatchAllUpdateParamsActionsTypeForward RuleCatchAllUpdateParamsActionsType = "forward" - RuleCatchAllUpdateParamsActionsTypeWorker RuleCatchAllUpdateParamsActionsType = "worker" -) - -func (r RuleCatchAllUpdateParamsActionsType) IsKnown() bool { - switch r { - case RuleCatchAllUpdateParamsActionsTypeDrop, RuleCatchAllUpdateParamsActionsTypeForward, RuleCatchAllUpdateParamsActionsTypeWorker: - return true - } - return false -} - -// Matcher for catch-all routing rule. -type RuleCatchAllUpdateParamsMatcher struct { - // Type of matcher. Default is 'all'. - Type param.Field[RuleCatchAllUpdateParamsMatchersType] `json:"type,required"` -} - -func (r RuleCatchAllUpdateParamsMatcher) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Type of matcher. Default is 'all'. -type RuleCatchAllUpdateParamsMatchersType string - -const ( - RuleCatchAllUpdateParamsMatchersTypeAll RuleCatchAllUpdateParamsMatchersType = "all" -) - -func (r RuleCatchAllUpdateParamsMatchersType) IsKnown() bool { - switch r { - case RuleCatchAllUpdateParamsMatchersTypeAll: - return true - } - return false -} - // Routing rule status. type RuleCatchAllUpdateParamsEnabled bool diff --git a/email_routing/rulecatchall_test.go b/email_routing/rulecatchall_test.go index 12a6fa61cd9..6bb360e997b 100644 --- a/email_routing/rulecatchall_test.go +++ b/email_routing/rulecatchall_test.go @@ -32,22 +32,22 @@ func TestRuleCatchAllUpdateWithOptionalParams(t *testing.T) { context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", email_routing.RuleCatchAllUpdateParams{ - Actions: cloudflare.F([]email_routing.RuleCatchAllUpdateParamsAction{{ - Type: cloudflare.F(email_routing.RuleCatchAllUpdateParamsActionsTypeForward), + Actions: cloudflare.F([]email_routing.ActionParam{{ + Type: cloudflare.F(email_routing.ActionTypeForward), Value: cloudflare.F([]string{"destinationaddress@example.net", "destinationaddress@example.net", "destinationaddress@example.net"}), }, { - Type: cloudflare.F(email_routing.RuleCatchAllUpdateParamsActionsTypeForward), + Type: cloudflare.F(email_routing.ActionTypeForward), Value: cloudflare.F([]string{"destinationaddress@example.net", "destinationaddress@example.net", "destinationaddress@example.net"}), }, { - Type: cloudflare.F(email_routing.RuleCatchAllUpdateParamsActionsTypeForward), + Type: cloudflare.F(email_routing.ActionTypeForward), Value: cloudflare.F([]string{"destinationaddress@example.net", "destinationaddress@example.net", "destinationaddress@example.net"}), }}), - Matchers: cloudflare.F([]email_routing.RuleCatchAllUpdateParamsMatcher{{ - Type: cloudflare.F(email_routing.RuleCatchAllUpdateParamsMatchersTypeAll), + Matchers: cloudflare.F([]email_routing.MatcherParam{{ + Type: cloudflare.F(email_routing.MatcherTypeAll), }, { - Type: cloudflare.F(email_routing.RuleCatchAllUpdateParamsMatchersTypeAll), + Type: cloudflare.F(email_routing.MatcherTypeAll), }, { - Type: cloudflare.F(email_routing.RuleCatchAllUpdateParamsMatchersTypeAll), + Type: cloudflare.F(email_routing.MatcherTypeAll), }}), Enabled: cloudflare.F(email_routing.RuleCatchAllUpdateParamsEnabledTrue), Name: cloudflare.F("Send to user@example.net rule."), diff --git a/internal/shared/union.go b/internal/shared/union.go index 94519910dda..e7a72d45574 100644 --- a/internal/shared/union.go +++ b/internal/shared/union.go @@ -16,9 +16,10 @@ func (UnionString) ImplementsLoadBalancersRegionGetResponseUnion() func (UnionString) ImplementsCacheCachePurgeParamsCachePurgeFilesFileUnion() {} func (UnionString) ImplementsDNSDNSFirewallDNSFirewallIPsUnion() {} func (UnionString) ImplementsDNSDNSFirewallUpstreamIPsUnion() {} -func (UnionString) ImplementsDNSFirewallNewParamsUpstreamIPUnion() {} -func (UnionString) ImplementsDNSFirewallEditParamsDNSFirewallIPUnion() {} -func (UnionString) ImplementsDNSFirewallEditParamsUpstreamIPUnion() {} +func (UnionString) ImplementsDNSFirewallIPsItemUnionParam() {} +func (UnionString) ImplementsDNSFirewallIPsItemUnion() {} +func (UnionString) ImplementsDNSUpstreamIPsItemsUnionParam() {} +func (UnionString) ImplementsDNSUpstreamIPsItemsUnion() {} func (UnionString) ImplementsLogsReceivedGetParamsEndUnion() {} func (UnionString) ImplementsLogsReceivedGetParamsStartUnion() {} func (UnionString) ImplementsWorkersAIRunResponseUnion() {} @@ -47,9 +48,8 @@ func (UnionString) ImplementsRulesListItemGetResponseUnion() func (UnionString) ImplementsStreamCaptionDeleteResponseUnion() {} func (UnionString) ImplementsAlertingAvailableAlertListResponseUnion() {} func (UnionString) ImplementsAlertingDestinationEligibleGetResponseUnion() {} -func (UnionString) ImplementsAlertingAlertingPoliciesMechanismsIDUnion() {} -func (UnionString) ImplementsAlertingPolicyNewParamsMechanismsIDUnion() {} -func (UnionString) ImplementsAlertingPolicyUpdateParamsMechanismsIDUnion() {} +func (UnionString) ImplementsAlertingMechanismsIDUnionParam() {} +func (UnionString) ImplementsAlertingMechanismsIDUnion() {} func (UnionString) ImplementsWARPConnectorWARPConnectorTokenResponseUnion() {} func (UnionString) ImplementsZeroTrustAccessApplicationUpdateParamsSelfHostedApplicationAppIDUnion() { } diff --git a/load_balancers/loadbalancer.go b/load_balancers/loadbalancer.go index 5a55297c4b8..d40e8aa5f98 100644 --- a/load_balancers/loadbalancer.go +++ b/load_balancers/loadbalancer.go @@ -132,6 +132,119 @@ func (r *LoadBalancerService) Get(ctx context.Context, loadBalancerID string, qu return } +// WNAM: Western North America, ENAM: Eastern North America, WEU: Western Europe, +// EEU: Eastern Europe, NSAM: Northern South America, SSAM: Southern South America, +// OC: Oceania, ME: Middle East, NAF: North Africa, SAF: South Africa, SAS: +// Southern Asia, SEAS: South East Asia, NEAS: North East Asia, ALL_REGIONS: all +// regions (ENTERPRISE customers only). +type CheckRegion string + +const ( + CheckRegionWnam CheckRegion = "WNAM" + CheckRegionEnam CheckRegion = "ENAM" + CheckRegionWeu CheckRegion = "WEU" + CheckRegionEeu CheckRegion = "EEU" + CheckRegionNsam CheckRegion = "NSAM" + CheckRegionSsam CheckRegion = "SSAM" + CheckRegionOc CheckRegion = "OC" + CheckRegionMe CheckRegion = "ME" + CheckRegionNaf CheckRegion = "NAF" + CheckRegionSaf CheckRegion = "SAF" + CheckRegionSas CheckRegion = "SAS" + CheckRegionSeas CheckRegion = "SEAS" + CheckRegionNeas CheckRegion = "NEAS" + CheckRegionAllRegions CheckRegion = "ALL_REGIONS" +) + +func (r CheckRegion) IsKnown() bool { + switch r { + case CheckRegionWnam, CheckRegionEnam, CheckRegionWeu, CheckRegionEeu, CheckRegionNsam, CheckRegionSsam, CheckRegionOc, CheckRegionMe, CheckRegionNaf, CheckRegionSaf, CheckRegionSas, CheckRegionSeas, CheckRegionNeas, CheckRegionAllRegions: + return true + } + return false +} + +// Filter options for a particular resource type (pool or origin). Use null to +// reset. +type FilterOptions struct { + // If set true, disable notifications for this type of resource (pool or origin). + Disable bool `json:"disable"` + // If present, send notifications only for this health status (e.g. false for only + // DOWN events). Use null to reset (all events). + Healthy bool `json:"healthy,nullable"` + JSON filterOptionsJSON `json:"-"` +} + +// filterOptionsJSON contains the JSON metadata for the struct [FilterOptions] +type filterOptionsJSON struct { + Disable apijson.Field + Healthy apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *FilterOptions) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r filterOptionsJSON) RawJSON() string { + return r.raw +} + +// Filter options for a particular resource type (pool or origin). Use null to +// reset. +type FilterOptionsParam struct { + // If set true, disable notifications for this type of resource (pool or origin). + Disable param.Field[bool] `json:"disable"` + // If present, send notifications only for this health status (e.g. false for only + // DOWN events). Use null to reset (all events). + Healthy param.Field[bool] `json:"healthy"` +} + +func (r FilterOptionsParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// The request header is used to pass additional information with an HTTP request. +// Currently supported header is 'Host'. +type Header struct { + // The 'Host' header allows to override the hostname set in the HTTP request. + // Current support is 1 'Host' header override per origin. + Host []HostItem `json:"Host"` + JSON headerJSON `json:"-"` +} + +// headerJSON contains the JSON metadata for the struct [Header] +type headerJSON struct { + Host apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *Header) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r headerJSON) RawJSON() string { + return r.raw +} + +// The request header is used to pass additional information with an HTTP request. +// Currently supported header is 'Host'. +type HeaderParam struct { + // The 'Host' header allows to override the hostname set in the HTTP request. + // Current support is 1 'Host' header override per origin. + Host param.Field[[]HostItemParam] `json:"Host"` +} + +func (r HeaderParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type HostItem = string + +type HostItemParam = string + type LoadBalancer struct { ID string `json:"id"` // Controls features that modify the routing of requests to pools and origins in @@ -1254,6 +1367,406 @@ func (r LoadBalancerSteeringPolicy) IsKnown() bool { return false } +// Configures load shedding policies and percentages for the pool. +type LoadShedding struct { + // The percent of traffic to shed from the pool, according to the default policy. + // Applies to new sessions and traffic without session affinity. + DefaultPercent float64 `json:"default_percent"` + // The default policy to use when load shedding. A random policy randomly sheds a + // given percent of requests. A hash policy computes a hash over the + // CF-Connecting-IP address and sheds all requests originating from a percent of + // IPs. + DefaultPolicy LoadSheddingDefaultPolicy `json:"default_policy"` + // The percent of existing sessions to shed from the pool, according to the session + // policy. + SessionPercent float64 `json:"session_percent"` + // Only the hash policy is supported for existing sessions (to avoid exponential + // decay). + SessionPolicy LoadSheddingSessionPolicy `json:"session_policy"` + JSON loadSheddingJSON `json:"-"` +} + +// loadSheddingJSON contains the JSON metadata for the struct [LoadShedding] +type loadSheddingJSON struct { + DefaultPercent apijson.Field + DefaultPolicy apijson.Field + SessionPercent apijson.Field + SessionPolicy apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *LoadShedding) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r loadSheddingJSON) RawJSON() string { + return r.raw +} + +// The default policy to use when load shedding. A random policy randomly sheds a +// given percent of requests. A hash policy computes a hash over the +// CF-Connecting-IP address and sheds all requests originating from a percent of +// IPs. +type LoadSheddingDefaultPolicy string + +const ( + LoadSheddingDefaultPolicyRandom LoadSheddingDefaultPolicy = "random" + LoadSheddingDefaultPolicyHash LoadSheddingDefaultPolicy = "hash" +) + +func (r LoadSheddingDefaultPolicy) IsKnown() bool { + switch r { + case LoadSheddingDefaultPolicyRandom, LoadSheddingDefaultPolicyHash: + return true + } + return false +} + +// Only the hash policy is supported for existing sessions (to avoid exponential +// decay). +type LoadSheddingSessionPolicy string + +const ( + LoadSheddingSessionPolicyHash LoadSheddingSessionPolicy = "hash" +) + +func (r LoadSheddingSessionPolicy) IsKnown() bool { + switch r { + case LoadSheddingSessionPolicyHash: + return true + } + return false +} + +// Configures load shedding policies and percentages for the pool. +type LoadSheddingParam struct { + // The percent of traffic to shed from the pool, according to the default policy. + // Applies to new sessions and traffic without session affinity. + DefaultPercent param.Field[float64] `json:"default_percent"` + // The default policy to use when load shedding. A random policy randomly sheds a + // given percent of requests. A hash policy computes a hash over the + // CF-Connecting-IP address and sheds all requests originating from a percent of + // IPs. + DefaultPolicy param.Field[LoadSheddingDefaultPolicy] `json:"default_policy"` + // The percent of existing sessions to shed from the pool, according to the session + // policy. + SessionPercent param.Field[float64] `json:"session_percent"` + // Only the hash policy is supported for existing sessions (to avoid exponential + // decay). + SessionPolicy param.Field[LoadSheddingSessionPolicy] `json:"session_policy"` +} + +func (r LoadSheddingParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Filter pool and origin health notifications by resource type or health status. +// Use null to reset. +type NotificationFilter struct { + // Filter options for a particular resource type (pool or origin). Use null to + // reset. + Origin FilterOptions `json:"origin,nullable"` + // Filter options for a particular resource type (pool or origin). Use null to + // reset. + Pool FilterOptions `json:"pool,nullable"` + JSON notificationFilterJSON `json:"-"` +} + +// notificationFilterJSON contains the JSON metadata for the struct +// [NotificationFilter] +type notificationFilterJSON struct { + Origin apijson.Field + Pool apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *NotificationFilter) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r notificationFilterJSON) RawJSON() string { + return r.raw +} + +// Filter pool and origin health notifications by resource type or health status. +// Use null to reset. +type NotificationFilterParam struct { + // Filter options for a particular resource type (pool or origin). Use null to + // reset. + Origin param.Field[FilterOptionsParam] `json:"origin"` + // Filter options for a particular resource type (pool or origin). Use null to + // reset. + Pool param.Field[FilterOptionsParam] `json:"pool"` +} + +func (r NotificationFilterParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type Origin struct { + // The IP address (IPv4 or IPv6) of the origin, or its publicly addressable + // hostname. Hostnames entered here should resolve directly to the origin, and not + // be a hostname proxied by Cloudflare. To set an internal/reserved address, + // virtual_network_id must also be set. + Address string `json:"address"` + // This field shows up only if the origin is disabled. This field is set with the + // time the origin was disabled. + DisabledAt time.Time `json:"disabled_at" format:"date-time"` + // Whether to enable (the default) this origin within the pool. Disabled origins + // will not receive traffic and are excluded from health checks. The origin will + // only be disabled for the current pool. + Enabled bool `json:"enabled"` + // The request header is used to pass additional information with an HTTP request. + // Currently supported header is 'Host'. + Header Header `json:"header"` + // A human-identifiable name for the origin. + Name string `json:"name"` + // The virtual network subnet ID the origin belongs in. Virtual network must also + // belong to the account. + VirtualNetworkID string `json:"virtual_network_id"` + // The weight of this origin relative to other origins in the pool. Based on the + // configured weight the total traffic is distributed among origins within the + // pool. + // + // - `origin_steering.policy="least_outstanding_requests"`: Use weight to scale the + // origin's outstanding requests. + // - `origin_steering.policy="least_connections"`: Use weight to scale the origin's + // open connections. + Weight float64 `json:"weight"` + JSON originJSON `json:"-"` +} + +// originJSON contains the JSON metadata for the struct [Origin] +type originJSON struct { + Address apijson.Field + DisabledAt apijson.Field + Enabled apijson.Field + Header apijson.Field + Name apijson.Field + VirtualNetworkID apijson.Field + Weight apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *Origin) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r originJSON) RawJSON() string { + return r.raw +} + +type OriginParam struct { + // The IP address (IPv4 or IPv6) of the origin, or its publicly addressable + // hostname. Hostnames entered here should resolve directly to the origin, and not + // be a hostname proxied by Cloudflare. To set an internal/reserved address, + // virtual_network_id must also be set. + Address param.Field[string] `json:"address"` + // Whether to enable (the default) this origin within the pool. Disabled origins + // will not receive traffic and are excluded from health checks. The origin will + // only be disabled for the current pool. + Enabled param.Field[bool] `json:"enabled"` + // The request header is used to pass additional information with an HTTP request. + // Currently supported header is 'Host'. + Header param.Field[HeaderParam] `json:"header"` + // A human-identifiable name for the origin. + Name param.Field[string] `json:"name"` + // The virtual network subnet ID the origin belongs in. Virtual network must also + // belong to the account. + VirtualNetworkID param.Field[string] `json:"virtual_network_id"` + // The weight of this origin relative to other origins in the pool. Based on the + // configured weight the total traffic is distributed among origins within the + // pool. + // + // - `origin_steering.policy="least_outstanding_requests"`: Use weight to scale the + // origin's outstanding requests. + // - `origin_steering.policy="least_connections"`: Use weight to scale the origin's + // open connections. + Weight param.Field[float64] `json:"weight"` +} + +func (r OriginParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +type OriginItem struct { + // The IP address (IPv4 or IPv6) of the origin, or its publicly addressable + // hostname. Hostnames entered here should resolve directly to the origin, and not + // be a hostname proxied by Cloudflare. To set an internal/reserved address, + // virtual_network_id must also be set. + Address string `json:"address"` + // This field shows up only if the origin is disabled. This field is set with the + // time the origin was disabled. + DisabledAt time.Time `json:"disabled_at" format:"date-time"` + // Whether to enable (the default) this origin within the pool. Disabled origins + // will not receive traffic and are excluded from health checks. The origin will + // only be disabled for the current pool. + Enabled bool `json:"enabled"` + // The request header is used to pass additional information with an HTTP request. + // Currently supported header is 'Host'. + Header Header `json:"header"` + // A human-identifiable name for the origin. + Name string `json:"name"` + // The virtual network subnet ID the origin belongs in. Virtual network must also + // belong to the account. + VirtualNetworkID string `json:"virtual_network_id"` + // The weight of this origin relative to other origins in the pool. Based on the + // configured weight the total traffic is distributed among origins within the + // pool. + // + // - `origin_steering.policy="least_outstanding_requests"`: Use weight to scale the + // origin's outstanding requests. + // - `origin_steering.policy="least_connections"`: Use weight to scale the origin's + // open connections. + Weight float64 `json:"weight"` + JSON originItemJSON `json:"-"` +} + +// originItemJSON contains the JSON metadata for the struct [OriginItem] +type originItemJSON struct { + Address apijson.Field + DisabledAt apijson.Field + Enabled apijson.Field + Header apijson.Field + Name apijson.Field + VirtualNetworkID apijson.Field + Weight apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *OriginItem) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r originItemJSON) RawJSON() string { + return r.raw +} + +type OriginItemParam struct { + // The IP address (IPv4 or IPv6) of the origin, or its publicly addressable + // hostname. Hostnames entered here should resolve directly to the origin, and not + // be a hostname proxied by Cloudflare. To set an internal/reserved address, + // virtual_network_id must also be set. + Address param.Field[string] `json:"address"` + // Whether to enable (the default) this origin within the pool. Disabled origins + // will not receive traffic and are excluded from health checks. The origin will + // only be disabled for the current pool. + Enabled param.Field[bool] `json:"enabled"` + // The request header is used to pass additional information with an HTTP request. + // Currently supported header is 'Host'. + Header param.Field[HeaderParam] `json:"header"` + // A human-identifiable name for the origin. + Name param.Field[string] `json:"name"` + // The virtual network subnet ID the origin belongs in. Virtual network must also + // belong to the account. + VirtualNetworkID param.Field[string] `json:"virtual_network_id"` + // The weight of this origin relative to other origins in the pool. Based on the + // configured weight the total traffic is distributed among origins within the + // pool. + // + // - `origin_steering.policy="least_outstanding_requests"`: Use weight to scale the + // origin's outstanding requests. + // - `origin_steering.policy="least_connections"`: Use weight to scale the origin's + // open connections. + Weight param.Field[float64] `json:"weight"` +} + +func (r OriginItemParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + +// Configures origin steering for the pool. Controls how origins are selected for +// new sessions and traffic without session affinity. +type OriginSteering struct { + // The type of origin steering policy to use. + // + // - `"random"`: Select an origin randomly. + // - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP + // address. + // - `"least_outstanding_requests"`: Select an origin by taking into consideration + // origin weights, as well as each origin's number of outstanding requests. + // Origins with more pending requests are weighted proportionately less relative + // to others. + // - `"least_connections"`: Select an origin by taking into consideration origin + // weights, as well as each origin's number of open connections. Origins with + // more open connections are weighted proportionately less relative to others. + // Supported for HTTP/1 and HTTP/2 connections. + Policy OriginSteeringPolicy `json:"policy"` + JSON originSteeringJSON `json:"-"` +} + +// originSteeringJSON contains the JSON metadata for the struct [OriginSteering] +type originSteeringJSON struct { + Policy apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *OriginSteering) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r originSteeringJSON) RawJSON() string { + return r.raw +} + +// The type of origin steering policy to use. +// +// - `"random"`: Select an origin randomly. +// - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP +// address. +// - `"least_outstanding_requests"`: Select an origin by taking into consideration +// origin weights, as well as each origin's number of outstanding requests. +// Origins with more pending requests are weighted proportionately less relative +// to others. +// - `"least_connections"`: Select an origin by taking into consideration origin +// weights, as well as each origin's number of open connections. Origins with +// more open connections are weighted proportionately less relative to others. +// Supported for HTTP/1 and HTTP/2 connections. +type OriginSteeringPolicy string + +const ( + OriginSteeringPolicyRandom OriginSteeringPolicy = "random" + OriginSteeringPolicyHash OriginSteeringPolicy = "hash" + OriginSteeringPolicyLeastOutstandingRequests OriginSteeringPolicy = "least_outstanding_requests" + OriginSteeringPolicyLeastConnections OriginSteeringPolicy = "least_connections" +) + +func (r OriginSteeringPolicy) IsKnown() bool { + switch r { + case OriginSteeringPolicyRandom, OriginSteeringPolicyHash, OriginSteeringPolicyLeastOutstandingRequests, OriginSteeringPolicyLeastConnections: + return true + } + return false +} + +// Configures origin steering for the pool. Controls how origins are selected for +// new sessions and traffic without session affinity. +type OriginSteeringParam struct { + // The type of origin steering policy to use. + // + // - `"random"`: Select an origin randomly. + // - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP + // address. + // - `"least_outstanding_requests"`: Select an origin by taking into consideration + // origin weights, as well as each origin's number of outstanding requests. + // Origins with more pending requests are weighted proportionately less relative + // to others. + // - `"least_connections"`: Select an origin by taking into consideration origin + // weights, as well as each origin's number of open connections. Origins with + // more open connections are weighted proportionately less relative to others. + // Supported for HTTP/1 and HTTP/2 connections. + Policy param.Field[OriginSteeringPolicy] `json:"policy"` +} + +func (r OriginSteeringParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + type LoadBalancerDeleteResponse struct { ID string `json:"id"` JSON loadBalancerDeleteResponseJSON `json:"-"` diff --git a/load_balancers/pool.go b/load_balancers/pool.go index c05d3e20b7b..982d9f35e7c 100644 --- a/load_balancers/pool.go +++ b/load_balancers/pool.go @@ -156,7 +156,7 @@ type PoolNewParams struct { Name param.Field[string] `json:"name,required"` // The list of origins within this pool. Traffic directed at this pool is balanced // across all currently healthy origins, provided the pool itself is healthy. - Origins param.Field[[]PoolNewParamsOrigin] `json:"origins,required"` + Origins param.Field[[]OriginItemParam] `json:"origins,required"` // A human-readable description of the pool. Description param.Field[string] `json:"description"` // Whether to enable (the default) or disable this pool. Disabled pools will not @@ -167,7 +167,7 @@ type PoolNewParams struct { // decimal degrees. If this is set, longitude must also be set. Latitude param.Field[float64] `json:"latitude"` // Configures load shedding policies and percentages for the pool. - LoadShedding param.Field[PoolNewParamsLoadShedding] `json:"load_shedding"` + LoadShedding param.Field[LoadSheddingParam] `json:"load_shedding"` // The longitude of the data center containing the origins used in this pool in // decimal degrees. If this is set, latitude must also be set. Longitude param.Field[float64] `json:"longitude"` @@ -186,214 +186,16 @@ type PoolNewParams struct { NotificationEmail param.Field[string] `json:"notification_email"` // Filter pool and origin health notifications by resource type or health status. // Use null to reset. - NotificationFilter param.Field[PoolNewParamsNotificationFilter] `json:"notification_filter"` + NotificationFilter param.Field[NotificationFilterParam] `json:"notification_filter"` // Configures origin steering for the pool. Controls how origins are selected for // new sessions and traffic without session affinity. - OriginSteering param.Field[PoolNewParamsOriginSteering] `json:"origin_steering"` + OriginSteering param.Field[OriginSteeringParam] `json:"origin_steering"` } func (r PoolNewParams) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -type PoolNewParamsOrigin struct { - // The IP address (IPv4 or IPv6) of the origin, or its publicly addressable - // hostname. Hostnames entered here should resolve directly to the origin, and not - // be a hostname proxied by Cloudflare. To set an internal/reserved address, - // virtual_network_id must also be set. - Address param.Field[string] `json:"address"` - // Whether to enable (the default) this origin within the pool. Disabled origins - // will not receive traffic and are excluded from health checks. The origin will - // only be disabled for the current pool. - Enabled param.Field[bool] `json:"enabled"` - // The request header is used to pass additional information with an HTTP request. - // Currently supported header is 'Host'. - Header param.Field[PoolNewParamsOriginsHeader] `json:"header"` - // A human-identifiable name for the origin. - Name param.Field[string] `json:"name"` - // The virtual network subnet ID the origin belongs in. Virtual network must also - // belong to the account. - VirtualNetworkID param.Field[string] `json:"virtual_network_id"` - // The weight of this origin relative to other origins in the pool. Based on the - // configured weight the total traffic is distributed among origins within the - // pool. - // - // - `origin_steering.policy="least_outstanding_requests"`: Use weight to scale the - // origin's outstanding requests. - // - `origin_steering.policy="least_connections"`: Use weight to scale the origin's - // open connections. - Weight param.Field[float64] `json:"weight"` -} - -func (r PoolNewParamsOrigin) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The request header is used to pass additional information with an HTTP request. -// Currently supported header is 'Host'. -type PoolNewParamsOriginsHeader struct { - // The 'Host' header allows to override the hostname set in the HTTP request. - // Current support is 1 'Host' header override per origin. - Host param.Field[[]string] `json:"Host"` -} - -func (r PoolNewParamsOriginsHeader) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Configures load shedding policies and percentages for the pool. -type PoolNewParamsLoadShedding struct { - // The percent of traffic to shed from the pool, according to the default policy. - // Applies to new sessions and traffic without session affinity. - DefaultPercent param.Field[float64] `json:"default_percent"` - // The default policy to use when load shedding. A random policy randomly sheds a - // given percent of requests. A hash policy computes a hash over the - // CF-Connecting-IP address and sheds all requests originating from a percent of - // IPs. - DefaultPolicy param.Field[PoolNewParamsLoadSheddingDefaultPolicy] `json:"default_policy"` - // The percent of existing sessions to shed from the pool, according to the session - // policy. - SessionPercent param.Field[float64] `json:"session_percent"` - // Only the hash policy is supported for existing sessions (to avoid exponential - // decay). - SessionPolicy param.Field[PoolNewParamsLoadSheddingSessionPolicy] `json:"session_policy"` -} - -func (r PoolNewParamsLoadShedding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The default policy to use when load shedding. A random policy randomly sheds a -// given percent of requests. A hash policy computes a hash over the -// CF-Connecting-IP address and sheds all requests originating from a percent of -// IPs. -type PoolNewParamsLoadSheddingDefaultPolicy string - -const ( - PoolNewParamsLoadSheddingDefaultPolicyRandom PoolNewParamsLoadSheddingDefaultPolicy = "random" - PoolNewParamsLoadSheddingDefaultPolicyHash PoolNewParamsLoadSheddingDefaultPolicy = "hash" -) - -func (r PoolNewParamsLoadSheddingDefaultPolicy) IsKnown() bool { - switch r { - case PoolNewParamsLoadSheddingDefaultPolicyRandom, PoolNewParamsLoadSheddingDefaultPolicyHash: - return true - } - return false -} - -// Only the hash policy is supported for existing sessions (to avoid exponential -// decay). -type PoolNewParamsLoadSheddingSessionPolicy string - -const ( - PoolNewParamsLoadSheddingSessionPolicyHash PoolNewParamsLoadSheddingSessionPolicy = "hash" -) - -func (r PoolNewParamsLoadSheddingSessionPolicy) IsKnown() bool { - switch r { - case PoolNewParamsLoadSheddingSessionPolicyHash: - return true - } - return false -} - -// Filter pool and origin health notifications by resource type or health status. -// Use null to reset. -type PoolNewParamsNotificationFilter struct { - // Filter options for a particular resource type (pool or origin). Use null to - // reset. - Origin param.Field[PoolNewParamsNotificationFilterOrigin] `json:"origin"` - // Filter options for a particular resource type (pool or origin). Use null to - // reset. - Pool param.Field[PoolNewParamsNotificationFilterPool] `json:"pool"` -} - -func (r PoolNewParamsNotificationFilter) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Filter options for a particular resource type (pool or origin). Use null to -// reset. -type PoolNewParamsNotificationFilterOrigin struct { - // If set true, disable notifications for this type of resource (pool or origin). - Disable param.Field[bool] `json:"disable"` - // If present, send notifications only for this health status (e.g. false for only - // DOWN events). Use null to reset (all events). - Healthy param.Field[bool] `json:"healthy"` -} - -func (r PoolNewParamsNotificationFilterOrigin) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Filter options for a particular resource type (pool or origin). Use null to -// reset. -type PoolNewParamsNotificationFilterPool struct { - // If set true, disable notifications for this type of resource (pool or origin). - Disable param.Field[bool] `json:"disable"` - // If present, send notifications only for this health status (e.g. false for only - // DOWN events). Use null to reset (all events). - Healthy param.Field[bool] `json:"healthy"` -} - -func (r PoolNewParamsNotificationFilterPool) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Configures origin steering for the pool. Controls how origins are selected for -// new sessions and traffic without session affinity. -type PoolNewParamsOriginSteering struct { - // The type of origin steering policy to use. - // - // - `"random"`: Select an origin randomly. - // - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP - // address. - // - `"least_outstanding_requests"`: Select an origin by taking into consideration - // origin weights, as well as each origin's number of outstanding requests. - // Origins with more pending requests are weighted proportionately less relative - // to others. - // - `"least_connections"`: Select an origin by taking into consideration origin - // weights, as well as each origin's number of open connections. Origins with - // more open connections are weighted proportionately less relative to others. - // Supported for HTTP/1 and HTTP/2 connections. - Policy param.Field[PoolNewParamsOriginSteeringPolicy] `json:"policy"` -} - -func (r PoolNewParamsOriginSteering) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The type of origin steering policy to use. -// -// - `"random"`: Select an origin randomly. -// - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP -// address. -// - `"least_outstanding_requests"`: Select an origin by taking into consideration -// origin weights, as well as each origin's number of outstanding requests. -// Origins with more pending requests are weighted proportionately less relative -// to others. -// - `"least_connections"`: Select an origin by taking into consideration origin -// weights, as well as each origin's number of open connections. Origins with -// more open connections are weighted proportionately less relative to others. -// Supported for HTTP/1 and HTTP/2 connections. -type PoolNewParamsOriginSteeringPolicy string - -const ( - PoolNewParamsOriginSteeringPolicyRandom PoolNewParamsOriginSteeringPolicy = "random" - PoolNewParamsOriginSteeringPolicyHash PoolNewParamsOriginSteeringPolicy = "hash" - PoolNewParamsOriginSteeringPolicyLeastOutstandingRequests PoolNewParamsOriginSteeringPolicy = "least_outstanding_requests" - PoolNewParamsOriginSteeringPolicyLeastConnections PoolNewParamsOriginSteeringPolicy = "least_connections" -) - -func (r PoolNewParamsOriginSteeringPolicy) IsKnown() bool { - switch r { - case PoolNewParamsOriginSteeringPolicyRandom, PoolNewParamsOriginSteeringPolicyHash, PoolNewParamsOriginSteeringPolicyLeastOutstandingRequests, PoolNewParamsOriginSteeringPolicyLeastConnections: - return true - } - return false -} - type PoolNewResponseEnvelope struct { Errors []shared.UnnamedSchemaRef3248f24329456e19dfa042fff9986f72 `json:"errors,required"` Messages []shared.UnnamedSchemaRef3248f24329456e19dfa042fff9986f72 `json:"messages,required"` @@ -445,10 +247,10 @@ type PoolUpdateParams struct { Name param.Field[string] `json:"name,required"` // The list of origins within this pool. Traffic directed at this pool is balanced // across all currently healthy origins, provided the pool itself is healthy. - Origins param.Field[[]PoolUpdateParamsOrigin] `json:"origins,required"` + Origins param.Field[[]OriginItemParam] `json:"origins,required"` // A list of regions from which to run health checks. Null means every Cloudflare // data center. - CheckRegions param.Field[[]PoolUpdateParamsCheckRegion] `json:"check_regions"` + CheckRegions param.Field[[]CheckRegion] `json:"check_regions"` // A human-readable description of the pool. Description param.Field[string] `json:"description"` // Whether to enable (the default) or disable this pool. Disabled pools will not @@ -459,7 +261,7 @@ type PoolUpdateParams struct { // decimal degrees. If this is set, longitude must also be set. Latitude param.Field[float64] `json:"latitude"` // Configures load shedding policies and percentages for the pool. - LoadShedding param.Field[PoolUpdateParamsLoadShedding] `json:"load_shedding"` + LoadShedding param.Field[LoadSheddingParam] `json:"load_shedding"` // The longitude of the data center containing the origins used in this pool in // decimal degrees. If this is set, latitude must also be set. Longitude param.Field[float64] `json:"longitude"` @@ -478,246 +280,16 @@ type PoolUpdateParams struct { NotificationEmail param.Field[string] `json:"notification_email"` // Filter pool and origin health notifications by resource type or health status. // Use null to reset. - NotificationFilter param.Field[PoolUpdateParamsNotificationFilter] `json:"notification_filter"` + NotificationFilter param.Field[NotificationFilterParam] `json:"notification_filter"` // Configures origin steering for the pool. Controls how origins are selected for // new sessions and traffic without session affinity. - OriginSteering param.Field[PoolUpdateParamsOriginSteering] `json:"origin_steering"` + OriginSteering param.Field[OriginSteeringParam] `json:"origin_steering"` } func (r PoolUpdateParams) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -type PoolUpdateParamsOrigin struct { - // The IP address (IPv4 or IPv6) of the origin, or its publicly addressable - // hostname. Hostnames entered here should resolve directly to the origin, and not - // be a hostname proxied by Cloudflare. To set an internal/reserved address, - // virtual_network_id must also be set. - Address param.Field[string] `json:"address"` - // Whether to enable (the default) this origin within the pool. Disabled origins - // will not receive traffic and are excluded from health checks. The origin will - // only be disabled for the current pool. - Enabled param.Field[bool] `json:"enabled"` - // The request header is used to pass additional information with an HTTP request. - // Currently supported header is 'Host'. - Header param.Field[PoolUpdateParamsOriginsHeader] `json:"header"` - // A human-identifiable name for the origin. - Name param.Field[string] `json:"name"` - // The virtual network subnet ID the origin belongs in. Virtual network must also - // belong to the account. - VirtualNetworkID param.Field[string] `json:"virtual_network_id"` - // The weight of this origin relative to other origins in the pool. Based on the - // configured weight the total traffic is distributed among origins within the - // pool. - // - // - `origin_steering.policy="least_outstanding_requests"`: Use weight to scale the - // origin's outstanding requests. - // - `origin_steering.policy="least_connections"`: Use weight to scale the origin's - // open connections. - Weight param.Field[float64] `json:"weight"` -} - -func (r PoolUpdateParamsOrigin) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The request header is used to pass additional information with an HTTP request. -// Currently supported header is 'Host'. -type PoolUpdateParamsOriginsHeader struct { - // The 'Host' header allows to override the hostname set in the HTTP request. - // Current support is 1 'Host' header override per origin. - Host param.Field[[]string] `json:"Host"` -} - -func (r PoolUpdateParamsOriginsHeader) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// WNAM: Western North America, ENAM: Eastern North America, WEU: Western Europe, -// EEU: Eastern Europe, NSAM: Northern South America, SSAM: Southern South America, -// OC: Oceania, ME: Middle East, NAF: North Africa, SAF: South Africa, SAS: -// Southern Asia, SEAS: South East Asia, NEAS: North East Asia, ALL_REGIONS: all -// regions (ENTERPRISE customers only). -type PoolUpdateParamsCheckRegion string - -const ( - PoolUpdateParamsCheckRegionWnam PoolUpdateParamsCheckRegion = "WNAM" - PoolUpdateParamsCheckRegionEnam PoolUpdateParamsCheckRegion = "ENAM" - PoolUpdateParamsCheckRegionWeu PoolUpdateParamsCheckRegion = "WEU" - PoolUpdateParamsCheckRegionEeu PoolUpdateParamsCheckRegion = "EEU" - PoolUpdateParamsCheckRegionNsam PoolUpdateParamsCheckRegion = "NSAM" - PoolUpdateParamsCheckRegionSsam PoolUpdateParamsCheckRegion = "SSAM" - PoolUpdateParamsCheckRegionOc PoolUpdateParamsCheckRegion = "OC" - PoolUpdateParamsCheckRegionMe PoolUpdateParamsCheckRegion = "ME" - PoolUpdateParamsCheckRegionNaf PoolUpdateParamsCheckRegion = "NAF" - PoolUpdateParamsCheckRegionSaf PoolUpdateParamsCheckRegion = "SAF" - PoolUpdateParamsCheckRegionSas PoolUpdateParamsCheckRegion = "SAS" - PoolUpdateParamsCheckRegionSeas PoolUpdateParamsCheckRegion = "SEAS" - PoolUpdateParamsCheckRegionNeas PoolUpdateParamsCheckRegion = "NEAS" - PoolUpdateParamsCheckRegionAllRegions PoolUpdateParamsCheckRegion = "ALL_REGIONS" -) - -func (r PoolUpdateParamsCheckRegion) IsKnown() bool { - switch r { - case PoolUpdateParamsCheckRegionWnam, PoolUpdateParamsCheckRegionEnam, PoolUpdateParamsCheckRegionWeu, PoolUpdateParamsCheckRegionEeu, PoolUpdateParamsCheckRegionNsam, PoolUpdateParamsCheckRegionSsam, PoolUpdateParamsCheckRegionOc, PoolUpdateParamsCheckRegionMe, PoolUpdateParamsCheckRegionNaf, PoolUpdateParamsCheckRegionSaf, PoolUpdateParamsCheckRegionSas, PoolUpdateParamsCheckRegionSeas, PoolUpdateParamsCheckRegionNeas, PoolUpdateParamsCheckRegionAllRegions: - return true - } - return false -} - -// Configures load shedding policies and percentages for the pool. -type PoolUpdateParamsLoadShedding struct { - // The percent of traffic to shed from the pool, according to the default policy. - // Applies to new sessions and traffic without session affinity. - DefaultPercent param.Field[float64] `json:"default_percent"` - // The default policy to use when load shedding. A random policy randomly sheds a - // given percent of requests. A hash policy computes a hash over the - // CF-Connecting-IP address and sheds all requests originating from a percent of - // IPs. - DefaultPolicy param.Field[PoolUpdateParamsLoadSheddingDefaultPolicy] `json:"default_policy"` - // The percent of existing sessions to shed from the pool, according to the session - // policy. - SessionPercent param.Field[float64] `json:"session_percent"` - // Only the hash policy is supported for existing sessions (to avoid exponential - // decay). - SessionPolicy param.Field[PoolUpdateParamsLoadSheddingSessionPolicy] `json:"session_policy"` -} - -func (r PoolUpdateParamsLoadShedding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The default policy to use when load shedding. A random policy randomly sheds a -// given percent of requests. A hash policy computes a hash over the -// CF-Connecting-IP address and sheds all requests originating from a percent of -// IPs. -type PoolUpdateParamsLoadSheddingDefaultPolicy string - -const ( - PoolUpdateParamsLoadSheddingDefaultPolicyRandom PoolUpdateParamsLoadSheddingDefaultPolicy = "random" - PoolUpdateParamsLoadSheddingDefaultPolicyHash PoolUpdateParamsLoadSheddingDefaultPolicy = "hash" -) - -func (r PoolUpdateParamsLoadSheddingDefaultPolicy) IsKnown() bool { - switch r { - case PoolUpdateParamsLoadSheddingDefaultPolicyRandom, PoolUpdateParamsLoadSheddingDefaultPolicyHash: - return true - } - return false -} - -// Only the hash policy is supported for existing sessions (to avoid exponential -// decay). -type PoolUpdateParamsLoadSheddingSessionPolicy string - -const ( - PoolUpdateParamsLoadSheddingSessionPolicyHash PoolUpdateParamsLoadSheddingSessionPolicy = "hash" -) - -func (r PoolUpdateParamsLoadSheddingSessionPolicy) IsKnown() bool { - switch r { - case PoolUpdateParamsLoadSheddingSessionPolicyHash: - return true - } - return false -} - -// Filter pool and origin health notifications by resource type or health status. -// Use null to reset. -type PoolUpdateParamsNotificationFilter struct { - // Filter options for a particular resource type (pool or origin). Use null to - // reset. - Origin param.Field[PoolUpdateParamsNotificationFilterOrigin] `json:"origin"` - // Filter options for a particular resource type (pool or origin). Use null to - // reset. - Pool param.Field[PoolUpdateParamsNotificationFilterPool] `json:"pool"` -} - -func (r PoolUpdateParamsNotificationFilter) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Filter options for a particular resource type (pool or origin). Use null to -// reset. -type PoolUpdateParamsNotificationFilterOrigin struct { - // If set true, disable notifications for this type of resource (pool or origin). - Disable param.Field[bool] `json:"disable"` - // If present, send notifications only for this health status (e.g. false for only - // DOWN events). Use null to reset (all events). - Healthy param.Field[bool] `json:"healthy"` -} - -func (r PoolUpdateParamsNotificationFilterOrigin) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Filter options for a particular resource type (pool or origin). Use null to -// reset. -type PoolUpdateParamsNotificationFilterPool struct { - // If set true, disable notifications for this type of resource (pool or origin). - Disable param.Field[bool] `json:"disable"` - // If present, send notifications only for this health status (e.g. false for only - // DOWN events). Use null to reset (all events). - Healthy param.Field[bool] `json:"healthy"` -} - -func (r PoolUpdateParamsNotificationFilterPool) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Configures origin steering for the pool. Controls how origins are selected for -// new sessions and traffic without session affinity. -type PoolUpdateParamsOriginSteering struct { - // The type of origin steering policy to use. - // - // - `"random"`: Select an origin randomly. - // - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP - // address. - // - `"least_outstanding_requests"`: Select an origin by taking into consideration - // origin weights, as well as each origin's number of outstanding requests. - // Origins with more pending requests are weighted proportionately less relative - // to others. - // - `"least_connections"`: Select an origin by taking into consideration origin - // weights, as well as each origin's number of open connections. Origins with - // more open connections are weighted proportionately less relative to others. - // Supported for HTTP/1 and HTTP/2 connections. - Policy param.Field[PoolUpdateParamsOriginSteeringPolicy] `json:"policy"` -} - -func (r PoolUpdateParamsOriginSteering) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The type of origin steering policy to use. -// -// - `"random"`: Select an origin randomly. -// - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP -// address. -// - `"least_outstanding_requests"`: Select an origin by taking into consideration -// origin weights, as well as each origin's number of outstanding requests. -// Origins with more pending requests are weighted proportionately less relative -// to others. -// - `"least_connections"`: Select an origin by taking into consideration origin -// weights, as well as each origin's number of open connections. Origins with -// more open connections are weighted proportionately less relative to others. -// Supported for HTTP/1 and HTTP/2 connections. -type PoolUpdateParamsOriginSteeringPolicy string - -const ( - PoolUpdateParamsOriginSteeringPolicyRandom PoolUpdateParamsOriginSteeringPolicy = "random" - PoolUpdateParamsOriginSteeringPolicyHash PoolUpdateParamsOriginSteeringPolicy = "hash" - PoolUpdateParamsOriginSteeringPolicyLeastOutstandingRequests PoolUpdateParamsOriginSteeringPolicy = "least_outstanding_requests" - PoolUpdateParamsOriginSteeringPolicyLeastConnections PoolUpdateParamsOriginSteeringPolicy = "least_connections" -) - -func (r PoolUpdateParamsOriginSteeringPolicy) IsKnown() bool { - switch r { - case PoolUpdateParamsOriginSteeringPolicyRandom, PoolUpdateParamsOriginSteeringPolicyHash, PoolUpdateParamsOriginSteeringPolicyLeastOutstandingRequests, PoolUpdateParamsOriginSteeringPolicyLeastConnections: - return true - } - return false -} - type PoolUpdateResponseEnvelope struct { Errors []shared.UnnamedSchemaRef3248f24329456e19dfa042fff9986f72 `json:"errors,required"` Messages []shared.UnnamedSchemaRef3248f24329456e19dfa042fff9986f72 `json:"messages,required"` @@ -835,7 +407,7 @@ type PoolEditParams struct { AccountID param.Field[string] `path:"account_id,required"` // A list of regions from which to run health checks. Null means every Cloudflare // data center. - CheckRegions param.Field[[]PoolEditParamsCheckRegion] `json:"check_regions"` + CheckRegions param.Field[[]CheckRegion] `json:"check_regions"` // A human-readable description of the pool. Description param.Field[string] `json:"description"` // Whether to enable (the default) or disable this pool. Disabled pools will not @@ -846,7 +418,7 @@ type PoolEditParams struct { // decimal degrees. If this is set, longitude must also be set. Latitude param.Field[float64] `json:"latitude"` // Configures load shedding policies and percentages for the pool. - LoadShedding param.Field[PoolEditParamsLoadShedding] `json:"load_shedding"` + LoadShedding param.Field[LoadSheddingParam] `json:"load_shedding"` // The longitude of the data center containing the origins used in this pool in // decimal degrees. If this is set, latitude must also be set. Longitude param.Field[float64] `json:"longitude"` @@ -868,249 +440,19 @@ type PoolEditParams struct { NotificationEmail param.Field[string] `json:"notification_email"` // Filter pool and origin health notifications by resource type or health status. // Use null to reset. - NotificationFilter param.Field[PoolEditParamsNotificationFilter] `json:"notification_filter"` + NotificationFilter param.Field[NotificationFilterParam] `json:"notification_filter"` // Configures origin steering for the pool. Controls how origins are selected for // new sessions and traffic without session affinity. - OriginSteering param.Field[PoolEditParamsOriginSteering] `json:"origin_steering"` + OriginSteering param.Field[OriginSteeringParam] `json:"origin_steering"` // The list of origins within this pool. Traffic directed at this pool is balanced // across all currently healthy origins, provided the pool itself is healthy. - Origins param.Field[[]PoolEditParamsOrigin] `json:"origins"` + Origins param.Field[[]OriginItemParam] `json:"origins"` } func (r PoolEditParams) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -// WNAM: Western North America, ENAM: Eastern North America, WEU: Western Europe, -// EEU: Eastern Europe, NSAM: Northern South America, SSAM: Southern South America, -// OC: Oceania, ME: Middle East, NAF: North Africa, SAF: South Africa, SAS: -// Southern Asia, SEAS: South East Asia, NEAS: North East Asia, ALL_REGIONS: all -// regions (ENTERPRISE customers only). -type PoolEditParamsCheckRegion string - -const ( - PoolEditParamsCheckRegionWnam PoolEditParamsCheckRegion = "WNAM" - PoolEditParamsCheckRegionEnam PoolEditParamsCheckRegion = "ENAM" - PoolEditParamsCheckRegionWeu PoolEditParamsCheckRegion = "WEU" - PoolEditParamsCheckRegionEeu PoolEditParamsCheckRegion = "EEU" - PoolEditParamsCheckRegionNsam PoolEditParamsCheckRegion = "NSAM" - PoolEditParamsCheckRegionSsam PoolEditParamsCheckRegion = "SSAM" - PoolEditParamsCheckRegionOc PoolEditParamsCheckRegion = "OC" - PoolEditParamsCheckRegionMe PoolEditParamsCheckRegion = "ME" - PoolEditParamsCheckRegionNaf PoolEditParamsCheckRegion = "NAF" - PoolEditParamsCheckRegionSaf PoolEditParamsCheckRegion = "SAF" - PoolEditParamsCheckRegionSas PoolEditParamsCheckRegion = "SAS" - PoolEditParamsCheckRegionSeas PoolEditParamsCheckRegion = "SEAS" - PoolEditParamsCheckRegionNeas PoolEditParamsCheckRegion = "NEAS" - PoolEditParamsCheckRegionAllRegions PoolEditParamsCheckRegion = "ALL_REGIONS" -) - -func (r PoolEditParamsCheckRegion) IsKnown() bool { - switch r { - case PoolEditParamsCheckRegionWnam, PoolEditParamsCheckRegionEnam, PoolEditParamsCheckRegionWeu, PoolEditParamsCheckRegionEeu, PoolEditParamsCheckRegionNsam, PoolEditParamsCheckRegionSsam, PoolEditParamsCheckRegionOc, PoolEditParamsCheckRegionMe, PoolEditParamsCheckRegionNaf, PoolEditParamsCheckRegionSaf, PoolEditParamsCheckRegionSas, PoolEditParamsCheckRegionSeas, PoolEditParamsCheckRegionNeas, PoolEditParamsCheckRegionAllRegions: - return true - } - return false -} - -// Configures load shedding policies and percentages for the pool. -type PoolEditParamsLoadShedding struct { - // The percent of traffic to shed from the pool, according to the default policy. - // Applies to new sessions and traffic without session affinity. - DefaultPercent param.Field[float64] `json:"default_percent"` - // The default policy to use when load shedding. A random policy randomly sheds a - // given percent of requests. A hash policy computes a hash over the - // CF-Connecting-IP address and sheds all requests originating from a percent of - // IPs. - DefaultPolicy param.Field[PoolEditParamsLoadSheddingDefaultPolicy] `json:"default_policy"` - // The percent of existing sessions to shed from the pool, according to the session - // policy. - SessionPercent param.Field[float64] `json:"session_percent"` - // Only the hash policy is supported for existing sessions (to avoid exponential - // decay). - SessionPolicy param.Field[PoolEditParamsLoadSheddingSessionPolicy] `json:"session_policy"` -} - -func (r PoolEditParamsLoadShedding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The default policy to use when load shedding. A random policy randomly sheds a -// given percent of requests. A hash policy computes a hash over the -// CF-Connecting-IP address and sheds all requests originating from a percent of -// IPs. -type PoolEditParamsLoadSheddingDefaultPolicy string - -const ( - PoolEditParamsLoadSheddingDefaultPolicyRandom PoolEditParamsLoadSheddingDefaultPolicy = "random" - PoolEditParamsLoadSheddingDefaultPolicyHash PoolEditParamsLoadSheddingDefaultPolicy = "hash" -) - -func (r PoolEditParamsLoadSheddingDefaultPolicy) IsKnown() bool { - switch r { - case PoolEditParamsLoadSheddingDefaultPolicyRandom, PoolEditParamsLoadSheddingDefaultPolicyHash: - return true - } - return false -} - -// Only the hash policy is supported for existing sessions (to avoid exponential -// decay). -type PoolEditParamsLoadSheddingSessionPolicy string - -const ( - PoolEditParamsLoadSheddingSessionPolicyHash PoolEditParamsLoadSheddingSessionPolicy = "hash" -) - -func (r PoolEditParamsLoadSheddingSessionPolicy) IsKnown() bool { - switch r { - case PoolEditParamsLoadSheddingSessionPolicyHash: - return true - } - return false -} - -// Filter pool and origin health notifications by resource type or health status. -// Use null to reset. -type PoolEditParamsNotificationFilter struct { - // Filter options for a particular resource type (pool or origin). Use null to - // reset. - Origin param.Field[PoolEditParamsNotificationFilterOrigin] `json:"origin"` - // Filter options for a particular resource type (pool or origin). Use null to - // reset. - Pool param.Field[PoolEditParamsNotificationFilterPool] `json:"pool"` -} - -func (r PoolEditParamsNotificationFilter) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Filter options for a particular resource type (pool or origin). Use null to -// reset. -type PoolEditParamsNotificationFilterOrigin struct { - // If set true, disable notifications for this type of resource (pool or origin). - Disable param.Field[bool] `json:"disable"` - // If present, send notifications only for this health status (e.g. false for only - // DOWN events). Use null to reset (all events). - Healthy param.Field[bool] `json:"healthy"` -} - -func (r PoolEditParamsNotificationFilterOrigin) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Filter options for a particular resource type (pool or origin). Use null to -// reset. -type PoolEditParamsNotificationFilterPool struct { - // If set true, disable notifications for this type of resource (pool or origin). - Disable param.Field[bool] `json:"disable"` - // If present, send notifications only for this health status (e.g. false for only - // DOWN events). Use null to reset (all events). - Healthy param.Field[bool] `json:"healthy"` -} - -func (r PoolEditParamsNotificationFilterPool) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Configures origin steering for the pool. Controls how origins are selected for -// new sessions and traffic without session affinity. -type PoolEditParamsOriginSteering struct { - // The type of origin steering policy to use. - // - // - `"random"`: Select an origin randomly. - // - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP - // address. - // - `"least_outstanding_requests"`: Select an origin by taking into consideration - // origin weights, as well as each origin's number of outstanding requests. - // Origins with more pending requests are weighted proportionately less relative - // to others. - // - `"least_connections"`: Select an origin by taking into consideration origin - // weights, as well as each origin's number of open connections. Origins with - // more open connections are weighted proportionately less relative to others. - // Supported for HTTP/1 and HTTP/2 connections. - Policy param.Field[PoolEditParamsOriginSteeringPolicy] `json:"policy"` -} - -func (r PoolEditParamsOriginSteering) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The type of origin steering policy to use. -// -// - `"random"`: Select an origin randomly. -// - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP -// address. -// - `"least_outstanding_requests"`: Select an origin by taking into consideration -// origin weights, as well as each origin's number of outstanding requests. -// Origins with more pending requests are weighted proportionately less relative -// to others. -// - `"least_connections"`: Select an origin by taking into consideration origin -// weights, as well as each origin's number of open connections. Origins with -// more open connections are weighted proportionately less relative to others. -// Supported for HTTP/1 and HTTP/2 connections. -type PoolEditParamsOriginSteeringPolicy string - -const ( - PoolEditParamsOriginSteeringPolicyRandom PoolEditParamsOriginSteeringPolicy = "random" - PoolEditParamsOriginSteeringPolicyHash PoolEditParamsOriginSteeringPolicy = "hash" - PoolEditParamsOriginSteeringPolicyLeastOutstandingRequests PoolEditParamsOriginSteeringPolicy = "least_outstanding_requests" - PoolEditParamsOriginSteeringPolicyLeastConnections PoolEditParamsOriginSteeringPolicy = "least_connections" -) - -func (r PoolEditParamsOriginSteeringPolicy) IsKnown() bool { - switch r { - case PoolEditParamsOriginSteeringPolicyRandom, PoolEditParamsOriginSteeringPolicyHash, PoolEditParamsOriginSteeringPolicyLeastOutstandingRequests, PoolEditParamsOriginSteeringPolicyLeastConnections: - return true - } - return false -} - -type PoolEditParamsOrigin struct { - // The IP address (IPv4 or IPv6) of the origin, or its publicly addressable - // hostname. Hostnames entered here should resolve directly to the origin, and not - // be a hostname proxied by Cloudflare. To set an internal/reserved address, - // virtual_network_id must also be set. - Address param.Field[string] `json:"address"` - // Whether to enable (the default) this origin within the pool. Disabled origins - // will not receive traffic and are excluded from health checks. The origin will - // only be disabled for the current pool. - Enabled param.Field[bool] `json:"enabled"` - // The request header is used to pass additional information with an HTTP request. - // Currently supported header is 'Host'. - Header param.Field[PoolEditParamsOriginsHeader] `json:"header"` - // A human-identifiable name for the origin. - Name param.Field[string] `json:"name"` - // The virtual network subnet ID the origin belongs in. Virtual network must also - // belong to the account. - VirtualNetworkID param.Field[string] `json:"virtual_network_id"` - // The weight of this origin relative to other origins in the pool. Based on the - // configured weight the total traffic is distributed among origins within the - // pool. - // - // - `origin_steering.policy="least_outstanding_requests"`: Use weight to scale the - // origin's outstanding requests. - // - `origin_steering.policy="least_connections"`: Use weight to scale the origin's - // open connections. - Weight param.Field[float64] `json:"weight"` -} - -func (r PoolEditParamsOrigin) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The request header is used to pass additional information with an HTTP request. -// Currently supported header is 'Host'. -type PoolEditParamsOriginsHeader struct { - // The 'Host' header allows to override the hostname set in the HTTP request. - // Current support is 1 'Host' header override per origin. - Host param.Field[[]string] `json:"Host"` -} - -func (r PoolEditParamsOriginsHeader) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - type PoolEditResponseEnvelope struct { Errors []shared.UnnamedSchemaRef3248f24329456e19dfa042fff9986f72 `json:"errors,required"` Messages []shared.UnnamedSchemaRef3248f24329456e19dfa042fff9986f72 `json:"messages,required"` diff --git a/load_balancers/pool_test.go b/load_balancers/pool_test.go index a4e9f367ebe..4f92594a25d 100644 --- a/load_balancers/pool_test.go +++ b/load_balancers/pool_test.go @@ -31,11 +31,11 @@ func TestPoolNewWithOptionalParams(t *testing.T) { _, err := client.LoadBalancers.Pools.New(context.TODO(), load_balancers.PoolNewParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Name: cloudflare.F("primary-dc-1"), - Origins: cloudflare.F([]load_balancers.PoolNewParamsOrigin{{ + Origins: cloudflare.F([]load_balancers.OriginItemParam{{ Address: cloudflare.F("0.0.0.0"), Enabled: cloudflare.F(true), - Header: cloudflare.F(load_balancers.PoolNewParamsOriginsHeader{ - Host: cloudflare.F([]string{"example.com", "example.com", "example.com"}), + Header: cloudflare.F(load_balancers.HeaderParam{ + Host: cloudflare.F([]load_balancers.HostItemParam{"example.com", "example.com", "example.com"}), }), Name: cloudflare.F("app-server-1"), VirtualNetworkID: cloudflare.F("a5624d4e-044a-4ff0-b3e1-e2465353d4b4"), @@ -43,8 +43,8 @@ func TestPoolNewWithOptionalParams(t *testing.T) { }, { Address: cloudflare.F("0.0.0.0"), Enabled: cloudflare.F(true), - Header: cloudflare.F(load_balancers.PoolNewParamsOriginsHeader{ - Host: cloudflare.F([]string{"example.com", "example.com", "example.com"}), + Header: cloudflare.F(load_balancers.HeaderParam{ + Host: cloudflare.F([]load_balancers.HostItemParam{"example.com", "example.com", "example.com"}), }), Name: cloudflare.F("app-server-1"), VirtualNetworkID: cloudflare.F("a5624d4e-044a-4ff0-b3e1-e2465353d4b4"), @@ -52,8 +52,8 @@ func TestPoolNewWithOptionalParams(t *testing.T) { }, { Address: cloudflare.F("0.0.0.0"), Enabled: cloudflare.F(true), - Header: cloudflare.F(load_balancers.PoolNewParamsOriginsHeader{ - Host: cloudflare.F([]string{"example.com", "example.com", "example.com"}), + Header: cloudflare.F(load_balancers.HeaderParam{ + Host: cloudflare.F([]load_balancers.HostItemParam{"example.com", "example.com", "example.com"}), }), Name: cloudflare.F("app-server-1"), VirtualNetworkID: cloudflare.F("a5624d4e-044a-4ff0-b3e1-e2465353d4b4"), @@ -62,28 +62,28 @@ func TestPoolNewWithOptionalParams(t *testing.T) { Description: cloudflare.F("Primary data center - Provider XYZ"), Enabled: cloudflare.F(false), Latitude: cloudflare.F(0.000000), - LoadShedding: cloudflare.F(load_balancers.PoolNewParamsLoadShedding{ + LoadShedding: cloudflare.F(load_balancers.LoadSheddingParam{ DefaultPercent: cloudflare.F(0.000000), - DefaultPolicy: cloudflare.F(load_balancers.PoolNewParamsLoadSheddingDefaultPolicyRandom), + DefaultPolicy: cloudflare.F(load_balancers.LoadSheddingDefaultPolicyRandom), SessionPercent: cloudflare.F(0.000000), - SessionPolicy: cloudflare.F(load_balancers.PoolNewParamsLoadSheddingSessionPolicyHash), + SessionPolicy: cloudflare.F(load_balancers.LoadSheddingSessionPolicyHash), }), Longitude: cloudflare.F(0.000000), MinimumOrigins: cloudflare.F(int64(0)), Monitor: cloudflare.F[any](map[string]interface{}{}), NotificationEmail: cloudflare.F("someone@example.com,sometwo@example.com"), - NotificationFilter: cloudflare.F(load_balancers.PoolNewParamsNotificationFilter{ - Origin: cloudflare.F(load_balancers.PoolNewParamsNotificationFilterOrigin{ + NotificationFilter: cloudflare.F(load_balancers.NotificationFilterParam{ + Origin: cloudflare.F(load_balancers.FilterOptionsParam{ Disable: cloudflare.F(true), Healthy: cloudflare.F(true), }), - Pool: cloudflare.F(load_balancers.PoolNewParamsNotificationFilterPool{ + Pool: cloudflare.F(load_balancers.FilterOptionsParam{ Disable: cloudflare.F(true), Healthy: cloudflare.F(false), }), }), - OriginSteering: cloudflare.F(load_balancers.PoolNewParamsOriginSteering{ - Policy: cloudflare.F(load_balancers.PoolNewParamsOriginSteeringPolicyRandom), + OriginSteering: cloudflare.F(load_balancers.OriginSteeringParam{ + Policy: cloudflare.F(load_balancers.OriginSteeringPolicyRandom), }), }) if err != nil { @@ -115,11 +115,11 @@ func TestPoolUpdateWithOptionalParams(t *testing.T) { load_balancers.PoolUpdateParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Name: cloudflare.F("primary-dc-1"), - Origins: cloudflare.F([]load_balancers.PoolUpdateParamsOrigin{{ + Origins: cloudflare.F([]load_balancers.OriginItemParam{{ Address: cloudflare.F("0.0.0.0"), Enabled: cloudflare.F(true), - Header: cloudflare.F(load_balancers.PoolUpdateParamsOriginsHeader{ - Host: cloudflare.F([]string{"example.com", "example.com", "example.com"}), + Header: cloudflare.F(load_balancers.HeaderParam{ + Host: cloudflare.F([]load_balancers.HostItemParam{"example.com", "example.com", "example.com"}), }), Name: cloudflare.F("app-server-1"), VirtualNetworkID: cloudflare.F("a5624d4e-044a-4ff0-b3e1-e2465353d4b4"), @@ -127,8 +127,8 @@ func TestPoolUpdateWithOptionalParams(t *testing.T) { }, { Address: cloudflare.F("0.0.0.0"), Enabled: cloudflare.F(true), - Header: cloudflare.F(load_balancers.PoolUpdateParamsOriginsHeader{ - Host: cloudflare.F([]string{"example.com", "example.com", "example.com"}), + Header: cloudflare.F(load_balancers.HeaderParam{ + Host: cloudflare.F([]load_balancers.HostItemParam{"example.com", "example.com", "example.com"}), }), Name: cloudflare.F("app-server-1"), VirtualNetworkID: cloudflare.F("a5624d4e-044a-4ff0-b3e1-e2465353d4b4"), @@ -136,39 +136,39 @@ func TestPoolUpdateWithOptionalParams(t *testing.T) { }, { Address: cloudflare.F("0.0.0.0"), Enabled: cloudflare.F(true), - Header: cloudflare.F(load_balancers.PoolUpdateParamsOriginsHeader{ - Host: cloudflare.F([]string{"example.com", "example.com", "example.com"}), + Header: cloudflare.F(load_balancers.HeaderParam{ + Host: cloudflare.F([]load_balancers.HostItemParam{"example.com", "example.com", "example.com"}), }), Name: cloudflare.F("app-server-1"), VirtualNetworkID: cloudflare.F("a5624d4e-044a-4ff0-b3e1-e2465353d4b4"), Weight: cloudflare.F(0.600000), }}), - CheckRegions: cloudflare.F([]load_balancers.PoolUpdateParamsCheckRegion{load_balancers.PoolUpdateParamsCheckRegionWeu, load_balancers.PoolUpdateParamsCheckRegionEnam}), + CheckRegions: cloudflare.F([]load_balancers.CheckRegion{load_balancers.CheckRegionWeu, load_balancers.CheckRegionEnam}), Description: cloudflare.F("Primary data center - Provider XYZ"), Enabled: cloudflare.F(false), Latitude: cloudflare.F(0.000000), - LoadShedding: cloudflare.F(load_balancers.PoolUpdateParamsLoadShedding{ + LoadShedding: cloudflare.F(load_balancers.LoadSheddingParam{ DefaultPercent: cloudflare.F(0.000000), - DefaultPolicy: cloudflare.F(load_balancers.PoolUpdateParamsLoadSheddingDefaultPolicyRandom), + DefaultPolicy: cloudflare.F(load_balancers.LoadSheddingDefaultPolicyRandom), SessionPercent: cloudflare.F(0.000000), - SessionPolicy: cloudflare.F(load_balancers.PoolUpdateParamsLoadSheddingSessionPolicyHash), + SessionPolicy: cloudflare.F(load_balancers.LoadSheddingSessionPolicyHash), }), Longitude: cloudflare.F(0.000000), MinimumOrigins: cloudflare.F(int64(0)), Monitor: cloudflare.F[any](map[string]interface{}{}), NotificationEmail: cloudflare.F("someone@example.com,sometwo@example.com"), - NotificationFilter: cloudflare.F(load_balancers.PoolUpdateParamsNotificationFilter{ - Origin: cloudflare.F(load_balancers.PoolUpdateParamsNotificationFilterOrigin{ + NotificationFilter: cloudflare.F(load_balancers.NotificationFilterParam{ + Origin: cloudflare.F(load_balancers.FilterOptionsParam{ Disable: cloudflare.F(true), Healthy: cloudflare.F(true), }), - Pool: cloudflare.F(load_balancers.PoolUpdateParamsNotificationFilterPool{ + Pool: cloudflare.F(load_balancers.FilterOptionsParam{ Disable: cloudflare.F(true), Healthy: cloudflare.F(false), }), }), - OriginSteering: cloudflare.F(load_balancers.PoolUpdateParamsOriginSteering{ - Policy: cloudflare.F(load_balancers.PoolUpdateParamsOriginSteeringPolicyRandom), + OriginSteering: cloudflare.F(load_balancers.OriginSteeringParam{ + Policy: cloudflare.F(load_balancers.OriginSteeringPolicyRandom), }), }, ) @@ -258,39 +258,39 @@ func TestPoolEditWithOptionalParams(t *testing.T) { "17b5962d775c646f3f9725cbc7a53df4", load_balancers.PoolEditParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), - CheckRegions: cloudflare.F([]load_balancers.PoolEditParamsCheckRegion{load_balancers.PoolEditParamsCheckRegionWeu, load_balancers.PoolEditParamsCheckRegionEnam}), + CheckRegions: cloudflare.F([]load_balancers.CheckRegion{load_balancers.CheckRegionWeu, load_balancers.CheckRegionEnam}), Description: cloudflare.F("Primary data center - Provider XYZ"), Enabled: cloudflare.F(false), Latitude: cloudflare.F(0.000000), - LoadShedding: cloudflare.F(load_balancers.PoolEditParamsLoadShedding{ + LoadShedding: cloudflare.F(load_balancers.LoadSheddingParam{ DefaultPercent: cloudflare.F(0.000000), - DefaultPolicy: cloudflare.F(load_balancers.PoolEditParamsLoadSheddingDefaultPolicyRandom), + DefaultPolicy: cloudflare.F(load_balancers.LoadSheddingDefaultPolicyRandom), SessionPercent: cloudflare.F(0.000000), - SessionPolicy: cloudflare.F(load_balancers.PoolEditParamsLoadSheddingSessionPolicyHash), + SessionPolicy: cloudflare.F(load_balancers.LoadSheddingSessionPolicyHash), }), Longitude: cloudflare.F(0.000000), MinimumOrigins: cloudflare.F(int64(0)), Monitor: cloudflare.F[any](map[string]interface{}{}), Name: cloudflare.F("primary-dc-1"), NotificationEmail: cloudflare.F("someone@example.com,sometwo@example.com"), - NotificationFilter: cloudflare.F(load_balancers.PoolEditParamsNotificationFilter{ - Origin: cloudflare.F(load_balancers.PoolEditParamsNotificationFilterOrigin{ + NotificationFilter: cloudflare.F(load_balancers.NotificationFilterParam{ + Origin: cloudflare.F(load_balancers.FilterOptionsParam{ Disable: cloudflare.F(true), Healthy: cloudflare.F(true), }), - Pool: cloudflare.F(load_balancers.PoolEditParamsNotificationFilterPool{ + Pool: cloudflare.F(load_balancers.FilterOptionsParam{ Disable: cloudflare.F(true), Healthy: cloudflare.F(false), }), }), - OriginSteering: cloudflare.F(load_balancers.PoolEditParamsOriginSteering{ - Policy: cloudflare.F(load_balancers.PoolEditParamsOriginSteeringPolicyRandom), + OriginSteering: cloudflare.F(load_balancers.OriginSteeringParam{ + Policy: cloudflare.F(load_balancers.OriginSteeringPolicyRandom), }), - Origins: cloudflare.F([]load_balancers.PoolEditParamsOrigin{{ + Origins: cloudflare.F([]load_balancers.OriginItemParam{{ Address: cloudflare.F("0.0.0.0"), Enabled: cloudflare.F(true), - Header: cloudflare.F(load_balancers.PoolEditParamsOriginsHeader{ - Host: cloudflare.F([]string{"example.com", "example.com", "example.com"}), + Header: cloudflare.F(load_balancers.HeaderParam{ + Host: cloudflare.F([]load_balancers.HostItemParam{"example.com", "example.com", "example.com"}), }), Name: cloudflare.F("app-server-1"), VirtualNetworkID: cloudflare.F("a5624d4e-044a-4ff0-b3e1-e2465353d4b4"), @@ -298,8 +298,8 @@ func TestPoolEditWithOptionalParams(t *testing.T) { }, { Address: cloudflare.F("0.0.0.0"), Enabled: cloudflare.F(true), - Header: cloudflare.F(load_balancers.PoolEditParamsOriginsHeader{ - Host: cloudflare.F([]string{"example.com", "example.com", "example.com"}), + Header: cloudflare.F(load_balancers.HeaderParam{ + Host: cloudflare.F([]load_balancers.HostItemParam{"example.com", "example.com", "example.com"}), }), Name: cloudflare.F("app-server-1"), VirtualNetworkID: cloudflare.F("a5624d4e-044a-4ff0-b3e1-e2465353d4b4"), @@ -307,8 +307,8 @@ func TestPoolEditWithOptionalParams(t *testing.T) { }, { Address: cloudflare.F("0.0.0.0"), Enabled: cloudflare.F(true), - Header: cloudflare.F(load_balancers.PoolEditParamsOriginsHeader{ - Host: cloudflare.F([]string{"example.com", "example.com", "example.com"}), + Header: cloudflare.F(load_balancers.HeaderParam{ + Host: cloudflare.F([]load_balancers.HostItemParam{"example.com", "example.com", "example.com"}), }), Name: cloudflare.F("app-server-1"), VirtualNetworkID: cloudflare.F("a5624d4e-044a-4ff0-b3e1-e2465353d4b4"), diff --git a/memberships/membership.go b/memberships/membership.go index 11daf512724..a3e84e73291 100644 --- a/memberships/membership.go +++ b/memberships/membership.go @@ -16,6 +16,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/requestconfig" "github.com/cloudflare/cloudflare-go/v2/internal/shared" "github.com/cloudflare/cloudflare-go/v2/option" + "github.com/cloudflare/cloudflare-go/v2/user" ) // MembershipService contains methods and other services that help with interacting @@ -107,7 +108,7 @@ type Membership struct { // The unique activation code for the account membership. Code string `json:"code"` // All access permissions for the user at the account. - Permissions accounts.MemberPermission `json:"permissions"` + Permissions user.Permission `json:"permissions"` // List of role names for the user at the account. Roles []string `json:"roles"` // Status of this membership. diff --git a/user/invite.go b/user/invite.go index cab2db1084c..2f5be3b0a0d 100644 --- a/user/invite.go +++ b/user/invite.go @@ -8,6 +8,7 @@ import ( "net/http" "time" + "github.com/cloudflare/cloudflare-go/v2/accounts" "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "github.com/cloudflare/cloudflare-go/v2/internal/pagination" "github.com/cloudflare/cloudflare-go/v2/internal/param" @@ -100,7 +101,7 @@ type InviteListResponse struct { // Organization name. OrganizationName string `json:"organization_name"` // Roles to be assigned to this user. - Roles []InviteListResponseRole `json:"roles"` + Roles []accounts.Role `json:"roles"` // Current status of the invitation. Status InviteListResponseStatus `json:"status"` JSON inviteListResponseJSON `json:"-"` @@ -131,37 +132,6 @@ func (r inviteListResponseJSON) RawJSON() string { return r.raw } -type InviteListResponseRole struct { - // Role identifier tag. - ID string `json:"id,required"` - // Description of role's permissions. - Description string `json:"description,required"` - // Role Name. - Name string `json:"name,required"` - // Access permissions for this User. - Permissions []string `json:"permissions,required"` - JSON inviteListResponseRoleJSON `json:"-"` -} - -// inviteListResponseRoleJSON contains the JSON metadata for the struct -// [InviteListResponseRole] -type inviteListResponseRoleJSON struct { - ID apijson.Field - Description apijson.Field - Name apijson.Field - Permissions apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *InviteListResponseRole) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r inviteListResponseRoleJSON) RawJSON() string { - return r.raw -} - // Current status of the invitation. type InviteListResponseStatus string diff --git a/user/loadbalancerpool.go b/user/loadbalancerpool.go index 447434a47f1..bf15a0ae3a1 100644 --- a/user/loadbalancerpool.go +++ b/user/loadbalancerpool.go @@ -16,6 +16,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2/internal/param" "github.com/cloudflare/cloudflare-go/v2/internal/requestconfig" "github.com/cloudflare/cloudflare-go/v2/internal/shared" + "github.com/cloudflare/cloudflare-go/v2/load_balancers" "github.com/cloudflare/cloudflare-go/v2/option" "github.com/tidwall/gjson" ) @@ -185,7 +186,7 @@ type Pool struct { // decimal degrees. If this is set, longitude must also be set. Latitude float64 `json:"latitude"` // Configures load shedding policies and percentages for the pool. - LoadShedding PoolLoadShedding `json:"load_shedding"` + LoadShedding load_balancers.LoadShedding `json:"load_shedding"` // The longitude of the data center containing the origins used in this pool in // decimal degrees. If this is set, latitude must also be set. Longitude float64 `json:"longitude"` @@ -208,14 +209,14 @@ type Pool struct { NotificationEmail string `json:"notification_email"` // Filter pool and origin health notifications by resource type or health status. // Use null to reset. - NotificationFilter PoolNotificationFilter `json:"notification_filter,nullable"` + NotificationFilter load_balancers.NotificationFilter `json:"notification_filter,nullable"` // Configures origin steering for the pool. Controls how origins are selected for // new sessions and traffic without session affinity. - OriginSteering PoolOriginSteering `json:"origin_steering"` + OriginSteering load_balancers.OriginSteering `json:"origin_steering"` // The list of origins within this pool. Traffic directed at this pool is balanced // across all currently healthy origins, provided the pool itself is healthy. - Origins []PoolOrigin `json:"origins"` - JSON poolJSON `json:"-"` + Origins []load_balancers.Origin `json:"origins"` + JSON poolJSON `json:"-"` } // poolJSON contains the JSON metadata for the struct [Pool] @@ -281,309 +282,6 @@ func (r PoolCheckRegion) IsKnown() bool { return false } -// Configures load shedding policies and percentages for the pool. -type PoolLoadShedding struct { - // The percent of traffic to shed from the pool, according to the default policy. - // Applies to new sessions and traffic without session affinity. - DefaultPercent float64 `json:"default_percent"` - // The default policy to use when load shedding. A random policy randomly sheds a - // given percent of requests. A hash policy computes a hash over the - // CF-Connecting-IP address and sheds all requests originating from a percent of - // IPs. - DefaultPolicy PoolLoadSheddingDefaultPolicy `json:"default_policy"` - // The percent of existing sessions to shed from the pool, according to the session - // policy. - SessionPercent float64 `json:"session_percent"` - // Only the hash policy is supported for existing sessions (to avoid exponential - // decay). - SessionPolicy PoolLoadSheddingSessionPolicy `json:"session_policy"` - JSON poolLoadSheddingJSON `json:"-"` -} - -// poolLoadSheddingJSON contains the JSON metadata for the struct -// [PoolLoadShedding] -type poolLoadSheddingJSON struct { - DefaultPercent apijson.Field - DefaultPolicy apijson.Field - SessionPercent apijson.Field - SessionPolicy apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PoolLoadShedding) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r poolLoadSheddingJSON) RawJSON() string { - return r.raw -} - -// The default policy to use when load shedding. A random policy randomly sheds a -// given percent of requests. A hash policy computes a hash over the -// CF-Connecting-IP address and sheds all requests originating from a percent of -// IPs. -type PoolLoadSheddingDefaultPolicy string - -const ( - PoolLoadSheddingDefaultPolicyRandom PoolLoadSheddingDefaultPolicy = "random" - PoolLoadSheddingDefaultPolicyHash PoolLoadSheddingDefaultPolicy = "hash" -) - -func (r PoolLoadSheddingDefaultPolicy) IsKnown() bool { - switch r { - case PoolLoadSheddingDefaultPolicyRandom, PoolLoadSheddingDefaultPolicyHash: - return true - } - return false -} - -// Only the hash policy is supported for existing sessions (to avoid exponential -// decay). -type PoolLoadSheddingSessionPolicy string - -const ( - PoolLoadSheddingSessionPolicyHash PoolLoadSheddingSessionPolicy = "hash" -) - -func (r PoolLoadSheddingSessionPolicy) IsKnown() bool { - switch r { - case PoolLoadSheddingSessionPolicyHash: - return true - } - return false -} - -// Filter pool and origin health notifications by resource type or health status. -// Use null to reset. -type PoolNotificationFilter struct { - // Filter options for a particular resource type (pool or origin). Use null to - // reset. - Origin PoolNotificationFilterOrigin `json:"origin,nullable"` - // Filter options for a particular resource type (pool or origin). Use null to - // reset. - Pool PoolNotificationFilterPool `json:"pool,nullable"` - JSON poolNotificationFilterJSON `json:"-"` -} - -// poolNotificationFilterJSON contains the JSON metadata for the struct -// [PoolNotificationFilter] -type poolNotificationFilterJSON struct { - Origin apijson.Field - Pool apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PoolNotificationFilter) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r poolNotificationFilterJSON) RawJSON() string { - return r.raw -} - -// Filter options for a particular resource type (pool or origin). Use null to -// reset. -type PoolNotificationFilterOrigin struct { - // If set true, disable notifications for this type of resource (pool or origin). - Disable bool `json:"disable"` - // If present, send notifications only for this health status (e.g. false for only - // DOWN events). Use null to reset (all events). - Healthy bool `json:"healthy,nullable"` - JSON poolNotificationFilterOriginJSON `json:"-"` -} - -// poolNotificationFilterOriginJSON contains the JSON metadata for the struct -// [PoolNotificationFilterOrigin] -type poolNotificationFilterOriginJSON struct { - Disable apijson.Field - Healthy apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PoolNotificationFilterOrigin) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r poolNotificationFilterOriginJSON) RawJSON() string { - return r.raw -} - -// Filter options for a particular resource type (pool or origin). Use null to -// reset. -type PoolNotificationFilterPool struct { - // If set true, disable notifications for this type of resource (pool or origin). - Disable bool `json:"disable"` - // If present, send notifications only for this health status (e.g. false for only - // DOWN events). Use null to reset (all events). - Healthy bool `json:"healthy,nullable"` - JSON poolNotificationFilterPoolJSON `json:"-"` -} - -// poolNotificationFilterPoolJSON contains the JSON metadata for the struct -// [PoolNotificationFilterPool] -type poolNotificationFilterPoolJSON struct { - Disable apijson.Field - Healthy apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PoolNotificationFilterPool) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r poolNotificationFilterPoolJSON) RawJSON() string { - return r.raw -} - -// Configures origin steering for the pool. Controls how origins are selected for -// new sessions and traffic without session affinity. -type PoolOriginSteering struct { - // The type of origin steering policy to use. - // - // - `"random"`: Select an origin randomly. - // - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP - // address. - // - `"least_outstanding_requests"`: Select an origin by taking into consideration - // origin weights, as well as each origin's number of outstanding requests. - // Origins with more pending requests are weighted proportionately less relative - // to others. - // - `"least_connections"`: Select an origin by taking into consideration origin - // weights, as well as each origin's number of open connections. Origins with - // more open connections are weighted proportionately less relative to others. - // Supported for HTTP/1 and HTTP/2 connections. - Policy PoolOriginSteeringPolicy `json:"policy"` - JSON poolOriginSteeringJSON `json:"-"` -} - -// poolOriginSteeringJSON contains the JSON metadata for the struct -// [PoolOriginSteering] -type poolOriginSteeringJSON struct { - Policy apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PoolOriginSteering) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r poolOriginSteeringJSON) RawJSON() string { - return r.raw -} - -// The type of origin steering policy to use. -// -// - `"random"`: Select an origin randomly. -// - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP -// address. -// - `"least_outstanding_requests"`: Select an origin by taking into consideration -// origin weights, as well as each origin's number of outstanding requests. -// Origins with more pending requests are weighted proportionately less relative -// to others. -// - `"least_connections"`: Select an origin by taking into consideration origin -// weights, as well as each origin's number of open connections. Origins with -// more open connections are weighted proportionately less relative to others. -// Supported for HTTP/1 and HTTP/2 connections. -type PoolOriginSteeringPolicy string - -const ( - PoolOriginSteeringPolicyRandom PoolOriginSteeringPolicy = "random" - PoolOriginSteeringPolicyHash PoolOriginSteeringPolicy = "hash" - PoolOriginSteeringPolicyLeastOutstandingRequests PoolOriginSteeringPolicy = "least_outstanding_requests" - PoolOriginSteeringPolicyLeastConnections PoolOriginSteeringPolicy = "least_connections" -) - -func (r PoolOriginSteeringPolicy) IsKnown() bool { - switch r { - case PoolOriginSteeringPolicyRandom, PoolOriginSteeringPolicyHash, PoolOriginSteeringPolicyLeastOutstandingRequests, PoolOriginSteeringPolicyLeastConnections: - return true - } - return false -} - -type PoolOrigin struct { - // The IP address (IPv4 or IPv6) of the origin, or its publicly addressable - // hostname. Hostnames entered here should resolve directly to the origin, and not - // be a hostname proxied by Cloudflare. To set an internal/reserved address, - // virtual_network_id must also be set. - Address string `json:"address"` - // This field shows up only if the origin is disabled. This field is set with the - // time the origin was disabled. - DisabledAt time.Time `json:"disabled_at" format:"date-time"` - // Whether to enable (the default) this origin within the pool. Disabled origins - // will not receive traffic and are excluded from health checks. The origin will - // only be disabled for the current pool. - Enabled bool `json:"enabled"` - // The request header is used to pass additional information with an HTTP request. - // Currently supported header is 'Host'. - Header PoolOriginsHeader `json:"header"` - // A human-identifiable name for the origin. - Name string `json:"name"` - // The virtual network subnet ID the origin belongs in. Virtual network must also - // belong to the account. - VirtualNetworkID string `json:"virtual_network_id"` - // The weight of this origin relative to other origins in the pool. Based on the - // configured weight the total traffic is distributed among origins within the - // pool. - // - // - `origin_steering.policy="least_outstanding_requests"`: Use weight to scale the - // origin's outstanding requests. - // - `origin_steering.policy="least_connections"`: Use weight to scale the origin's - // open connections. - Weight float64 `json:"weight"` - JSON poolOriginJSON `json:"-"` -} - -// poolOriginJSON contains the JSON metadata for the struct [PoolOrigin] -type poolOriginJSON struct { - Address apijson.Field - DisabledAt apijson.Field - Enabled apijson.Field - Header apijson.Field - Name apijson.Field - VirtualNetworkID apijson.Field - Weight apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PoolOrigin) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r poolOriginJSON) RawJSON() string { - return r.raw -} - -// The request header is used to pass additional information with an HTTP request. -// Currently supported header is 'Host'. -type PoolOriginsHeader struct { - // The 'Host' header allows to override the hostname set in the HTTP request. - // Current support is 1 'Host' header override per origin. - Host []string `json:"Host"` - JSON poolOriginsHeaderJSON `json:"-"` -} - -// poolOriginsHeaderJSON contains the JSON metadata for the struct -// [PoolOriginsHeader] -type poolOriginsHeaderJSON struct { - Host apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *PoolOriginsHeader) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r poolOriginsHeaderJSON) RawJSON() string { - return r.raw -} - type LoadBalancerPoolDeleteResponse struct { ID string `json:"id"` JSON loadBalancerPoolDeleteResponseJSON `json:"-"` @@ -682,7 +380,7 @@ type LoadBalancerPoolNewParams struct { Name param.Field[string] `json:"name,required"` // The list of origins within this pool. Traffic directed at this pool is balanced // across all currently healthy origins, provided the pool itself is healthy. - Origins param.Field[[]LoadBalancerPoolNewParamsOrigin] `json:"origins,required"` + Origins param.Field[[]load_balancers.OriginParam] `json:"origins,required"` // A list of regions from which to run health checks. Null means every Cloudflare // data center. CheckRegions param.Field[[]LoadBalancerPoolNewParamsCheckRegion] `json:"check_regions"` @@ -696,7 +394,7 @@ type LoadBalancerPoolNewParams struct { // decimal degrees. If this is set, longitude must also be set. Latitude param.Field[float64] `json:"latitude"` // Configures load shedding policies and percentages for the pool. - LoadShedding param.Field[LoadBalancerPoolNewParamsLoadShedding] `json:"load_shedding"` + LoadShedding param.Field[load_balancers.LoadSheddingParam] `json:"load_shedding"` // The longitude of the data center containing the origins used in this pool in // decimal degrees. If this is set, latitude must also be set. Longitude param.Field[float64] `json:"longitude"` @@ -715,61 +413,16 @@ type LoadBalancerPoolNewParams struct { NotificationEmail param.Field[string] `json:"notification_email"` // Filter pool and origin health notifications by resource type or health status. // Use null to reset. - NotificationFilter param.Field[LoadBalancerPoolNewParamsNotificationFilter] `json:"notification_filter"` + NotificationFilter param.Field[load_balancers.NotificationFilterParam] `json:"notification_filter"` // Configures origin steering for the pool. Controls how origins are selected for // new sessions and traffic without session affinity. - OriginSteering param.Field[LoadBalancerPoolNewParamsOriginSteering] `json:"origin_steering"` + OriginSteering param.Field[load_balancers.OriginSteeringParam] `json:"origin_steering"` } func (r LoadBalancerPoolNewParams) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -type LoadBalancerPoolNewParamsOrigin struct { - // The IP address (IPv4 or IPv6) of the origin, or its publicly addressable - // hostname. Hostnames entered here should resolve directly to the origin, and not - // be a hostname proxied by Cloudflare. To set an internal/reserved address, - // virtual_network_id must also be set. - Address param.Field[string] `json:"address"` - // Whether to enable (the default) this origin within the pool. Disabled origins - // will not receive traffic and are excluded from health checks. The origin will - // only be disabled for the current pool. - Enabled param.Field[bool] `json:"enabled"` - // The request header is used to pass additional information with an HTTP request. - // Currently supported header is 'Host'. - Header param.Field[LoadBalancerPoolNewParamsOriginsHeader] `json:"header"` - // A human-identifiable name for the origin. - Name param.Field[string] `json:"name"` - // The virtual network subnet ID the origin belongs in. Virtual network must also - // belong to the account. - VirtualNetworkID param.Field[string] `json:"virtual_network_id"` - // The weight of this origin relative to other origins in the pool. Based on the - // configured weight the total traffic is distributed among origins within the - // pool. - // - // - `origin_steering.policy="least_outstanding_requests"`: Use weight to scale the - // origin's outstanding requests. - // - `origin_steering.policy="least_connections"`: Use weight to scale the origin's - // open connections. - Weight param.Field[float64] `json:"weight"` -} - -func (r LoadBalancerPoolNewParamsOrigin) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The request header is used to pass additional information with an HTTP request. -// Currently supported header is 'Host'. -type LoadBalancerPoolNewParamsOriginsHeader struct { - // The 'Host' header allows to override the hostname set in the HTTP request. - // Current support is 1 'Host' header override per origin. - Host param.Field[[]string] `json:"Host"` -} - -func (r LoadBalancerPoolNewParamsOriginsHeader) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - // WNAM: Western North America, ENAM: Eastern North America, WEU: Western Europe, // EEU: Eastern Europe, NSAM: Northern South America, SSAM: Southern South America, // OC: Oceania, ME: Middle East, NAF: North Africa, SAF: South Africa, SAS: @@ -802,159 +455,6 @@ func (r LoadBalancerPoolNewParamsCheckRegion) IsKnown() bool { return false } -// Configures load shedding policies and percentages for the pool. -type LoadBalancerPoolNewParamsLoadShedding struct { - // The percent of traffic to shed from the pool, according to the default policy. - // Applies to new sessions and traffic without session affinity. - DefaultPercent param.Field[float64] `json:"default_percent"` - // The default policy to use when load shedding. A random policy randomly sheds a - // given percent of requests. A hash policy computes a hash over the - // CF-Connecting-IP address and sheds all requests originating from a percent of - // IPs. - DefaultPolicy param.Field[LoadBalancerPoolNewParamsLoadSheddingDefaultPolicy] `json:"default_policy"` - // The percent of existing sessions to shed from the pool, according to the session - // policy. - SessionPercent param.Field[float64] `json:"session_percent"` - // Only the hash policy is supported for existing sessions (to avoid exponential - // decay). - SessionPolicy param.Field[LoadBalancerPoolNewParamsLoadSheddingSessionPolicy] `json:"session_policy"` -} - -func (r LoadBalancerPoolNewParamsLoadShedding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The default policy to use when load shedding. A random policy randomly sheds a -// given percent of requests. A hash policy computes a hash over the -// CF-Connecting-IP address and sheds all requests originating from a percent of -// IPs. -type LoadBalancerPoolNewParamsLoadSheddingDefaultPolicy string - -const ( - LoadBalancerPoolNewParamsLoadSheddingDefaultPolicyRandom LoadBalancerPoolNewParamsLoadSheddingDefaultPolicy = "random" - LoadBalancerPoolNewParamsLoadSheddingDefaultPolicyHash LoadBalancerPoolNewParamsLoadSheddingDefaultPolicy = "hash" -) - -func (r LoadBalancerPoolNewParamsLoadSheddingDefaultPolicy) IsKnown() bool { - switch r { - case LoadBalancerPoolNewParamsLoadSheddingDefaultPolicyRandom, LoadBalancerPoolNewParamsLoadSheddingDefaultPolicyHash: - return true - } - return false -} - -// Only the hash policy is supported for existing sessions (to avoid exponential -// decay). -type LoadBalancerPoolNewParamsLoadSheddingSessionPolicy string - -const ( - LoadBalancerPoolNewParamsLoadSheddingSessionPolicyHash LoadBalancerPoolNewParamsLoadSheddingSessionPolicy = "hash" -) - -func (r LoadBalancerPoolNewParamsLoadSheddingSessionPolicy) IsKnown() bool { - switch r { - case LoadBalancerPoolNewParamsLoadSheddingSessionPolicyHash: - return true - } - return false -} - -// Filter pool and origin health notifications by resource type or health status. -// Use null to reset. -type LoadBalancerPoolNewParamsNotificationFilter struct { - // Filter options for a particular resource type (pool or origin). Use null to - // reset. - Origin param.Field[LoadBalancerPoolNewParamsNotificationFilterOrigin] `json:"origin"` - // Filter options for a particular resource type (pool or origin). Use null to - // reset. - Pool param.Field[LoadBalancerPoolNewParamsNotificationFilterPool] `json:"pool"` -} - -func (r LoadBalancerPoolNewParamsNotificationFilter) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Filter options for a particular resource type (pool or origin). Use null to -// reset. -type LoadBalancerPoolNewParamsNotificationFilterOrigin struct { - // If set true, disable notifications for this type of resource (pool or origin). - Disable param.Field[bool] `json:"disable"` - // If present, send notifications only for this health status (e.g. false for only - // DOWN events). Use null to reset (all events). - Healthy param.Field[bool] `json:"healthy"` -} - -func (r LoadBalancerPoolNewParamsNotificationFilterOrigin) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Filter options for a particular resource type (pool or origin). Use null to -// reset. -type LoadBalancerPoolNewParamsNotificationFilterPool struct { - // If set true, disable notifications for this type of resource (pool or origin). - Disable param.Field[bool] `json:"disable"` - // If present, send notifications only for this health status (e.g. false for only - // DOWN events). Use null to reset (all events). - Healthy param.Field[bool] `json:"healthy"` -} - -func (r LoadBalancerPoolNewParamsNotificationFilterPool) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Configures origin steering for the pool. Controls how origins are selected for -// new sessions and traffic without session affinity. -type LoadBalancerPoolNewParamsOriginSteering struct { - // The type of origin steering policy to use. - // - // - `"random"`: Select an origin randomly. - // - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP - // address. - // - `"least_outstanding_requests"`: Select an origin by taking into consideration - // origin weights, as well as each origin's number of outstanding requests. - // Origins with more pending requests are weighted proportionately less relative - // to others. - // - `"least_connections"`: Select an origin by taking into consideration origin - // weights, as well as each origin's number of open connections. Origins with - // more open connections are weighted proportionately less relative to others. - // Supported for HTTP/1 and HTTP/2 connections. - Policy param.Field[LoadBalancerPoolNewParamsOriginSteeringPolicy] `json:"policy"` -} - -func (r LoadBalancerPoolNewParamsOriginSteering) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The type of origin steering policy to use. -// -// - `"random"`: Select an origin randomly. -// - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP -// address. -// - `"least_outstanding_requests"`: Select an origin by taking into consideration -// origin weights, as well as each origin's number of outstanding requests. -// Origins with more pending requests are weighted proportionately less relative -// to others. -// - `"least_connections"`: Select an origin by taking into consideration origin -// weights, as well as each origin's number of open connections. Origins with -// more open connections are weighted proportionately less relative to others. -// Supported for HTTP/1 and HTTP/2 connections. -type LoadBalancerPoolNewParamsOriginSteeringPolicy string - -const ( - LoadBalancerPoolNewParamsOriginSteeringPolicyRandom LoadBalancerPoolNewParamsOriginSteeringPolicy = "random" - LoadBalancerPoolNewParamsOriginSteeringPolicyHash LoadBalancerPoolNewParamsOriginSteeringPolicy = "hash" - LoadBalancerPoolNewParamsOriginSteeringPolicyLeastOutstandingRequests LoadBalancerPoolNewParamsOriginSteeringPolicy = "least_outstanding_requests" - LoadBalancerPoolNewParamsOriginSteeringPolicyLeastConnections LoadBalancerPoolNewParamsOriginSteeringPolicy = "least_connections" -) - -func (r LoadBalancerPoolNewParamsOriginSteeringPolicy) IsKnown() bool { - switch r { - case LoadBalancerPoolNewParamsOriginSteeringPolicyRandom, LoadBalancerPoolNewParamsOriginSteeringPolicyHash, LoadBalancerPoolNewParamsOriginSteeringPolicyLeastOutstandingRequests, LoadBalancerPoolNewParamsOriginSteeringPolicyLeastConnections: - return true - } - return false -} - type LoadBalancerPoolNewResponseEnvelope struct { Errors []shared.UnnamedSchemaRef3248f24329456e19dfa042fff9986f72 `json:"errors,required"` Messages []shared.UnnamedSchemaRef3248f24329456e19dfa042fff9986f72 `json:"messages,required"` @@ -1004,7 +504,7 @@ type LoadBalancerPoolUpdateParams struct { Name param.Field[string] `json:"name,required"` // The list of origins within this pool. Traffic directed at this pool is balanced // across all currently healthy origins, provided the pool itself is healthy. - Origins param.Field[[]LoadBalancerPoolUpdateParamsOrigin] `json:"origins,required"` + Origins param.Field[[]load_balancers.OriginParam] `json:"origins,required"` // A list of regions from which to run health checks. Null means every Cloudflare // data center. CheckRegions param.Field[[]LoadBalancerPoolUpdateParamsCheckRegion] `json:"check_regions"` @@ -1018,7 +518,7 @@ type LoadBalancerPoolUpdateParams struct { // decimal degrees. If this is set, longitude must also be set. Latitude param.Field[float64] `json:"latitude"` // Configures load shedding policies and percentages for the pool. - LoadShedding param.Field[LoadBalancerPoolUpdateParamsLoadShedding] `json:"load_shedding"` + LoadShedding param.Field[load_balancers.LoadSheddingParam] `json:"load_shedding"` // The longitude of the data center containing the origins used in this pool in // decimal degrees. If this is set, latitude must also be set. Longitude param.Field[float64] `json:"longitude"` @@ -1037,61 +537,16 @@ type LoadBalancerPoolUpdateParams struct { NotificationEmail param.Field[string] `json:"notification_email"` // Filter pool and origin health notifications by resource type or health status. // Use null to reset. - NotificationFilter param.Field[LoadBalancerPoolUpdateParamsNotificationFilter] `json:"notification_filter"` + NotificationFilter param.Field[load_balancers.NotificationFilterParam] `json:"notification_filter"` // Configures origin steering for the pool. Controls how origins are selected for // new sessions and traffic without session affinity. - OriginSteering param.Field[LoadBalancerPoolUpdateParamsOriginSteering] `json:"origin_steering"` + OriginSteering param.Field[load_balancers.OriginSteeringParam] `json:"origin_steering"` } func (r LoadBalancerPoolUpdateParams) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -type LoadBalancerPoolUpdateParamsOrigin struct { - // The IP address (IPv4 or IPv6) of the origin, or its publicly addressable - // hostname. Hostnames entered here should resolve directly to the origin, and not - // be a hostname proxied by Cloudflare. To set an internal/reserved address, - // virtual_network_id must also be set. - Address param.Field[string] `json:"address"` - // Whether to enable (the default) this origin within the pool. Disabled origins - // will not receive traffic and are excluded from health checks. The origin will - // only be disabled for the current pool. - Enabled param.Field[bool] `json:"enabled"` - // The request header is used to pass additional information with an HTTP request. - // Currently supported header is 'Host'. - Header param.Field[LoadBalancerPoolUpdateParamsOriginsHeader] `json:"header"` - // A human-identifiable name for the origin. - Name param.Field[string] `json:"name"` - // The virtual network subnet ID the origin belongs in. Virtual network must also - // belong to the account. - VirtualNetworkID param.Field[string] `json:"virtual_network_id"` - // The weight of this origin relative to other origins in the pool. Based on the - // configured weight the total traffic is distributed among origins within the - // pool. - // - // - `origin_steering.policy="least_outstanding_requests"`: Use weight to scale the - // origin's outstanding requests. - // - `origin_steering.policy="least_connections"`: Use weight to scale the origin's - // open connections. - Weight param.Field[float64] `json:"weight"` -} - -func (r LoadBalancerPoolUpdateParamsOrigin) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The request header is used to pass additional information with an HTTP request. -// Currently supported header is 'Host'. -type LoadBalancerPoolUpdateParamsOriginsHeader struct { - // The 'Host' header allows to override the hostname set in the HTTP request. - // Current support is 1 'Host' header override per origin. - Host param.Field[[]string] `json:"Host"` -} - -func (r LoadBalancerPoolUpdateParamsOriginsHeader) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - // WNAM: Western North America, ENAM: Eastern North America, WEU: Western Europe, // EEU: Eastern Europe, NSAM: Northern South America, SSAM: Southern South America, // OC: Oceania, ME: Middle East, NAF: North Africa, SAF: South Africa, SAS: @@ -1124,159 +579,6 @@ func (r LoadBalancerPoolUpdateParamsCheckRegion) IsKnown() bool { return false } -// Configures load shedding policies and percentages for the pool. -type LoadBalancerPoolUpdateParamsLoadShedding struct { - // The percent of traffic to shed from the pool, according to the default policy. - // Applies to new sessions and traffic without session affinity. - DefaultPercent param.Field[float64] `json:"default_percent"` - // The default policy to use when load shedding. A random policy randomly sheds a - // given percent of requests. A hash policy computes a hash over the - // CF-Connecting-IP address and sheds all requests originating from a percent of - // IPs. - DefaultPolicy param.Field[LoadBalancerPoolUpdateParamsLoadSheddingDefaultPolicy] `json:"default_policy"` - // The percent of existing sessions to shed from the pool, according to the session - // policy. - SessionPercent param.Field[float64] `json:"session_percent"` - // Only the hash policy is supported for existing sessions (to avoid exponential - // decay). - SessionPolicy param.Field[LoadBalancerPoolUpdateParamsLoadSheddingSessionPolicy] `json:"session_policy"` -} - -func (r LoadBalancerPoolUpdateParamsLoadShedding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The default policy to use when load shedding. A random policy randomly sheds a -// given percent of requests. A hash policy computes a hash over the -// CF-Connecting-IP address and sheds all requests originating from a percent of -// IPs. -type LoadBalancerPoolUpdateParamsLoadSheddingDefaultPolicy string - -const ( - LoadBalancerPoolUpdateParamsLoadSheddingDefaultPolicyRandom LoadBalancerPoolUpdateParamsLoadSheddingDefaultPolicy = "random" - LoadBalancerPoolUpdateParamsLoadSheddingDefaultPolicyHash LoadBalancerPoolUpdateParamsLoadSheddingDefaultPolicy = "hash" -) - -func (r LoadBalancerPoolUpdateParamsLoadSheddingDefaultPolicy) IsKnown() bool { - switch r { - case LoadBalancerPoolUpdateParamsLoadSheddingDefaultPolicyRandom, LoadBalancerPoolUpdateParamsLoadSheddingDefaultPolicyHash: - return true - } - return false -} - -// Only the hash policy is supported for existing sessions (to avoid exponential -// decay). -type LoadBalancerPoolUpdateParamsLoadSheddingSessionPolicy string - -const ( - LoadBalancerPoolUpdateParamsLoadSheddingSessionPolicyHash LoadBalancerPoolUpdateParamsLoadSheddingSessionPolicy = "hash" -) - -func (r LoadBalancerPoolUpdateParamsLoadSheddingSessionPolicy) IsKnown() bool { - switch r { - case LoadBalancerPoolUpdateParamsLoadSheddingSessionPolicyHash: - return true - } - return false -} - -// Filter pool and origin health notifications by resource type or health status. -// Use null to reset. -type LoadBalancerPoolUpdateParamsNotificationFilter struct { - // Filter options for a particular resource type (pool or origin). Use null to - // reset. - Origin param.Field[LoadBalancerPoolUpdateParamsNotificationFilterOrigin] `json:"origin"` - // Filter options for a particular resource type (pool or origin). Use null to - // reset. - Pool param.Field[LoadBalancerPoolUpdateParamsNotificationFilterPool] `json:"pool"` -} - -func (r LoadBalancerPoolUpdateParamsNotificationFilter) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Filter options for a particular resource type (pool or origin). Use null to -// reset. -type LoadBalancerPoolUpdateParamsNotificationFilterOrigin struct { - // If set true, disable notifications for this type of resource (pool or origin). - Disable param.Field[bool] `json:"disable"` - // If present, send notifications only for this health status (e.g. false for only - // DOWN events). Use null to reset (all events). - Healthy param.Field[bool] `json:"healthy"` -} - -func (r LoadBalancerPoolUpdateParamsNotificationFilterOrigin) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Filter options for a particular resource type (pool or origin). Use null to -// reset. -type LoadBalancerPoolUpdateParamsNotificationFilterPool struct { - // If set true, disable notifications for this type of resource (pool or origin). - Disable param.Field[bool] `json:"disable"` - // If present, send notifications only for this health status (e.g. false for only - // DOWN events). Use null to reset (all events). - Healthy param.Field[bool] `json:"healthy"` -} - -func (r LoadBalancerPoolUpdateParamsNotificationFilterPool) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Configures origin steering for the pool. Controls how origins are selected for -// new sessions and traffic without session affinity. -type LoadBalancerPoolUpdateParamsOriginSteering struct { - // The type of origin steering policy to use. - // - // - `"random"`: Select an origin randomly. - // - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP - // address. - // - `"least_outstanding_requests"`: Select an origin by taking into consideration - // origin weights, as well as each origin's number of outstanding requests. - // Origins with more pending requests are weighted proportionately less relative - // to others. - // - `"least_connections"`: Select an origin by taking into consideration origin - // weights, as well as each origin's number of open connections. Origins with - // more open connections are weighted proportionately less relative to others. - // Supported for HTTP/1 and HTTP/2 connections. - Policy param.Field[LoadBalancerPoolUpdateParamsOriginSteeringPolicy] `json:"policy"` -} - -func (r LoadBalancerPoolUpdateParamsOriginSteering) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The type of origin steering policy to use. -// -// - `"random"`: Select an origin randomly. -// - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP -// address. -// - `"least_outstanding_requests"`: Select an origin by taking into consideration -// origin weights, as well as each origin's number of outstanding requests. -// Origins with more pending requests are weighted proportionately less relative -// to others. -// - `"least_connections"`: Select an origin by taking into consideration origin -// weights, as well as each origin's number of open connections. Origins with -// more open connections are weighted proportionately less relative to others. -// Supported for HTTP/1 and HTTP/2 connections. -type LoadBalancerPoolUpdateParamsOriginSteeringPolicy string - -const ( - LoadBalancerPoolUpdateParamsOriginSteeringPolicyRandom LoadBalancerPoolUpdateParamsOriginSteeringPolicy = "random" - LoadBalancerPoolUpdateParamsOriginSteeringPolicyHash LoadBalancerPoolUpdateParamsOriginSteeringPolicy = "hash" - LoadBalancerPoolUpdateParamsOriginSteeringPolicyLeastOutstandingRequests LoadBalancerPoolUpdateParamsOriginSteeringPolicy = "least_outstanding_requests" - LoadBalancerPoolUpdateParamsOriginSteeringPolicyLeastConnections LoadBalancerPoolUpdateParamsOriginSteeringPolicy = "least_connections" -) - -func (r LoadBalancerPoolUpdateParamsOriginSteeringPolicy) IsKnown() bool { - switch r { - case LoadBalancerPoolUpdateParamsOriginSteeringPolicyRandom, LoadBalancerPoolUpdateParamsOriginSteeringPolicyHash, LoadBalancerPoolUpdateParamsOriginSteeringPolicyLeastOutstandingRequests, LoadBalancerPoolUpdateParamsOriginSteeringPolicyLeastConnections: - return true - } - return false -} - type LoadBalancerPoolUpdateResponseEnvelope struct { Errors []shared.UnnamedSchemaRef3248f24329456e19dfa042fff9986f72 `json:"errors,required"` Messages []shared.UnnamedSchemaRef3248f24329456e19dfa042fff9986f72 `json:"messages,required"` @@ -1400,7 +702,7 @@ type LoadBalancerPoolEditParams struct { // decimal degrees. If this is set, longitude must also be set. Latitude param.Field[float64] `json:"latitude"` // Configures load shedding policies and percentages for the pool. - LoadShedding param.Field[LoadBalancerPoolEditParamsLoadShedding] `json:"load_shedding"` + LoadShedding param.Field[load_balancers.LoadSheddingParam] `json:"load_shedding"` // The longitude of the data center containing the origins used in this pool in // decimal degrees. If this is set, latitude must also be set. Longitude param.Field[float64] `json:"longitude"` @@ -1422,13 +724,13 @@ type LoadBalancerPoolEditParams struct { NotificationEmail param.Field[string] `json:"notification_email"` // Filter pool and origin health notifications by resource type or health status. // Use null to reset. - NotificationFilter param.Field[LoadBalancerPoolEditParamsNotificationFilter] `json:"notification_filter"` + NotificationFilter param.Field[load_balancers.NotificationFilterParam] `json:"notification_filter"` // Configures origin steering for the pool. Controls how origins are selected for // new sessions and traffic without session affinity. - OriginSteering param.Field[LoadBalancerPoolEditParamsOriginSteering] `json:"origin_steering"` + OriginSteering param.Field[load_balancers.OriginSteeringParam] `json:"origin_steering"` // The list of origins within this pool. Traffic directed at this pool is balanced // across all currently healthy origins, provided the pool itself is healthy. - Origins param.Field[[]LoadBalancerPoolEditParamsOrigin] `json:"origins"` + Origins param.Field[[]load_balancers.OriginParam] `json:"origins"` } func (r LoadBalancerPoolEditParams) MarshalJSON() (data []byte, err error) { @@ -1467,204 +769,6 @@ func (r LoadBalancerPoolEditParamsCheckRegion) IsKnown() bool { return false } -// Configures load shedding policies and percentages for the pool. -type LoadBalancerPoolEditParamsLoadShedding struct { - // The percent of traffic to shed from the pool, according to the default policy. - // Applies to new sessions and traffic without session affinity. - DefaultPercent param.Field[float64] `json:"default_percent"` - // The default policy to use when load shedding. A random policy randomly sheds a - // given percent of requests. A hash policy computes a hash over the - // CF-Connecting-IP address and sheds all requests originating from a percent of - // IPs. - DefaultPolicy param.Field[LoadBalancerPoolEditParamsLoadSheddingDefaultPolicy] `json:"default_policy"` - // The percent of existing sessions to shed from the pool, according to the session - // policy. - SessionPercent param.Field[float64] `json:"session_percent"` - // Only the hash policy is supported for existing sessions (to avoid exponential - // decay). - SessionPolicy param.Field[LoadBalancerPoolEditParamsLoadSheddingSessionPolicy] `json:"session_policy"` -} - -func (r LoadBalancerPoolEditParamsLoadShedding) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The default policy to use when load shedding. A random policy randomly sheds a -// given percent of requests. A hash policy computes a hash over the -// CF-Connecting-IP address and sheds all requests originating from a percent of -// IPs. -type LoadBalancerPoolEditParamsLoadSheddingDefaultPolicy string - -const ( - LoadBalancerPoolEditParamsLoadSheddingDefaultPolicyRandom LoadBalancerPoolEditParamsLoadSheddingDefaultPolicy = "random" - LoadBalancerPoolEditParamsLoadSheddingDefaultPolicyHash LoadBalancerPoolEditParamsLoadSheddingDefaultPolicy = "hash" -) - -func (r LoadBalancerPoolEditParamsLoadSheddingDefaultPolicy) IsKnown() bool { - switch r { - case LoadBalancerPoolEditParamsLoadSheddingDefaultPolicyRandom, LoadBalancerPoolEditParamsLoadSheddingDefaultPolicyHash: - return true - } - return false -} - -// Only the hash policy is supported for existing sessions (to avoid exponential -// decay). -type LoadBalancerPoolEditParamsLoadSheddingSessionPolicy string - -const ( - LoadBalancerPoolEditParamsLoadSheddingSessionPolicyHash LoadBalancerPoolEditParamsLoadSheddingSessionPolicy = "hash" -) - -func (r LoadBalancerPoolEditParamsLoadSheddingSessionPolicy) IsKnown() bool { - switch r { - case LoadBalancerPoolEditParamsLoadSheddingSessionPolicyHash: - return true - } - return false -} - -// Filter pool and origin health notifications by resource type or health status. -// Use null to reset. -type LoadBalancerPoolEditParamsNotificationFilter struct { - // Filter options for a particular resource type (pool or origin). Use null to - // reset. - Origin param.Field[LoadBalancerPoolEditParamsNotificationFilterOrigin] `json:"origin"` - // Filter options for a particular resource type (pool or origin). Use null to - // reset. - Pool param.Field[LoadBalancerPoolEditParamsNotificationFilterPool] `json:"pool"` -} - -func (r LoadBalancerPoolEditParamsNotificationFilter) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Filter options for a particular resource type (pool or origin). Use null to -// reset. -type LoadBalancerPoolEditParamsNotificationFilterOrigin struct { - // If set true, disable notifications for this type of resource (pool or origin). - Disable param.Field[bool] `json:"disable"` - // If present, send notifications only for this health status (e.g. false for only - // DOWN events). Use null to reset (all events). - Healthy param.Field[bool] `json:"healthy"` -} - -func (r LoadBalancerPoolEditParamsNotificationFilterOrigin) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Filter options for a particular resource type (pool or origin). Use null to -// reset. -type LoadBalancerPoolEditParamsNotificationFilterPool struct { - // If set true, disable notifications for this type of resource (pool or origin). - Disable param.Field[bool] `json:"disable"` - // If present, send notifications only for this health status (e.g. false for only - // DOWN events). Use null to reset (all events). - Healthy param.Field[bool] `json:"healthy"` -} - -func (r LoadBalancerPoolEditParamsNotificationFilterPool) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// Configures origin steering for the pool. Controls how origins are selected for -// new sessions and traffic without session affinity. -type LoadBalancerPoolEditParamsOriginSteering struct { - // The type of origin steering policy to use. - // - // - `"random"`: Select an origin randomly. - // - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP - // address. - // - `"least_outstanding_requests"`: Select an origin by taking into consideration - // origin weights, as well as each origin's number of outstanding requests. - // Origins with more pending requests are weighted proportionately less relative - // to others. - // - `"least_connections"`: Select an origin by taking into consideration origin - // weights, as well as each origin's number of open connections. Origins with - // more open connections are weighted proportionately less relative to others. - // Supported for HTTP/1 and HTTP/2 connections. - Policy param.Field[LoadBalancerPoolEditParamsOriginSteeringPolicy] `json:"policy"` -} - -func (r LoadBalancerPoolEditParamsOriginSteering) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The type of origin steering policy to use. -// -// - `"random"`: Select an origin randomly. -// - `"hash"`: Select an origin by computing a hash over the CF-Connecting-IP -// address. -// - `"least_outstanding_requests"`: Select an origin by taking into consideration -// origin weights, as well as each origin's number of outstanding requests. -// Origins with more pending requests are weighted proportionately less relative -// to others. -// - `"least_connections"`: Select an origin by taking into consideration origin -// weights, as well as each origin's number of open connections. Origins with -// more open connections are weighted proportionately less relative to others. -// Supported for HTTP/1 and HTTP/2 connections. -type LoadBalancerPoolEditParamsOriginSteeringPolicy string - -const ( - LoadBalancerPoolEditParamsOriginSteeringPolicyRandom LoadBalancerPoolEditParamsOriginSteeringPolicy = "random" - LoadBalancerPoolEditParamsOriginSteeringPolicyHash LoadBalancerPoolEditParamsOriginSteeringPolicy = "hash" - LoadBalancerPoolEditParamsOriginSteeringPolicyLeastOutstandingRequests LoadBalancerPoolEditParamsOriginSteeringPolicy = "least_outstanding_requests" - LoadBalancerPoolEditParamsOriginSteeringPolicyLeastConnections LoadBalancerPoolEditParamsOriginSteeringPolicy = "least_connections" -) - -func (r LoadBalancerPoolEditParamsOriginSteeringPolicy) IsKnown() bool { - switch r { - case LoadBalancerPoolEditParamsOriginSteeringPolicyRandom, LoadBalancerPoolEditParamsOriginSteeringPolicyHash, LoadBalancerPoolEditParamsOriginSteeringPolicyLeastOutstandingRequests, LoadBalancerPoolEditParamsOriginSteeringPolicyLeastConnections: - return true - } - return false -} - -type LoadBalancerPoolEditParamsOrigin struct { - // The IP address (IPv4 or IPv6) of the origin, or its publicly addressable - // hostname. Hostnames entered here should resolve directly to the origin, and not - // be a hostname proxied by Cloudflare. To set an internal/reserved address, - // virtual_network_id must also be set. - Address param.Field[string] `json:"address"` - // Whether to enable (the default) this origin within the pool. Disabled origins - // will not receive traffic and are excluded from health checks. The origin will - // only be disabled for the current pool. - Enabled param.Field[bool] `json:"enabled"` - // The request header is used to pass additional information with an HTTP request. - // Currently supported header is 'Host'. - Header param.Field[LoadBalancerPoolEditParamsOriginsHeader] `json:"header"` - // A human-identifiable name for the origin. - Name param.Field[string] `json:"name"` - // The virtual network subnet ID the origin belongs in. Virtual network must also - // belong to the account. - VirtualNetworkID param.Field[string] `json:"virtual_network_id"` - // The weight of this origin relative to other origins in the pool. Based on the - // configured weight the total traffic is distributed among origins within the - // pool. - // - // - `origin_steering.policy="least_outstanding_requests"`: Use weight to scale the - // origin's outstanding requests. - // - `origin_steering.policy="least_connections"`: Use weight to scale the origin's - // open connections. - Weight param.Field[float64] `json:"weight"` -} - -func (r LoadBalancerPoolEditParamsOrigin) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The request header is used to pass additional information with an HTTP request. -// Currently supported header is 'Host'. -type LoadBalancerPoolEditParamsOriginsHeader struct { - // The 'Host' header allows to override the hostname set in the HTTP request. - // Current support is 1 'Host' header override per origin. - Host param.Field[[]string] `json:"Host"` -} - -func (r LoadBalancerPoolEditParamsOriginsHeader) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - type LoadBalancerPoolEditResponseEnvelope struct { Errors []shared.UnnamedSchemaRef3248f24329456e19dfa042fff9986f72 `json:"errors,required"` Messages []shared.UnnamedSchemaRef3248f24329456e19dfa042fff9986f72 `json:"messages,required"` diff --git a/user/loadbalancerpool_test.go b/user/loadbalancerpool_test.go index 5825306df07..22d2aa0ce34 100644 --- a/user/loadbalancerpool_test.go +++ b/user/loadbalancerpool_test.go @@ -10,6 +10,7 @@ import ( "github.com/cloudflare/cloudflare-go/v2" "github.com/cloudflare/cloudflare-go/v2/internal/testutil" + "github.com/cloudflare/cloudflare-go/v2/load_balancers" "github.com/cloudflare/cloudflare-go/v2/option" "github.com/cloudflare/cloudflare-go/v2/user" ) @@ -30,10 +31,10 @@ func TestLoadBalancerPoolNewWithOptionalParams(t *testing.T) { ) _, err := client.User.LoadBalancers.Pools.New(context.TODO(), user.LoadBalancerPoolNewParams{ Name: cloudflare.F("primary-dc-1"), - Origins: cloudflare.F([]user.LoadBalancerPoolNewParamsOrigin{{ + Origins: cloudflare.F([]load_balancers.OriginParam{{ Address: cloudflare.F("0.0.0.0"), Enabled: cloudflare.F(true), - Header: cloudflare.F(user.LoadBalancerPoolNewParamsOriginsHeader{ + Header: cloudflare.F(load_balancers.HeaderParam{ Host: cloudflare.F([]string{"example.com", "example.com", "example.com"}), }), Name: cloudflare.F("app-server-1"), @@ -42,7 +43,7 @@ func TestLoadBalancerPoolNewWithOptionalParams(t *testing.T) { }, { Address: cloudflare.F("0.0.0.0"), Enabled: cloudflare.F(true), - Header: cloudflare.F(user.LoadBalancerPoolNewParamsOriginsHeader{ + Header: cloudflare.F(load_balancers.HeaderParam{ Host: cloudflare.F([]string{"example.com", "example.com", "example.com"}), }), Name: cloudflare.F("app-server-1"), @@ -51,7 +52,7 @@ func TestLoadBalancerPoolNewWithOptionalParams(t *testing.T) { }, { Address: cloudflare.F("0.0.0.0"), Enabled: cloudflare.F(true), - Header: cloudflare.F(user.LoadBalancerPoolNewParamsOriginsHeader{ + Header: cloudflare.F(load_balancers.HeaderParam{ Host: cloudflare.F([]string{"example.com", "example.com", "example.com"}), }), Name: cloudflare.F("app-server-1"), @@ -62,28 +63,28 @@ func TestLoadBalancerPoolNewWithOptionalParams(t *testing.T) { Description: cloudflare.F("Primary data center - Provider XYZ"), Enabled: cloudflare.F(false), Latitude: cloudflare.F(0.000000), - LoadShedding: cloudflare.F(user.LoadBalancerPoolNewParamsLoadShedding{ + LoadShedding: cloudflare.F(load_balancers.LoadSheddingParam{ DefaultPercent: cloudflare.F(0.000000), - DefaultPolicy: cloudflare.F(user.LoadBalancerPoolNewParamsLoadSheddingDefaultPolicyRandom), + DefaultPolicy: cloudflare.F(load_balancers.LoadSheddingDefaultPolicyRandom), SessionPercent: cloudflare.F(0.000000), - SessionPolicy: cloudflare.F(user.LoadBalancerPoolNewParamsLoadSheddingSessionPolicyHash), + SessionPolicy: cloudflare.F(load_balancers.LoadSheddingSessionPolicyHash), }), Longitude: cloudflare.F(0.000000), MinimumOrigins: cloudflare.F(int64(0)), Monitor: cloudflare.F[any](map[string]interface{}{}), NotificationEmail: cloudflare.F("someone@example.com,sometwo@example.com"), - NotificationFilter: cloudflare.F(user.LoadBalancerPoolNewParamsNotificationFilter{ - Origin: cloudflare.F(user.LoadBalancerPoolNewParamsNotificationFilterOrigin{ + NotificationFilter: cloudflare.F(load_balancers.NotificationFilterParam{ + Origin: cloudflare.F(load_balancers.FilterOptionsParam{ Disable: cloudflare.F(true), Healthy: cloudflare.F(true), }), - Pool: cloudflare.F(user.LoadBalancerPoolNewParamsNotificationFilterPool{ + Pool: cloudflare.F(load_balancers.FilterOptionsParam{ Disable: cloudflare.F(true), Healthy: cloudflare.F(false), }), }), - OriginSteering: cloudflare.F(user.LoadBalancerPoolNewParamsOriginSteering{ - Policy: cloudflare.F(user.LoadBalancerPoolNewParamsOriginSteeringPolicyRandom), + OriginSteering: cloudflare.F(load_balancers.OriginSteeringParam{ + Policy: cloudflare.F(load_balancers.OriginSteeringPolicyRandom), }), }) if err != nil { @@ -114,10 +115,10 @@ func TestLoadBalancerPoolUpdateWithOptionalParams(t *testing.T) { "17b5962d775c646f3f9725cbc7a53df4", user.LoadBalancerPoolUpdateParams{ Name: cloudflare.F("primary-dc-1"), - Origins: cloudflare.F([]user.LoadBalancerPoolUpdateParamsOrigin{{ + Origins: cloudflare.F([]load_balancers.OriginParam{{ Address: cloudflare.F("0.0.0.0"), Enabled: cloudflare.F(true), - Header: cloudflare.F(user.LoadBalancerPoolUpdateParamsOriginsHeader{ + Header: cloudflare.F(load_balancers.HeaderParam{ Host: cloudflare.F([]string{"example.com", "example.com", "example.com"}), }), Name: cloudflare.F("app-server-1"), @@ -126,7 +127,7 @@ func TestLoadBalancerPoolUpdateWithOptionalParams(t *testing.T) { }, { Address: cloudflare.F("0.0.0.0"), Enabled: cloudflare.F(true), - Header: cloudflare.F(user.LoadBalancerPoolUpdateParamsOriginsHeader{ + Header: cloudflare.F(load_balancers.HeaderParam{ Host: cloudflare.F([]string{"example.com", "example.com", "example.com"}), }), Name: cloudflare.F("app-server-1"), @@ -135,7 +136,7 @@ func TestLoadBalancerPoolUpdateWithOptionalParams(t *testing.T) { }, { Address: cloudflare.F("0.0.0.0"), Enabled: cloudflare.F(true), - Header: cloudflare.F(user.LoadBalancerPoolUpdateParamsOriginsHeader{ + Header: cloudflare.F(load_balancers.HeaderParam{ Host: cloudflare.F([]string{"example.com", "example.com", "example.com"}), }), Name: cloudflare.F("app-server-1"), @@ -146,28 +147,28 @@ func TestLoadBalancerPoolUpdateWithOptionalParams(t *testing.T) { Description: cloudflare.F("Primary data center - Provider XYZ"), Enabled: cloudflare.F(false), Latitude: cloudflare.F(0.000000), - LoadShedding: cloudflare.F(user.LoadBalancerPoolUpdateParamsLoadShedding{ + LoadShedding: cloudflare.F(load_balancers.LoadSheddingParam{ DefaultPercent: cloudflare.F(0.000000), - DefaultPolicy: cloudflare.F(user.LoadBalancerPoolUpdateParamsLoadSheddingDefaultPolicyRandom), + DefaultPolicy: cloudflare.F(load_balancers.LoadSheddingDefaultPolicyRandom), SessionPercent: cloudflare.F(0.000000), - SessionPolicy: cloudflare.F(user.LoadBalancerPoolUpdateParamsLoadSheddingSessionPolicyHash), + SessionPolicy: cloudflare.F(load_balancers.LoadSheddingSessionPolicyHash), }), Longitude: cloudflare.F(0.000000), MinimumOrigins: cloudflare.F(int64(0)), Monitor: cloudflare.F[any](map[string]interface{}{}), NotificationEmail: cloudflare.F("someone@example.com,sometwo@example.com"), - NotificationFilter: cloudflare.F(user.LoadBalancerPoolUpdateParamsNotificationFilter{ - Origin: cloudflare.F(user.LoadBalancerPoolUpdateParamsNotificationFilterOrigin{ + NotificationFilter: cloudflare.F(load_balancers.NotificationFilterParam{ + Origin: cloudflare.F(load_balancers.FilterOptionsParam{ Disable: cloudflare.F(true), Healthy: cloudflare.F(true), }), - Pool: cloudflare.F(user.LoadBalancerPoolUpdateParamsNotificationFilterPool{ + Pool: cloudflare.F(load_balancers.FilterOptionsParam{ Disable: cloudflare.F(true), Healthy: cloudflare.F(false), }), }), - OriginSteering: cloudflare.F(user.LoadBalancerPoolUpdateParamsOriginSteering{ - Policy: cloudflare.F(user.LoadBalancerPoolUpdateParamsOriginSteeringPolicyRandom), + OriginSteering: cloudflare.F(load_balancers.OriginSteeringParam{ + Policy: cloudflare.F(load_balancers.OriginSteeringPolicyRandom), }), }, ) @@ -258,34 +259,34 @@ func TestLoadBalancerPoolEditWithOptionalParams(t *testing.T) { Description: cloudflare.F("Primary data center - Provider XYZ"), Enabled: cloudflare.F(false), Latitude: cloudflare.F(0.000000), - LoadShedding: cloudflare.F(user.LoadBalancerPoolEditParamsLoadShedding{ + LoadShedding: cloudflare.F(load_balancers.LoadSheddingParam{ DefaultPercent: cloudflare.F(0.000000), - DefaultPolicy: cloudflare.F(user.LoadBalancerPoolEditParamsLoadSheddingDefaultPolicyRandom), + DefaultPolicy: cloudflare.F(load_balancers.LoadSheddingDefaultPolicyRandom), SessionPercent: cloudflare.F(0.000000), - SessionPolicy: cloudflare.F(user.LoadBalancerPoolEditParamsLoadSheddingSessionPolicyHash), + SessionPolicy: cloudflare.F(load_balancers.LoadSheddingSessionPolicyHash), }), Longitude: cloudflare.F(0.000000), MinimumOrigins: cloudflare.F(int64(0)), Monitor: cloudflare.F[any](map[string]interface{}{}), Name: cloudflare.F("primary-dc-1"), NotificationEmail: cloudflare.F("someone@example.com,sometwo@example.com"), - NotificationFilter: cloudflare.F(user.LoadBalancerPoolEditParamsNotificationFilter{ - Origin: cloudflare.F(user.LoadBalancerPoolEditParamsNotificationFilterOrigin{ + NotificationFilter: cloudflare.F(load_balancers.NotificationFilterParam{ + Origin: cloudflare.F(load_balancers.FilterOptionsParam{ Disable: cloudflare.F(true), Healthy: cloudflare.F(true), }), - Pool: cloudflare.F(user.LoadBalancerPoolEditParamsNotificationFilterPool{ + Pool: cloudflare.F(load_balancers.FilterOptionsParam{ Disable: cloudflare.F(true), Healthy: cloudflare.F(false), }), }), - OriginSteering: cloudflare.F(user.LoadBalancerPoolEditParamsOriginSteering{ - Policy: cloudflare.F(user.LoadBalancerPoolEditParamsOriginSteeringPolicyRandom), + OriginSteering: cloudflare.F(load_balancers.OriginSteeringParam{ + Policy: cloudflare.F(load_balancers.OriginSteeringPolicyRandom), }), - Origins: cloudflare.F([]user.LoadBalancerPoolEditParamsOrigin{{ + Origins: cloudflare.F([]load_balancers.OriginParam{{ Address: cloudflare.F("0.0.0.0"), Enabled: cloudflare.F(true), - Header: cloudflare.F(user.LoadBalancerPoolEditParamsOriginsHeader{ + Header: cloudflare.F(load_balancers.HeaderParam{ Host: cloudflare.F([]string{"example.com", "example.com", "example.com"}), }), Name: cloudflare.F("app-server-1"), @@ -294,7 +295,7 @@ func TestLoadBalancerPoolEditWithOptionalParams(t *testing.T) { }, { Address: cloudflare.F("0.0.0.0"), Enabled: cloudflare.F(true), - Header: cloudflare.F(user.LoadBalancerPoolEditParamsOriginsHeader{ + Header: cloudflare.F(load_balancers.HeaderParam{ Host: cloudflare.F([]string{"example.com", "example.com", "example.com"}), }), Name: cloudflare.F("app-server-1"), @@ -303,7 +304,7 @@ func TestLoadBalancerPoolEditWithOptionalParams(t *testing.T) { }, { Address: cloudflare.F("0.0.0.0"), Enabled: cloudflare.F(true), - Header: cloudflare.F(user.LoadBalancerPoolEditParamsOriginsHeader{ + Header: cloudflare.F(load_balancers.HeaderParam{ Host: cloudflare.F([]string{"example.com", "example.com", "example.com"}), }), Name: cloudflare.F("app-server-1"), diff --git a/user/tokenpermissiongroup.go b/user/tokenpermissiongroup.go index cccc912bcfa..7169a80adad 100644 --- a/user/tokenpermissiongroup.go +++ b/user/tokenpermissiongroup.go @@ -6,7 +6,10 @@ import ( "context" "net/http" + "github.com/cloudflare/cloudflare-go/v2/accounts" + "github.com/cloudflare/cloudflare-go/v2/internal/apijson" "github.com/cloudflare/cloudflare-go/v2/internal/pagination" + "github.com/cloudflare/cloudflare-go/v2/internal/param" "github.com/cloudflare/cloudflare-go/v2/internal/requestconfig" "github.com/cloudflare/cloudflare-go/v2/option" ) @@ -52,4 +55,65 @@ func (r *TokenPermissionGroupService) ListAutoPaging(ctx context.Context, opts . return pagination.NewSinglePageAutoPager(r.List(ctx, opts...)) } +type Permission struct { + Analytics accounts.PermissionGrant `json:"analytics"` + Billing accounts.PermissionGrant `json:"billing"` + CachePurge accounts.PermissionGrant `json:"cache_purge"` + DNS accounts.PermissionGrant `json:"dns"` + DNSRecords accounts.PermissionGrant `json:"dns_records"` + Lb accounts.PermissionGrant `json:"lb"` + Logs accounts.PermissionGrant `json:"logs"` + Organization accounts.PermissionGrant `json:"organization"` + SSL accounts.PermissionGrant `json:"ssl"` + WAF accounts.PermissionGrant `json:"waf"` + ZoneSettings accounts.PermissionGrant `json:"zone_settings"` + Zones accounts.PermissionGrant `json:"zones"` + JSON permissionJSON `json:"-"` +} + +// permissionJSON contains the JSON metadata for the struct [Permission] +type permissionJSON struct { + Analytics apijson.Field + Billing apijson.Field + CachePurge apijson.Field + DNS apijson.Field + DNSRecords apijson.Field + Lb apijson.Field + Logs apijson.Field + Organization apijson.Field + SSL apijson.Field + WAF apijson.Field + ZoneSettings apijson.Field + Zones apijson.Field + raw string + ExtraFields map[string]apijson.Field +} + +func (r *Permission) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r permissionJSON) RawJSON() string { + return r.raw +} + +type PermissionParam struct { + Analytics param.Field[accounts.PermissionGrantParam] `json:"analytics"` + Billing param.Field[accounts.PermissionGrantParam] `json:"billing"` + CachePurge param.Field[accounts.PermissionGrantParam] `json:"cache_purge"` + DNS param.Field[accounts.PermissionGrantParam] `json:"dns"` + DNSRecords param.Field[accounts.PermissionGrantParam] `json:"dns_records"` + Lb param.Field[accounts.PermissionGrantParam] `json:"lb"` + Logs param.Field[accounts.PermissionGrantParam] `json:"logs"` + Organization param.Field[accounts.PermissionGrantParam] `json:"organization"` + SSL param.Field[accounts.PermissionGrantParam] `json:"ssl"` + WAF param.Field[accounts.PermissionGrantParam] `json:"waf"` + ZoneSettings param.Field[accounts.PermissionGrantParam] `json:"zone_settings"` + Zones param.Field[accounts.PermissionGrantParam] `json:"zones"` +} + +func (r PermissionParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + type TokenPermissionGroupListResponse = interface{}