diff --git a/.stats.yml b/.stats.yml index 71e1621688b..0818ecbb822 100644 --- a/.stats.yml +++ b/.stats.yml @@ -1 +1 @@ -configured_endpoints: 1274 +configured_endpoints: 1251 diff --git a/accounts/member.go b/accounts/member.go index 21594c6ba69..b0469201780 100644 --- a/accounts/member.go +++ b/accounts/member.go @@ -15,7 +15,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/cloudflare/cloudflare-go/v2/user" ) // MemberService contains methods and other services that help with interacting @@ -144,9 +143,9 @@ type MemberRole struct { // 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:"-"` + Name string `json:"name,required"` + Permissions MemberRolesPermissions `json:"permissions,required"` + JSON memberRoleJSON `json:"-"` } // memberRoleJSON contains the JSON metadata for the struct [MemberRole] @@ -167,6 +166,49 @@ func (r memberRoleJSON) RawJSON() string { return r.raw } +type MemberRolesPermissions 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 memberRolesPermissionsJSON `json:"-"` +} + +// memberRolesPermissionsJSON contains the JSON metadata for the struct +// [MemberRolesPermissions] +type memberRolesPermissionsJSON 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 *MemberRolesPermissions) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r memberRolesPermissionsJSON) RawJSON() string { + return r.raw +} + type MemberUser struct { // The contact email address of the user. Email string `json:"email,required"` @@ -241,9 +283,9 @@ type MemberWithInviteCodeRole struct { // Description of role's permissions. Description string `json:"description,required"` // Role name. - Name string `json:"name,required"` - Permissions user.Permission `json:"permissions,required"` - JSON memberWithInviteCodeRoleJSON `json:"-"` + Name string `json:"name,required"` + Permissions MemberWithInviteCodeRolesPermissions `json:"permissions,required"` + JSON memberWithInviteCodeRoleJSON `json:"-"` } // memberWithInviteCodeRoleJSON contains the JSON metadata for the struct @@ -265,6 +307,49 @@ func (r memberWithInviteCodeRoleJSON) RawJSON() string { return r.raw } +type MemberWithInviteCodeRolesPermissions 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 memberWithInviteCodeRolesPermissionsJSON `json:"-"` +} + +// memberWithInviteCodeRolesPermissionsJSON contains the JSON metadata for the +// struct [MemberWithInviteCodeRolesPermissions] +type memberWithInviteCodeRolesPermissionsJSON 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 *MemberWithInviteCodeRolesPermissions) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r memberWithInviteCodeRolesPermissionsJSON) RawJSON() string { + return r.raw +} + type MemberWithInviteCodeUser struct { // The contact email address of the user. Email string `json:"email,required"` @@ -462,6 +547,25 @@ func (r MemberUpdateParamsRole) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } +type MemberUpdateParamsRolesPermissions 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 MemberUpdateParamsRolesPermissions) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + type MemberUpdateResponseEnvelope struct { Errors []shared.ResponseInfo `json:"errors,required"` Messages []shared.ResponseInfo `json:"messages,required"` diff --git a/accounts/role.go b/accounts/role.go index e32e9f05b99..c19a1652af4 100644 --- a/accounts/role.go +++ b/accounts/role.go @@ -108,8 +108,8 @@ type Role struct { // Role Name. Name string `json:"name,required"` // Access permissions for this User. - Permissions []user.PermissionItem `json:"permissions,required"` - JSON roleJSON `json:"-"` + Permissions []user.Permission `json:"permissions,required"` + JSON roleJSON `json:"-"` } // roleJSON contains the JSON metadata for the struct [Role] diff --git a/api.md b/api.md index 809d710c414..cf616f7bb7c 100644 --- a/api.md +++ b/api.md @@ -133,22 +133,6 @@ Methods: - client.User.Billing.Profile.Get(ctx context.Context) (shared.UnnamedSchemaRef9444735ca60712dbcf8afd832eb5716aUnion, error) -## Firewall - -### AccessRules - -Response Types: - -- user.FirewallRule -- user.FirewallAccessRuleDeleteResponse - -Methods: - -- client.User.Firewall.AccessRules.New(ctx context.Context, body user.FirewallAccessRuleNewParams) (user.FirewallRule, error) -- client.User.Firewall.AccessRules.List(ctx context.Context, query user.FirewallAccessRuleListParams) (pagination.V4PagePaginationArray[user.FirewallRule], error) -- client.User.Firewall.AccessRules.Delete(ctx context.Context, identifier string, body user.FirewallAccessRuleDeleteParams) (user.FirewallAccessRuleDeleteResponse, error) -- client.User.Firewall.AccessRules.Edit(ctx context.Context, identifier string, body user.FirewallAccessRuleEditParams) (user.FirewallRule, error) - ## Invites Response Types: @@ -161,75 +145,6 @@ Methods: - client.User.Invites.Edit(ctx context.Context, inviteID string, body user.InviteEditParams) (shared.UnnamedSchemaRef9444735ca60712dbcf8afd832eb5716aUnion, error) - client.User.Invites.Get(ctx context.Context, inviteID string) (shared.UnnamedSchemaRef9444735ca60712dbcf8afd832eb5716aUnion, error) -## LoadBalancing - -### Monitors - -Response Types: - -- user.LoadBalancingMonitorNewResponse -- user.LoadBalancingMonitorUpdateResponse -- user.LoadBalancingMonitorListResponse -- user.LoadBalancingMonitorDeleteResponse -- user.LoadBalancingMonitorEditResponse -- user.LoadBalancingMonitorGetResponse -- user.LoadBalancingMonitorPreviewResponse -- user.LoadBalancingMonitorReferencesResponse - -Methods: - -- client.User.LoadBalancing.Monitors.New(ctx context.Context, body user.LoadBalancingMonitorNewParams) (user.LoadBalancingMonitorNewResponse, error) -- client.User.LoadBalancing.Monitors.Update(ctx context.Context, monitorID string, body user.LoadBalancingMonitorUpdateParams) (user.LoadBalancingMonitorUpdateResponse, error) -- client.User.LoadBalancing.Monitors.List(ctx context.Context) (pagination.SinglePage[user.LoadBalancingMonitorListResponse], error) -- client.User.LoadBalancing.Monitors.Delete(ctx context.Context, monitorID string, body user.LoadBalancingMonitorDeleteParams) (user.LoadBalancingMonitorDeleteResponse, error) -- client.User.LoadBalancing.Monitors.Edit(ctx context.Context, monitorID string, body user.LoadBalancingMonitorEditParams) (user.LoadBalancingMonitorEditResponse, error) -- client.User.LoadBalancing.Monitors.Get(ctx context.Context, monitorID string) (user.LoadBalancingMonitorGetResponse, error) -- client.User.LoadBalancing.Monitors.Preview(ctx context.Context, monitorID string, body user.LoadBalancingMonitorPreviewParams) (user.LoadBalancingMonitorPreviewResponse, error) -- client.User.LoadBalancing.Monitors.References(ctx context.Context, monitorID string) ([]user.LoadBalancingMonitorReferencesResponse, error) - -### Pools - -Response Types: - -- user.LoadBalancingPoolDeleteResponse -- user.LoadBalancingPoolHealthResponseUnion -- user.LoadBalancingPoolPreviewResponse -- user.LoadBalancingPoolReferencesResponse - -Methods: - -- client.User.LoadBalancing.Pools.New(ctx context.Context, body user.LoadBalancingPoolNewParams) (load_balancers.Pool, error) -- client.User.LoadBalancing.Pools.Update(ctx context.Context, poolID string, body user.LoadBalancingPoolUpdateParams) (load_balancers.Pool, error) -- client.User.LoadBalancing.Pools.List(ctx context.Context, query user.LoadBalancingPoolListParams) (pagination.SinglePage[load_balancers.Pool], error) -- client.User.LoadBalancing.Pools.Delete(ctx context.Context, poolID string, body user.LoadBalancingPoolDeleteParams) (user.LoadBalancingPoolDeleteResponse, error) -- client.User.LoadBalancing.Pools.Edit(ctx context.Context, poolID string, body user.LoadBalancingPoolEditParams) (load_balancers.Pool, error) -- client.User.LoadBalancing.Pools.Get(ctx context.Context, poolID string) (load_balancers.Pool, error) -- client.User.LoadBalancing.Pools.Health(ctx context.Context, poolID string) (user.LoadBalancingPoolHealthResponseUnion, error) -- client.User.LoadBalancing.Pools.Preview(ctx context.Context, poolID string, body user.LoadBalancingPoolPreviewParams) (user.LoadBalancingPoolPreviewResponse, error) -- client.User.LoadBalancing.Pools.References(ctx context.Context, poolID string) ([]user.LoadBalancingPoolReferencesResponse, error) - -### Preview - -Response Types: - -- user.LoadBalancingPreviewGetResponse - -Methods: - -- client.User.LoadBalancing.Preview.Get(ctx context.Context, previewID string) (user.LoadBalancingPreviewGetResponse, error) - -### Analytics - -Response Types: - -- user.Analytics - -#### Events - -Methods: - -- client.User.LoadBalancing.Analytics.Events.List(ctx context.Context, query user.LoadBalancingAnalyticsEventListParams) (pagination.SinglePage[user.Analytics], error) - ## Organizations Response Types: @@ -261,7 +176,7 @@ Methods: Params Types: -- user.CIDRListItemParam +- user.CIDRListParam - user.PolicyParam Response Types: @@ -283,14 +198,9 @@ Methods: ### PermissionGroups -Params Types: - -- user.PermissionParam - Response Types: - user.Permission -- user.PermissionItem - user.TokenPermissionGroupListResponse Methods: @@ -986,27 +896,27 @@ Params Types: - load_balancers.AdaptiveRoutingParam - load_balancers.CheckRegion -- load_balancers.DefaultPoolsItemParam +- load_balancers.DefaultPoolsParam - load_balancers.FilterOptionsParam - load_balancers.HeaderParam -- load_balancers.HostItemParam +- load_balancers.HostParam - load_balancers.LoadSheddingParam - load_balancers.LocationStrategyParam - load_balancers.NotificationFilterParam - load_balancers.OriginParam - load_balancers.OriginSteeringParam - load_balancers.RandomSteeringParam -- load_balancers.RulesItemParam +- load_balancers.RulesParam - load_balancers.SessionAffinityAttributesParam Response Types: - load_balancers.AdaptiveRouting - load_balancers.CheckRegion -- load_balancers.DefaultPoolsItem +- load_balancers.DefaultPools - load_balancers.FilterOptions - load_balancers.Header -- load_balancers.HostItem +- load_balancers.Host - load_balancers.LoadBalancer - load_balancers.LoadShedding - load_balancers.LocationStrategy @@ -1014,7 +924,7 @@ Response Types: - load_balancers.Origin - load_balancers.OriginSteering - load_balancers.RandomSteering -- load_balancers.RulesItem +- load_balancers.Rules - load_balancers.SessionAffinityAttributes - load_balancers.LoadBalancerDeleteResponse @@ -1212,11 +1122,11 @@ Methods: Params Types: -- ssl.HostItemParam +- ssl.HostParam Response Types: -- ssl.HostItem +- ssl.Host - ssl.CertificatePackListResponse - ssl.CertificatePackDeleteResponse - ssl.CertificatePackEditResponse @@ -1355,11 +1265,11 @@ Methods: Params Types: -- certificate_authorities.HostnameAssociationItemParam +- certificate_authorities.HostnameAssociationParam Response Types: -- certificate_authorities.HostnameAssociationItem +- certificate_authorities.HostnameAssociation - certificate_authorities.HostnameAssociationUpdateResponse - certificate_authorities.HostnameAssociationGetResponse @@ -1468,7 +1378,7 @@ Response Types: Params Types: -- dns.RecordTagsItemParam +- dns.RecordTagsParam - dns.TTLUnionParam Response Types: @@ -1487,7 +1397,7 @@ Response Types: - dns.NSRecord - dns.PTRRecord - dns.Record -- dns.RecordTagsItem +- dns.RecordTags - dns.SMIMEARecord - dns.SRVRecord - dns.SSHFPRecord @@ -1541,14 +1451,14 @@ Methods: Params Types: - dns.AttackMitigationParam -- dns.FirewallIPsItemUnionParam +- dns.FirewallIPsUnionParam - dns.UpstreamIPsUnionParam Response Types: - dns.AttackMitigation - dns.Firewall -- dns.FirewallIPsItemUnion +- dns.FirewallIPsUnion - dns.UpstreamIPsUnion - dns.FirewallDeleteResponse @@ -1695,7 +1605,7 @@ Response Types: - firewall.Lockdown - firewall.LockdownCIDRConfiguration - firewall.LockdownIPConfiguration -- firewall.URLsItem +- firewall.URLs - firewall.LockdownDeleteResponse Methods: @@ -1710,7 +1620,7 @@ Methods: Response Types: -- firewall.ProductsItem +- firewall.Products - firewall.Rule - firewall.DeletedFilter @@ -1735,11 +1645,6 @@ Params Types: Response Types: -- firewall.AccessRuleCIDRConfiguration -- firewall.AccessRuleIPConfiguration -- firewall.ASNConfiguration -- firewall.CountryConfiguration -- firewall.IPV6Configuration - firewall.AccessRuleListResponse - firewall.AccessRuleDeleteResponse @@ -1770,6 +1675,10 @@ Methods: ### Overrides +Params Types: + +- firewall.RulesParam + Response Types: - firewall.Override @@ -2233,12 +2142,12 @@ Methods: Params Types: -- waiting_rooms.AdditionalRoutesItemParam +- waiting_rooms.AdditionalRoutesParam - waiting_rooms.CookieAttributesParam Response Types: -- waiting_rooms.AdditionalRoutesItem +- waiting_rooms.AdditionalRoutes - waiting_rooms.CookieAttributes - waiting_rooms.WaitingRoom - waiting_rooms.WaitingRoomDeleteResponse @@ -2352,6 +2261,10 @@ Methods: #### ContentLists +Params Types: + +- web3.ContentListParam + Response Types: - web3.ContentList @@ -2365,21 +2278,21 @@ Methods: Params Types: -- web3.ContentListItemParam +- web3.ContentListParam Response Types: -- web3.ContentListItem +- web3.ContentList - web3.HostnameIPFSUniversalPathContentListEntryListResponse - web3.HostnameIPFSUniversalPathContentListEntryDeleteResponse Methods: -- client.Web3.Hostnames.IPFSUniversalPaths.ContentLists.Entries.New(ctx context.Context, zoneIdentifier string, identifier string, body web3.HostnameIPFSUniversalPathContentListEntryNewParams) (web3.ContentListItem, error) -- client.Web3.Hostnames.IPFSUniversalPaths.ContentLists.Entries.Update(ctx context.Context, zoneIdentifier string, identifier string, contentListEntryIdentifier string, body web3.HostnameIPFSUniversalPathContentListEntryUpdateParams) (web3.ContentListItem, error) +- client.Web3.Hostnames.IPFSUniversalPaths.ContentLists.Entries.New(ctx context.Context, zoneIdentifier string, identifier string, body web3.HostnameIPFSUniversalPathContentListEntryNewParams) (web3.ContentList, error) +- client.Web3.Hostnames.IPFSUniversalPaths.ContentLists.Entries.Update(ctx context.Context, zoneIdentifier string, identifier string, contentListEntryIdentifier string, body web3.HostnameIPFSUniversalPathContentListEntryUpdateParams) (web3.ContentList, error) - client.Web3.Hostnames.IPFSUniversalPaths.ContentLists.Entries.List(ctx context.Context, zoneIdentifier string, identifier string) (web3.HostnameIPFSUniversalPathContentListEntryListResponse, error) - client.Web3.Hostnames.IPFSUniversalPaths.ContentLists.Entries.Delete(ctx context.Context, zoneIdentifier string, identifier string, contentListEntryIdentifier string, body web3.HostnameIPFSUniversalPathContentListEntryDeleteParams) (web3.HostnameIPFSUniversalPathContentListEntryDeleteResponse, error) -- client.Web3.Hostnames.IPFSUniversalPaths.ContentLists.Entries.Get(ctx context.Context, zoneIdentifier string, identifier string, contentListEntryIdentifier string) (web3.ContentListItem, error) +- client.Web3.Hostnames.IPFSUniversalPaths.ContentLists.Entries.Get(ctx context.Context, zoneIdentifier string, identifier string, contentListEntryIdentifier string) (web3.ContentList, error) # Workers @@ -2446,11 +2359,11 @@ Methods: Params Types: -- workers.ConsumerScriptItemParam +- workers.ConsumerScriptParam Response Types: -- workers.ConsumerScriptItem +- workers.ConsumerScript - workers.ScriptTailNewResponse - workers.ScriptTailDeleteResponseUnion - workers.ScriptTailGetResponse @@ -2879,7 +2792,7 @@ Methods: Params Types: -- spectrum.DimensionItem +- spectrum.Dimension #### Bytimes @@ -3349,11 +3262,11 @@ Methods: Response Types: -- intel.SinkholeItem +- intel.Sinkhole Methods: -- client.Intel.Sinkholes.List(ctx context.Context, query intel.SinkholeListParams) (pagination.SinglePage[intel.SinkholeItem], error) +- client.Intel.Sinkholes.List(ctx context.Context, query intel.SinkholeListParams) (pagination.SinglePage[intel.Sinkhole], error) ## AttackSurfaceReport @@ -3803,7 +3716,6 @@ Methods: Response Types: - request_tracers.Trace -- request_tracers.TraceItem - request_tracers.TraceNewResponse Methods: @@ -3885,11 +3797,11 @@ Methods: Params Types: -- stream.AllowedOriginsItemParam +- stream.AllowedOriginsParam Response Types: -- stream.AllowedOriginsItem +- stream.AllowedOrigins - stream.Video Methods: @@ -4400,7 +4312,7 @@ Methods: Params Types: - zero_trust.InputUnionParam -- zero_trust.MatchItemParam +- zero_trust.MatchParam - zero_trust.UnnamedSchemaRef34ef0ad73a63c3f76ed170adca181930 - zero_trust.UnnamedSchemaRef41885dd46b9e0294254c49305a273681 @@ -4408,7 +4320,7 @@ Response Types: - zero_trust.DevicePostureRule - zero_trust.Input -- zero_trust.MatchItem +- zero_trust.Match - zero_trust.UnnamedSchemaRef34ef0ad73a63c3f76ed170adca181930 - zero_trust.UnnamedSchemaRef41885dd46b9e0294254c49305a273681 - zero_trust.DevicePostureDeleteResponse @@ -4657,11 +4569,11 @@ Methods: Params Types: -- zero_trust.AssociatedHostnamesItemParam +- zero_trust.AssociatedHostnamesParam Response Types: -- zero_trust.AssociatedHostnamesItem +- zero_trust.AssociatedHostnames - zero_trust.Certificate - zero_trust.AccessCertificateDeleteResponse @@ -5204,6 +5116,10 @@ Methods: ### Lists +Params Types: + +- zero_trust.ListsParam + Response Types: - zero_trust.Lists @@ -5222,15 +5138,15 @@ Methods: Params Types: -- zero_trust.ListsItemParam +- zero_trust.ListsParam Response Types: -- zero_trust.ListsItem +- zero_trust.Lists Methods: -- client.ZeroTrust.Gateway.Lists.Items.List(ctx context.Context, listID string, query zero_trust.GatewayListItemListParams) (pagination.SinglePage[[]zero_trust.ListsItem], error) +- client.ZeroTrust.Gateway.Lists.Items.List(ctx context.Context, listID string, query zero_trust.GatewayListItemListParams) (pagination.SinglePage[[]zero_trust.Lists], error) ### Locations @@ -5271,11 +5187,11 @@ Methods: Params Types: -- zero_trust.GatewayIPsItemParam +- zero_trust.GatewayIPsParam Response Types: -- zero_trust.GatewayIPsItem +- zero_trust.GatewayIPs - zero_trust.ProxyEndpoint Methods: @@ -5369,19 +5285,19 @@ Methods: Params Types: -- challenges.WidgetDomainItemParam +- challenges.WidgetDomainParam Response Types: - challenges.Widget - challenges.WidgetDomain -- challenges.WidgetDomainItem +- challenges.WidgetListResponse Methods: - client.Challenges.Widgets.New(ctx context.Context, params challenges.WidgetNewParams) (challenges.Widget, error) - client.Challenges.Widgets.Update(ctx context.Context, sitekey string, params challenges.WidgetUpdateParams) (challenges.Widget, error) -- client.Challenges.Widgets.List(ctx context.Context, params challenges.WidgetListParams) (pagination.V4PagePaginationArray[challenges.WidgetDomain], error) +- client.Challenges.Widgets.List(ctx context.Context, params challenges.WidgetListParams) (pagination.V4PagePaginationArray[challenges.WidgetListResponse], error) - client.Challenges.Widgets.Delete(ctx context.Context, sitekey string, body challenges.WidgetDeleteParams) (challenges.Widget, error) - client.Challenges.Widgets.Get(ctx context.Context, sitekey string, query challenges.WidgetGetParams) (challenges.Widget, error) - client.Challenges.Widgets.RotateSecret(ctx context.Context, sitekey string, params challenges.WidgetRotateSecretParams) (challenges.Widget, error) @@ -6584,7 +6500,7 @@ Methods: Response Types: - cloudforce_one.Item -- cloudforce_one.ListItem +- cloudforce_one.List - cloudforce_one.Quota - cloudforce_one.RequestConstants - cloudforce_one.RequestTypes @@ -6594,7 +6510,7 @@ Methods: - client.CloudforceOne.Requests.New(ctx context.Context, accountIdentifier string, body cloudforce_one.RequestNewParams) (cloudforce_one.Item, error) - client.CloudforceOne.Requests.Update(ctx context.Context, accountIdentifier string, requestIdentifier string, body cloudforce_one.RequestUpdateParams) (cloudforce_one.Item, error) -- client.CloudforceOne.Requests.List(ctx context.Context, accountIdentifier string, body cloudforce_one.RequestListParams) (pagination.V4PagePaginationArray[cloudforce_one.ListItem], error) +- client.CloudforceOne.Requests.List(ctx context.Context, accountIdentifier string, body cloudforce_one.RequestListParams) (pagination.V4PagePaginationArray[cloudforce_one.List], error) - client.CloudforceOne.Requests.Delete(ctx context.Context, accountIdentifier string, requestIdentifier string) (cloudforce_one.RequestDeleteResponseUnion, error) - client.CloudforceOne.Requests.Constants(ctx context.Context, accountIdentifier string) (cloudforce_one.RequestConstants, error) - client.CloudforceOne.Requests.Get(ctx context.Context, accountIdentifier string, requestIdentifier string) (cloudforce_one.Item, error) @@ -6619,11 +6535,11 @@ Methods: Params Types: -- cloudforce_one.LabelItemParam +- cloudforce_one.LabelParam Response Types: -- cloudforce_one.LabelItem +- cloudforce_one.Label - cloudforce_one.Priority - cloudforce_one.RequestPriorityDeleteResponseUnion diff --git a/certificate_authorities/hostnameassociation.go b/certificate_authorities/hostnameassociation.go index ee7b3d49492..8254554100e 100644 --- a/certificate_authorities/hostnameassociation.go +++ b/certificate_authorities/hostnameassociation.go @@ -60,12 +60,12 @@ func (r *HostnameAssociationService) Get(ctx context.Context, params HostnameAss return } -type HostnameAssociationItem = string +type HostnameAssociation = string -type HostnameAssociationItemParam = string +type HostnameAssociationParam = string type HostnameAssociationUpdateResponse struct { - Hostnames []HostnameAssociationItem `json:"hostnames"` + Hostnames []HostnameAssociation `json:"hostnames"` JSON hostnameAssociationUpdateResponseJSON `json:"-"` } @@ -86,7 +86,7 @@ func (r hostnameAssociationUpdateResponseJSON) RawJSON() string { } type HostnameAssociationGetResponse struct { - Hostnames []HostnameAssociationItem `json:"hostnames"` + Hostnames []HostnameAssociation `json:"hostnames"` JSON hostnameAssociationGetResponseJSON `json:"-"` } @@ -108,8 +108,8 @@ func (r hostnameAssociationGetResponseJSON) RawJSON() string { type HostnameAssociationUpdateParams struct { // Identifier - ZoneID param.Field[string] `path:"zone_id,required"` - Hostnames param.Field[[]HostnameAssociationItemParam] `json:"hostnames"` + ZoneID param.Field[string] `path:"zone_id,required"` + Hostnames param.Field[[]HostnameAssociationParam] `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 315b67c32bd..bb7d80f3216 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([]certificate_authorities.HostnameAssociationItemParam{"api.example.com", "api.example.com", "api.example.com"}), + Hostnames: cloudflare.F([]certificate_authorities.HostnameAssociationParam{"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 39230e0ab9e..f90f2aa08d5 100644 --- a/challenges/widget.go +++ b/challenges/widget.go @@ -62,7 +62,7 @@ func (r *WidgetService) Update(ctx context.Context, sitekey string, params Widge } // Lists all turnstile widgets of an account. -func (r *WidgetService) List(ctx context.Context, params WidgetListParams, opts ...option.RequestOption) (res *pagination.V4PagePaginationArray[WidgetDomain], err error) { +func (r *WidgetService) List(ctx context.Context, params WidgetListParams, opts ...option.RequestOption) (res *pagination.V4PagePaginationArray[WidgetListResponse], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -80,7 +80,7 @@ func (r *WidgetService) List(ctx context.Context, params WidgetListParams, opts } // Lists all turnstile widgets of an account. -func (r *WidgetService) ListAutoPaging(ctx context.Context, params WidgetListParams, opts ...option.RequestOption) *pagination.V4PagePaginationArrayAutoPager[WidgetDomain] { +func (r *WidgetService) ListAutoPaging(ctx context.Context, params WidgetListParams, opts ...option.RequestOption) *pagination.V4PagePaginationArrayAutoPager[WidgetListResponse] { return pagination.NewV4PagePaginationArrayAutoPager(r.List(ctx, params, opts...)) } @@ -135,8 +135,8 @@ type Widget struct { // challenge clearance, this setting can determine the clearance level to be set ClearanceLevel WidgetClearanceLevel `json:"clearance_level,required"` // When the widget was created. - CreatedOn time.Time `json:"created_on,required" format:"date-time"` - Domains []WidgetDomainItem `json:"domains,required"` + CreatedOn time.Time `json:"created_on,required" format:"date-time"` + Domains []WidgetDomain `json:"domains,required"` // Widget Mode Mode WidgetMode `json:"mode,required"` // When the widget was modified. @@ -232,19 +232,23 @@ func (r WidgetRegion) IsKnown() bool { return false } +type WidgetDomain = string + +type WidgetDomainParam = string + // A Turnstile Widgets configuration as it appears in listings -type WidgetDomain struct { +type WidgetListResponse struct { // If bot_fight_mode is set to `true`, Cloudflare issues computationally expensive // challenges in response to malicious bots (ENT only). BotFightMode bool `json:"bot_fight_mode,required"` // If Turnstile is embedded on a Cloudflare site and the widget should grant // challenge clearance, this setting can determine the clearance level to be set - ClearanceLevel WidgetDomainClearanceLevel `json:"clearance_level,required"` + ClearanceLevel WidgetListResponseClearanceLevel `json:"clearance_level,required"` // When the widget was created. - CreatedOn time.Time `json:"created_on,required" format:"date-time"` - Domains []WidgetDomainItem `json:"domains,required"` + CreatedOn time.Time `json:"created_on,required" format:"date-time"` + Domains []WidgetDomain `json:"domains,required"` // Widget Mode - Mode WidgetDomainMode `json:"mode,required"` + Mode WidgetListResponseMode `json:"mode,required"` // When the widget was modified. ModifiedOn time.Time `json:"modified_on,required" format:"date-time"` // Human readable widget name. Not unique. Cloudflare suggests that you set this to @@ -254,14 +258,15 @@ type WidgetDomain struct { // Do not show any Cloudflare branding on the widget (ENT only). Offlabel bool `json:"offlabel,required"` // Region where this widget can be used. - Region WidgetDomainRegion `json:"region,required"` + Region WidgetListResponseRegion `json:"region,required"` // Widget item identifier tag. - Sitekey string `json:"sitekey,required"` - JSON widgetDomainJSON `json:"-"` + Sitekey string `json:"sitekey,required"` + JSON widgetListResponseJSON `json:"-"` } -// widgetDomainJSON contains the JSON metadata for the struct [WidgetDomain] -type widgetDomainJSON struct { +// widgetListResponseJSON contains the JSON metadata for the struct +// [WidgetListResponse] +type widgetListResponseJSON struct { BotFightMode apijson.Field ClearanceLevel apijson.Field CreatedOn apijson.Field @@ -276,73 +281,69 @@ type widgetDomainJSON struct { ExtraFields map[string]apijson.Field } -func (r *WidgetDomain) UnmarshalJSON(data []byte) (err error) { +func (r *WidgetListResponse) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r widgetDomainJSON) RawJSON() string { +func (r widgetListResponseJSON) RawJSON() string { return r.raw } // If Turnstile is embedded on a Cloudflare site and the widget should grant // challenge clearance, this setting can determine the clearance level to be set -type WidgetDomainClearanceLevel string +type WidgetListResponseClearanceLevel string const ( - WidgetDomainClearanceLevelNoClearance WidgetDomainClearanceLevel = "no_clearance" - WidgetDomainClearanceLevelJschallenge WidgetDomainClearanceLevel = "jschallenge" - WidgetDomainClearanceLevelManaged WidgetDomainClearanceLevel = "managed" - WidgetDomainClearanceLevelInteractive WidgetDomainClearanceLevel = "interactive" + WidgetListResponseClearanceLevelNoClearance WidgetListResponseClearanceLevel = "no_clearance" + WidgetListResponseClearanceLevelJschallenge WidgetListResponseClearanceLevel = "jschallenge" + WidgetListResponseClearanceLevelManaged WidgetListResponseClearanceLevel = "managed" + WidgetListResponseClearanceLevelInteractive WidgetListResponseClearanceLevel = "interactive" ) -func (r WidgetDomainClearanceLevel) IsKnown() bool { +func (r WidgetListResponseClearanceLevel) IsKnown() bool { switch r { - case WidgetDomainClearanceLevelNoClearance, WidgetDomainClearanceLevelJschallenge, WidgetDomainClearanceLevelManaged, WidgetDomainClearanceLevelInteractive: + case WidgetListResponseClearanceLevelNoClearance, WidgetListResponseClearanceLevelJschallenge, WidgetListResponseClearanceLevelManaged, WidgetListResponseClearanceLevelInteractive: return true } return false } // Widget Mode -type WidgetDomainMode string +type WidgetListResponseMode string const ( - WidgetDomainModeNonInteractive WidgetDomainMode = "non-interactive" - WidgetDomainModeInvisible WidgetDomainMode = "invisible" - WidgetDomainModeManaged WidgetDomainMode = "managed" + WidgetListResponseModeNonInteractive WidgetListResponseMode = "non-interactive" + WidgetListResponseModeInvisible WidgetListResponseMode = "invisible" + WidgetListResponseModeManaged WidgetListResponseMode = "managed" ) -func (r WidgetDomainMode) IsKnown() bool { +func (r WidgetListResponseMode) IsKnown() bool { switch r { - case WidgetDomainModeNonInteractive, WidgetDomainModeInvisible, WidgetDomainModeManaged: + case WidgetListResponseModeNonInteractive, WidgetListResponseModeInvisible, WidgetListResponseModeManaged: return true } return false } // Region where this widget can be used. -type WidgetDomainRegion string +type WidgetListResponseRegion string const ( - WidgetDomainRegionWorld WidgetDomainRegion = "world" + WidgetListResponseRegionWorld WidgetListResponseRegion = "world" ) -func (r WidgetDomainRegion) IsKnown() bool { +func (r WidgetListResponseRegion) IsKnown() bool { switch r { - case WidgetDomainRegionWorld: + case WidgetListResponseRegionWorld: return true } return false } -type WidgetDomainItem = string - -type WidgetDomainItemParam = string - type WidgetNewParams struct { // Identifier - AccountID param.Field[string] `path:"account_id,required"` - Domains param.Field[[]WidgetDomainItemParam] `json:"domains,required"` + AccountID param.Field[string] `path:"account_id,required"` + Domains param.Field[[]WidgetDomainParam] `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 @@ -531,8 +532,8 @@ func (r widgetNewResponseEnvelopeResultInfoJSON) RawJSON() string { type WidgetUpdateParams struct { // Identifier - AccountID param.Field[string] `path:"account_id,required"` - Domains param.Field[[]WidgetDomainItemParam] `json:"domains,required"` + AccountID param.Field[string] `path:"account_id,required"` + Domains param.Field[[]WidgetDomainParam] `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 6cfdb5d7ab8..489014e7763 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([]challenges.WidgetDomainItemParam{"203.0.113.1", "cloudflare.com", "blog.example.com"}), + Domains: cloudflare.F([]challenges.WidgetDomainParam{"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([]challenges.WidgetDomainItemParam{"203.0.113.1", "cloudflare.com", "blog.example.com"}), + Domains: cloudflare.F([]challenges.WidgetDomainParam{"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/cloudforce_one/request.go b/cloudforce_one/request.go index 34545b10e2e..110deffea0c 100644 --- a/cloudforce_one/request.go +++ b/cloudforce_one/request.go @@ -70,7 +70,7 @@ func (r *RequestService) Update(ctx context.Context, accountIdentifier string, r } // List Requests -func (r *RequestService) List(ctx context.Context, accountIdentifier string, body RequestListParams, opts ...option.RequestOption) (res *pagination.V4PagePaginationArray[ListItem], err error) { +func (r *RequestService) List(ctx context.Context, accountIdentifier string, body RequestListParams, opts ...option.RequestOption) (res *pagination.V4PagePaginationArray[List], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -88,7 +88,7 @@ func (r *RequestService) List(ctx context.Context, accountIdentifier string, bod } // List Requests -func (r *RequestService) ListAutoPaging(ctx context.Context, accountIdentifier string, body RequestListParams, opts ...option.RequestOption) *pagination.V4PagePaginationArrayAutoPager[ListItem] { +func (r *RequestService) ListAutoPaging(ctx context.Context, accountIdentifier string, body RequestListParams, opts ...option.RequestOption) *pagination.V4PagePaginationArrayAutoPager[List] { return pagination.NewV4PagePaginationArrayAutoPager(r.List(ctx, accountIdentifier, body, opts...)) } @@ -249,18 +249,18 @@ func (r ItemStatus) IsKnown() bool { return false } -type ListItem struct { +type List struct { // UUID ID string `json:"id,required"` // Request creation time - Created time.Time `json:"created,required" format:"date-time"` - Priority ListItemPriority `json:"priority,required"` + Created time.Time `json:"created,required" format:"date-time"` + Priority ListPriority `json:"priority,required"` // Requested information from request Request string `json:"request,required"` // Brief description of the request Summary string `json:"summary,required"` // The CISA defined Traffic Light Protocol (TLP) - Tlp ListItemTlp `json:"tlp,required"` + Tlp ListTlp `json:"tlp,required"` // Request last updated time Updated time.Time `json:"updated,required" format:"date-time"` // Request completion time @@ -270,14 +270,14 @@ type ListItem struct { // Readable Request ID ReadableID string `json:"readable_id"` // Request Status - Status ListItemStatus `json:"status"` + Status ListStatus `json:"status"` // Tokens for the request - Tokens int64 `json:"tokens"` - JSON listItemJSON `json:"-"` + Tokens int64 `json:"tokens"` + JSON listJSON `json:"-"` } -// listItemJSON contains the JSON metadata for the struct [ListItem] -type listItemJSON struct { +// listJSON contains the JSON metadata for the struct [List] +type listJSON struct { ID apijson.Field Created apijson.Field Priority apijson.Field @@ -294,64 +294,64 @@ type listItemJSON struct { ExtraFields map[string]apijson.Field } -func (r *ListItem) UnmarshalJSON(data []byte) (err error) { +func (r *List) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r listItemJSON) RawJSON() string { +func (r listJSON) RawJSON() string { return r.raw } -type ListItemPriority string +type ListPriority string const ( - ListItemPriorityRoutine ListItemPriority = "routine" - ListItemPriorityHigh ListItemPriority = "high" - ListItemPriorityUrgent ListItemPriority = "urgent" + ListPriorityRoutine ListPriority = "routine" + ListPriorityHigh ListPriority = "high" + ListPriorityUrgent ListPriority = "urgent" ) -func (r ListItemPriority) IsKnown() bool { +func (r ListPriority) IsKnown() bool { switch r { - case ListItemPriorityRoutine, ListItemPriorityHigh, ListItemPriorityUrgent: + case ListPriorityRoutine, ListPriorityHigh, ListPriorityUrgent: return true } return false } // The CISA defined Traffic Light Protocol (TLP) -type ListItemTlp string +type ListTlp string const ( - ListItemTlpClear ListItemTlp = "clear" - ListItemTlpAmber ListItemTlp = "amber" - ListItemTlpAmberStrict ListItemTlp = "amber-strict" - ListItemTlpGreen ListItemTlp = "green" - ListItemTlpRed ListItemTlp = "red" + ListTlpClear ListTlp = "clear" + ListTlpAmber ListTlp = "amber" + ListTlpAmberStrict ListTlp = "amber-strict" + ListTlpGreen ListTlp = "green" + ListTlpRed ListTlp = "red" ) -func (r ListItemTlp) IsKnown() bool { +func (r ListTlp) IsKnown() bool { switch r { - case ListItemTlpClear, ListItemTlpAmber, ListItemTlpAmberStrict, ListItemTlpGreen, ListItemTlpRed: + case ListTlpClear, ListTlpAmber, ListTlpAmberStrict, ListTlpGreen, ListTlpRed: return true } return false } // Request Status -type ListItemStatus string +type ListStatus string const ( - ListItemStatusOpen ListItemStatus = "open" - ListItemStatusAccepted ListItemStatus = "accepted" - ListItemStatusReported ListItemStatus = "reported" - ListItemStatusApproved ListItemStatus = "approved" - ListItemStatusCompleted ListItemStatus = "completed" - ListItemStatusDeclined ListItemStatus = "declined" + ListStatusOpen ListStatus = "open" + ListStatusAccepted ListStatus = "accepted" + ListStatusReported ListStatus = "reported" + ListStatusApproved ListStatus = "approved" + ListStatusCompleted ListStatus = "completed" + ListStatusDeclined ListStatus = "declined" ) -func (r ListItemStatus) IsKnown() bool { +func (r ListStatus) IsKnown() bool { switch r { - case ListItemStatusOpen, ListItemStatusAccepted, ListItemStatusReported, ListItemStatusApproved, ListItemStatusCompleted, ListItemStatusDeclined: + case ListStatusOpen, ListStatusAccepted, ListStatusReported, ListStatusApproved, ListStatusCompleted, ListStatusDeclined: return true } return false diff --git a/cloudforce_one/requestpriority.go b/cloudforce_one/requestpriority.go index dec691cff99..51744f0215c 100644 --- a/cloudforce_one/requestpriority.go +++ b/cloudforce_one/requestpriority.go @@ -100,9 +100,9 @@ func (r *RequestPriorityService) Quota(ctx context.Context, accountIdentifier st return } -type LabelItem = string +type Label = string -type LabelItemParam = string +type LabelParam = string type Priority struct { // UUID @@ -110,7 +110,7 @@ type Priority struct { // Priority creation time Created time.Time `json:"created,required" format:"date-time"` // List of labels - Labels []LabelItem `json:"labels,required"` + Labels []Label `json:"labels,required"` // Priority Priority int64 `json:"priority,required"` // Requirement @@ -190,7 +190,7 @@ func (r RequestPriorityDeleteResponseArray) ImplementsCloudforceOneRequestPriori type RequestPriorityNewParams struct { // List of labels - Labels param.Field[[]LabelItemParam] `json:"labels,required"` + Labels param.Field[[]LabelParam] `json:"labels,required"` // Priority Priority param.Field[int64] `json:"priority,required"` // Requirement @@ -267,7 +267,7 @@ func (r RequestPriorityNewResponseEnvelopeSuccess) IsKnown() bool { type RequestPriorityUpdateParams struct { // List of labels - Labels param.Field[[]LabelItemParam] `json:"labels,required"` + Labels param.Field[[]LabelParam] `json:"labels,required"` // Priority Priority param.Field[int64] `json:"priority,required"` // Requirement diff --git a/cloudforce_one/requestpriority_test.go b/cloudforce_one/requestpriority_test.go index fd721ac8b05..0801ed1229a 100644 --- a/cloudforce_one/requestpriority_test.go +++ b/cloudforce_one/requestpriority_test.go @@ -32,7 +32,7 @@ func TestRequestPriorityNew(t *testing.T) { context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", cloudforce_one.RequestPriorityNewParams{ - Labels: cloudflare.F([]cloudforce_one.LabelItemParam{"DoS", "CVE"}), + Labels: cloudflare.F([]cloudforce_one.LabelParam{"DoS", "CVE"}), Priority: cloudflare.F(int64(1)), Requirement: cloudflare.F("DoS attacks carried out by CVEs"), Tlp: cloudflare.F(cloudforce_one.RequestPriorityNewParamsTlpClear), @@ -66,7 +66,7 @@ func TestRequestPriorityUpdate(t *testing.T) { "023e105f4ecef8ad9ca31a8372d0c353", "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", cloudforce_one.RequestPriorityUpdateParams{ - Labels: cloudflare.F([]cloudforce_one.LabelItemParam{"DoS", "CVE"}), + Labels: cloudflare.F([]cloudforce_one.LabelParam{"DoS", "CVE"}), Priority: cloudflare.F(int64(1)), Requirement: cloudflare.F("DoS attacks carried out by CVEs"), Tlp: cloudflare.F(cloudforce_one.RequestPriorityUpdateParamsTlpClear), diff --git a/dns/firewall.go b/dns/firewall.go index d3005a8fc0c..a305b739471 100644 --- a/dns/firewall.go +++ b/dns/firewall.go @@ -158,8 +158,8 @@ type Firewall struct { // Identifier ID string `json:"id,required"` // Deprecate the response to ANY requests. - DeprecateAnyRequests bool `json:"deprecate_any_requests,required"` - DNSFirewallIPs []FirewallIPsItemUnion `json:"dns_firewall_ips,required" format:"ipv4"` + DeprecateAnyRequests bool `json:"deprecate_any_requests,required"` + DNSFirewallIPs []FirewallIPsUnion `json:"dns_firewall_ips,required" format:"ipv4"` // Forward client IP (resolver) subnet if no EDNS Client Subnet is sent. EcsFallback bool `json:"ecs_fallback,required"` // Maximum DNS Cache TTL. @@ -214,13 +214,13 @@ func (r firewallJSON) RawJSON() string { // Cloudflare-assigned DNS IPv4 Address. // // Union satisfied by [shared.UnionString] or [shared.UnionString]. -type FirewallIPsItemUnion interface { - ImplementsDNSFirewallIPsItemUnion() +type FirewallIPsUnion interface { + ImplementsDNSFirewallIPsUnion() } func init() { apijson.RegisterUnion( - reflect.TypeOf((*FirewallIPsItemUnion)(nil)).Elem(), + reflect.TypeOf((*FirewallIPsUnion)(nil)).Elem(), "", apijson.UnionVariant{ TypeFilter: gjson.String, @@ -236,8 +236,8 @@ func init() { // Cloudflare-assigned DNS IPv4 Address. // // Satisfied by [shared.UnionString], [shared.UnionString]. -type FirewallIPsItemUnionParam interface { - ImplementsDNSFirewallIPsItemUnionParam() +type FirewallIPsUnionParam interface { + ImplementsDNSFirewallIPsUnionParam() } // Upstream DNS Server IPv4 Address. @@ -438,8 +438,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[[]FirewallIPsItemUnionParam] `json:"dns_firewall_ips,required" format:"ipv4"` + DeprecateAnyRequests param.Field[bool] `json:"deprecate_any_requests,required"` + DNSFirewallIPs param.Field[[]FirewallIPsUnionParam] `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. diff --git a/dns/firewall_test.go b/dns/firewall_test.go index 24f38fb4fb2..6b77616d2d7 100644 --- a/dns/firewall_test.go +++ b/dns/firewall_test.go @@ -133,7 +133,7 @@ func TestFirewallEditWithOptionalParams(t *testing.T) { dns.FirewallEditParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), DeprecateAnyRequests: cloudflare.F(true), - 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")}), + DNSFirewallIPs: cloudflare.F([]dns.FirewallIPsUnionParam{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), diff --git a/dns/record.go b/dns/record.go index 2525d5ca59b..924fb0a5dc5 100644 --- a/dns/record.go +++ b/dns/record.go @@ -218,7 +218,7 @@ type ARecord struct { // Cloudflare. Proxied bool `json:"proxied"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []RecordTagsItem `json:"tags"` + Tags []RecordTags `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -303,7 +303,7 @@ type AAAARecord struct { // Cloudflare. Proxied bool `json:"proxied"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []RecordTagsItem `json:"tags"` + Tags []RecordTags `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -387,7 +387,7 @@ type CAARecord struct { // Whether the record can be proxied by Cloudflare or not. Proxiable bool `json:"proxiable"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []RecordTagsItem `json:"tags"` + Tags []RecordTags `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -499,7 +499,7 @@ type CERTRecord struct { // Whether the record can be proxied by Cloudflare or not. Proxiable bool `json:"proxiable"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []RecordTagsItem `json:"tags"` + Tags []RecordTags `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -615,7 +615,7 @@ type CNAMERecord struct { // Cloudflare. Proxied bool `json:"proxied"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []RecordTagsItem `json:"tags"` + Tags []RecordTags `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -699,7 +699,7 @@ type DNSKEYRecord struct { // Whether the record can be proxied by Cloudflare or not. Proxiable bool `json:"proxiable"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []RecordTagsItem `json:"tags"` + Tags []RecordTags `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -815,7 +815,7 @@ type DSRecord struct { // Whether the record can be proxied by Cloudflare or not. Proxiable bool `json:"proxiable"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []RecordTagsItem `json:"tags"` + Tags []RecordTags `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -930,7 +930,7 @@ type HTTPSRecord struct { // Whether the record can be proxied by Cloudflare or not. Proxiable bool `json:"proxiable"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []RecordTagsItem `json:"tags"` + Tags []RecordTags `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -1042,7 +1042,7 @@ type LOCRecord struct { // Whether the record can be proxied by Cloudflare or not. Proxiable bool `json:"proxiable"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []RecordTagsItem `json:"tags"` + Tags []RecordTags `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -1214,7 +1214,7 @@ type MXRecord struct { // Whether the record can be proxied by Cloudflare or not. Proxiable bool `json:"proxiable"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []RecordTagsItem `json:"tags"` + Tags []RecordTags `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -1298,7 +1298,7 @@ type NAPTRRecord struct { // Whether the record can be proxied by Cloudflare or not. Proxiable bool `json:"proxiable"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []RecordTagsItem `json:"tags"` + Tags []RecordTags `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -1417,7 +1417,7 @@ type NSRecord struct { // Whether the record can be proxied by Cloudflare or not. Proxiable bool `json:"proxiable"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []RecordTagsItem `json:"tags"` + Tags []RecordTags `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -1498,7 +1498,7 @@ type PTRRecord struct { // Whether the record can be proxied by Cloudflare or not. Proxiable bool `json:"proxiable"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []RecordTagsItem `json:"tags"` + Tags []RecordTags `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -1787,9 +1787,9 @@ func (r RecordType) IsKnown() bool { return false } -type RecordTagsItem = string +type RecordTags = string -type RecordTagsItemParam = string +type RecordTagsParam = string type SMIMEARecord struct { // Components of a SMIMEA record. @@ -1817,7 +1817,7 @@ type SMIMEARecord struct { // Whether the record can be proxied by Cloudflare or not. Proxiable bool `json:"proxiable"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []RecordTagsItem `json:"tags"` + Tags []RecordTags `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -1936,7 +1936,7 @@ type SRVRecord struct { // Whether the record can be proxied by Cloudflare or not. Proxiable bool `json:"proxiable"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []RecordTagsItem `json:"tags"` + Tags []RecordTags `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -2067,7 +2067,7 @@ type SSHFPRecord struct { // Whether the record can be proxied by Cloudflare or not. Proxiable bool `json:"proxiable"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []RecordTagsItem `json:"tags"` + Tags []RecordTags `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -2179,7 +2179,7 @@ type SVCBRecord struct { // Whether the record can be proxied by Cloudflare or not. Proxiable bool `json:"proxiable"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []RecordTagsItem `json:"tags"` + Tags []RecordTags `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -2291,7 +2291,7 @@ type TLSARecord struct { // Whether the record can be proxied by Cloudflare or not. Proxiable bool `json:"proxiable"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []RecordTagsItem `json:"tags"` + Tags []RecordTags `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -2451,7 +2451,7 @@ type TXTRecord struct { // Whether the record can be proxied by Cloudflare or not. Proxiable bool `json:"proxiable"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []RecordTagsItem `json:"tags"` + Tags []RecordTags `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -2592,7 +2592,7 @@ type URIRecord struct { // Whether the record can be proxied by Cloudflare or not. Proxiable bool `json:"proxiable"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags []RecordTagsItem `json:"tags"` + Tags []RecordTags `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -2781,7 +2781,7 @@ type RecordNewParamsARecord struct { // Cloudflare. Proxied param.Field[bool] `json:"proxied"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]RecordTagsItemParam] `json:"tags"` + Tags param.Field[[]RecordTagsParam] `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -2831,7 +2831,7 @@ type RecordNewParamsAAAARecord struct { // Cloudflare. Proxied param.Field[bool] `json:"proxied"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]RecordTagsItemParam] `json:"tags"` + Tags param.Field[[]RecordTagsParam] `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -2878,7 +2878,7 @@ type RecordNewParamsCAARecord struct { // responses. Comment param.Field[string] `json:"comment"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]RecordTagsItemParam] `json:"tags"` + Tags param.Field[[]RecordTagsParam] `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -2939,7 +2939,7 @@ type RecordNewParamsCERTRecord struct { // responses. Comment param.Field[string] `json:"comment"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]RecordTagsItemParam] `json:"tags"` + Tags param.Field[[]RecordTagsParam] `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -3005,7 +3005,7 @@ type RecordNewParamsCNAMERecord struct { // Cloudflare. Proxied param.Field[bool] `json:"proxied"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]RecordTagsItemParam] `json:"tags"` + Tags param.Field[[]RecordTagsParam] `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -3052,7 +3052,7 @@ type RecordNewParamsDNSKEYRecord struct { // responses. Comment param.Field[string] `json:"comment"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]RecordTagsItemParam] `json:"tags"` + Tags param.Field[[]RecordTagsParam] `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -3115,7 +3115,7 @@ type RecordNewParamsDSRecord struct { // responses. Comment param.Field[string] `json:"comment"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]RecordTagsItemParam] `json:"tags"` + Tags param.Field[[]RecordTagsParam] `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -3178,7 +3178,7 @@ type RecordNewParamsHTTPSRecord struct { // responses. Comment param.Field[string] `json:"comment"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]RecordTagsItemParam] `json:"tags"` + Tags param.Field[[]RecordTagsParam] `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -3239,7 +3239,7 @@ type RecordNewParamsLOCRecord struct { // responses. Comment param.Field[string] `json:"comment"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]RecordTagsItemParam] `json:"tags"` + Tags param.Field[[]RecordTagsParam] `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -3353,7 +3353,7 @@ type RecordNewParamsMXRecord struct { // responses. Comment param.Field[string] `json:"comment"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]RecordTagsItemParam] `json:"tags"` + Tags param.Field[[]RecordTagsParam] `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -3400,7 +3400,7 @@ type RecordNewParamsNAPTRRecord struct { // responses. Comment param.Field[string] `json:"comment"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]RecordTagsItemParam] `json:"tags"` + Tags param.Field[[]RecordTagsParam] `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -3467,7 +3467,7 @@ type RecordNewParamsNSRecord struct { // responses. Comment param.Field[string] `json:"comment"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]RecordTagsItemParam] `json:"tags"` + Tags param.Field[[]RecordTagsParam] `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -3514,7 +3514,7 @@ type RecordNewParamsPTRRecord struct { // responses. Comment param.Field[string] `json:"comment"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]RecordTagsItemParam] `json:"tags"` + Tags param.Field[[]RecordTagsParam] `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -3561,7 +3561,7 @@ type RecordNewParamsSMIMEARecord struct { // responses. Comment param.Field[string] `json:"comment"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]RecordTagsItemParam] `json:"tags"` + Tags param.Field[[]RecordTagsParam] `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -3626,7 +3626,7 @@ type RecordNewParamsSRVRecord struct { // responses. Comment param.Field[string] `json:"comment"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]RecordTagsItemParam] `json:"tags"` + Tags param.Field[[]RecordTagsParam] `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -3702,7 +3702,7 @@ type RecordNewParamsSSHFPRecord struct { // responses. Comment param.Field[string] `json:"comment"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]RecordTagsItemParam] `json:"tags"` + Tags param.Field[[]RecordTagsParam] `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -3763,7 +3763,7 @@ type RecordNewParamsSVCBRecord struct { // responses. Comment param.Field[string] `json:"comment"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]RecordTagsItemParam] `json:"tags"` + Tags param.Field[[]RecordTagsParam] `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -3824,7 +3824,7 @@ type RecordNewParamsTLSARecord struct { // responses. Comment param.Field[string] `json:"comment"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]RecordTagsItemParam] `json:"tags"` + Tags param.Field[[]RecordTagsParam] `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -3887,7 +3887,7 @@ type RecordNewParamsTXTRecord struct { // responses. Comment param.Field[string] `json:"comment"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]RecordTagsItemParam] `json:"tags"` + Tags param.Field[[]RecordTagsParam] `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -3937,7 +3937,7 @@ type RecordNewParamsURIRecord struct { // responses. Comment param.Field[string] `json:"comment"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]RecordTagsItemParam] `json:"tags"` + Tags param.Field[[]RecordTagsParam] `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -4059,7 +4059,7 @@ type RecordUpdateParamsARecord struct { // Cloudflare. Proxied param.Field[bool] `json:"proxied"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]RecordTagsItemParam] `json:"tags"` + Tags param.Field[[]RecordTagsParam] `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -4109,7 +4109,7 @@ type RecordUpdateParamsAAAARecord struct { // Cloudflare. Proxied param.Field[bool] `json:"proxied"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]RecordTagsItemParam] `json:"tags"` + Tags param.Field[[]RecordTagsParam] `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -4156,7 +4156,7 @@ type RecordUpdateParamsCAARecord struct { // responses. Comment param.Field[string] `json:"comment"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]RecordTagsItemParam] `json:"tags"` + Tags param.Field[[]RecordTagsParam] `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -4217,7 +4217,7 @@ type RecordUpdateParamsCERTRecord struct { // responses. Comment param.Field[string] `json:"comment"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]RecordTagsItemParam] `json:"tags"` + Tags param.Field[[]RecordTagsParam] `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -4283,7 +4283,7 @@ type RecordUpdateParamsCNAMERecord struct { // Cloudflare. Proxied param.Field[bool] `json:"proxied"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]RecordTagsItemParam] `json:"tags"` + Tags param.Field[[]RecordTagsParam] `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -4330,7 +4330,7 @@ type RecordUpdateParamsDNSKEYRecord struct { // responses. Comment param.Field[string] `json:"comment"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]RecordTagsItemParam] `json:"tags"` + Tags param.Field[[]RecordTagsParam] `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -4393,7 +4393,7 @@ type RecordUpdateParamsDSRecord struct { // responses. Comment param.Field[string] `json:"comment"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]RecordTagsItemParam] `json:"tags"` + Tags param.Field[[]RecordTagsParam] `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -4456,7 +4456,7 @@ type RecordUpdateParamsHTTPSRecord struct { // responses. Comment param.Field[string] `json:"comment"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]RecordTagsItemParam] `json:"tags"` + Tags param.Field[[]RecordTagsParam] `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -4517,7 +4517,7 @@ type RecordUpdateParamsLOCRecord struct { // responses. Comment param.Field[string] `json:"comment"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]RecordTagsItemParam] `json:"tags"` + Tags param.Field[[]RecordTagsParam] `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -4631,7 +4631,7 @@ type RecordUpdateParamsMXRecord struct { // responses. Comment param.Field[string] `json:"comment"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]RecordTagsItemParam] `json:"tags"` + Tags param.Field[[]RecordTagsParam] `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -4678,7 +4678,7 @@ type RecordUpdateParamsNAPTRRecord struct { // responses. Comment param.Field[string] `json:"comment"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]RecordTagsItemParam] `json:"tags"` + Tags param.Field[[]RecordTagsParam] `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -4745,7 +4745,7 @@ type RecordUpdateParamsNSRecord struct { // responses. Comment param.Field[string] `json:"comment"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]RecordTagsItemParam] `json:"tags"` + Tags param.Field[[]RecordTagsParam] `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -4792,7 +4792,7 @@ type RecordUpdateParamsPTRRecord struct { // responses. Comment param.Field[string] `json:"comment"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]RecordTagsItemParam] `json:"tags"` + Tags param.Field[[]RecordTagsParam] `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -4839,7 +4839,7 @@ type RecordUpdateParamsSMIMEARecord struct { // responses. Comment param.Field[string] `json:"comment"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]RecordTagsItemParam] `json:"tags"` + Tags param.Field[[]RecordTagsParam] `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -4904,7 +4904,7 @@ type RecordUpdateParamsSRVRecord struct { // responses. Comment param.Field[string] `json:"comment"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]RecordTagsItemParam] `json:"tags"` + Tags param.Field[[]RecordTagsParam] `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -4980,7 +4980,7 @@ type RecordUpdateParamsSSHFPRecord struct { // responses. Comment param.Field[string] `json:"comment"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]RecordTagsItemParam] `json:"tags"` + Tags param.Field[[]RecordTagsParam] `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -5041,7 +5041,7 @@ type RecordUpdateParamsSVCBRecord struct { // responses. Comment param.Field[string] `json:"comment"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]RecordTagsItemParam] `json:"tags"` + Tags param.Field[[]RecordTagsParam] `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -5102,7 +5102,7 @@ type RecordUpdateParamsTLSARecord struct { // responses. Comment param.Field[string] `json:"comment"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]RecordTagsItemParam] `json:"tags"` + Tags param.Field[[]RecordTagsParam] `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -5165,7 +5165,7 @@ type RecordUpdateParamsTXTRecord struct { // responses. Comment param.Field[string] `json:"comment"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]RecordTagsItemParam] `json:"tags"` + Tags param.Field[[]RecordTagsParam] `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -5215,7 +5215,7 @@ type RecordUpdateParamsURIRecord struct { // responses. Comment param.Field[string] `json:"comment"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]RecordTagsItemParam] `json:"tags"` + Tags param.Field[[]RecordTagsParam] `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -5580,7 +5580,7 @@ type RecordEditParamsARecord struct { // Cloudflare. Proxied param.Field[bool] `json:"proxied"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]RecordTagsItemParam] `json:"tags"` + Tags param.Field[[]RecordTagsParam] `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -5630,7 +5630,7 @@ type RecordEditParamsAAAARecord struct { // Cloudflare. Proxied param.Field[bool] `json:"proxied"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]RecordTagsItemParam] `json:"tags"` + Tags param.Field[[]RecordTagsParam] `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -5677,7 +5677,7 @@ type RecordEditParamsCAARecord struct { // responses. Comment param.Field[string] `json:"comment"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]RecordTagsItemParam] `json:"tags"` + Tags param.Field[[]RecordTagsParam] `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -5738,7 +5738,7 @@ type RecordEditParamsCERTRecord struct { // responses. Comment param.Field[string] `json:"comment"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]RecordTagsItemParam] `json:"tags"` + Tags param.Field[[]RecordTagsParam] `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -5804,7 +5804,7 @@ type RecordEditParamsCNAMERecord struct { // Cloudflare. Proxied param.Field[bool] `json:"proxied"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]RecordTagsItemParam] `json:"tags"` + Tags param.Field[[]RecordTagsParam] `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -5851,7 +5851,7 @@ type RecordEditParamsDNSKEYRecord struct { // responses. Comment param.Field[string] `json:"comment"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]RecordTagsItemParam] `json:"tags"` + Tags param.Field[[]RecordTagsParam] `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -5914,7 +5914,7 @@ type RecordEditParamsDSRecord struct { // responses. Comment param.Field[string] `json:"comment"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]RecordTagsItemParam] `json:"tags"` + Tags param.Field[[]RecordTagsParam] `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -5977,7 +5977,7 @@ type RecordEditParamsHTTPSRecord struct { // responses. Comment param.Field[string] `json:"comment"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]RecordTagsItemParam] `json:"tags"` + Tags param.Field[[]RecordTagsParam] `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -6038,7 +6038,7 @@ type RecordEditParamsLOCRecord struct { // responses. Comment param.Field[string] `json:"comment"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]RecordTagsItemParam] `json:"tags"` + Tags param.Field[[]RecordTagsParam] `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -6152,7 +6152,7 @@ type RecordEditParamsMXRecord struct { // responses. Comment param.Field[string] `json:"comment"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]RecordTagsItemParam] `json:"tags"` + Tags param.Field[[]RecordTagsParam] `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -6199,7 +6199,7 @@ type RecordEditParamsNAPTRRecord struct { // responses. Comment param.Field[string] `json:"comment"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]RecordTagsItemParam] `json:"tags"` + Tags param.Field[[]RecordTagsParam] `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -6266,7 +6266,7 @@ type RecordEditParamsNSRecord struct { // responses. Comment param.Field[string] `json:"comment"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]RecordTagsItemParam] `json:"tags"` + Tags param.Field[[]RecordTagsParam] `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -6313,7 +6313,7 @@ type RecordEditParamsPTRRecord struct { // responses. Comment param.Field[string] `json:"comment"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]RecordTagsItemParam] `json:"tags"` + Tags param.Field[[]RecordTagsParam] `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -6360,7 +6360,7 @@ type RecordEditParamsSMIMEARecord struct { // responses. Comment param.Field[string] `json:"comment"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]RecordTagsItemParam] `json:"tags"` + Tags param.Field[[]RecordTagsParam] `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -6425,7 +6425,7 @@ type RecordEditParamsSRVRecord struct { // responses. Comment param.Field[string] `json:"comment"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]RecordTagsItemParam] `json:"tags"` + Tags param.Field[[]RecordTagsParam] `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -6501,7 +6501,7 @@ type RecordEditParamsSSHFPRecord struct { // responses. Comment param.Field[string] `json:"comment"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]RecordTagsItemParam] `json:"tags"` + Tags param.Field[[]RecordTagsParam] `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -6562,7 +6562,7 @@ type RecordEditParamsSVCBRecord struct { // responses. Comment param.Field[string] `json:"comment"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]RecordTagsItemParam] `json:"tags"` + Tags param.Field[[]RecordTagsParam] `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -6623,7 +6623,7 @@ type RecordEditParamsTLSARecord struct { // responses. Comment param.Field[string] `json:"comment"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]RecordTagsItemParam] `json:"tags"` + Tags param.Field[[]RecordTagsParam] `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -6686,7 +6686,7 @@ type RecordEditParamsTXTRecord struct { // responses. Comment param.Field[string] `json:"comment"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]RecordTagsItemParam] `json:"tags"` + Tags param.Field[[]RecordTagsParam] `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. @@ -6736,7 +6736,7 @@ type RecordEditParamsURIRecord struct { // responses. Comment param.Field[string] `json:"comment"` // Custom tags for the DNS record. This field has no effect on DNS responses. - Tags param.Field[[]RecordTagsItemParam] `json:"tags"` + Tags param.Field[[]RecordTagsParam] `json:"tags"` // Time To Live (TTL) of the DNS record in seconds. Setting to 1 means 'automatic'. // Value must be between 60 and 86400, with the minimum reduced to 30 for // Enterprise zones. diff --git a/dns/record_test.go b/dns/record_test.go index 57e2aeb4242..3707bff7940 100644 --- a/dns/record_test.go +++ b/dns/record_test.go @@ -36,7 +36,7 @@ func TestRecordNewWithOptionalParams(t *testing.T) { Type: cloudflare.F(dns.RecordNewParamsARecordTypeA), Comment: cloudflare.F("Domain verification record"), Proxied: cloudflare.F(false), - Tags: cloudflare.F([]dns.RecordTagsItemParam{"owner:dns-team", "owner:dns-team", "owner:dns-team"}), + Tags: cloudflare.F([]dns.RecordTagsParam{"owner:dns-team", "owner:dns-team", "owner:dns-team"}), TTL: cloudflare.F[dns.TTLUnionParam](shared.UnionFloat(3600.000000)), }) if err != nil { @@ -72,7 +72,7 @@ func TestRecordUpdateWithOptionalParams(t *testing.T) { Type: cloudflare.F(dns.RecordUpdateParamsARecordTypeA), Comment: cloudflare.F("Domain verification record"), Proxied: cloudflare.F(false), - Tags: cloudflare.F([]dns.RecordTagsItemParam{"owner:dns-team", "owner:dns-team", "owner:dns-team"}), + Tags: cloudflare.F([]dns.RecordTagsParam{"owner:dns-team", "owner:dns-team", "owner:dns-team"}), TTL: cloudflare.F[dns.TTLUnionParam](shared.UnionFloat(3600.000000)), }, ) @@ -193,7 +193,7 @@ func TestRecordEditWithOptionalParams(t *testing.T) { Type: cloudflare.F(dns.RecordEditParamsARecordTypeA), Comment: cloudflare.F("Domain verification record"), Proxied: cloudflare.F(false), - Tags: cloudflare.F([]dns.RecordTagsItemParam{"owner:dns-team", "owner:dns-team", "owner:dns-team"}), + Tags: cloudflare.F([]dns.RecordTagsParam{"owner:dns-team", "owner:dns-team", "owner:dns-team"}), TTL: cloudflare.F[dns.TTLUnionParam](shared.UnionFloat(3600.000000)), }, ) diff --git a/firewall/accessrule.go b/firewall/accessrule.go index b9bd828afb6..311aa597509 100644 --- a/firewall/accessrule.go +++ b/firewall/accessrule.go @@ -166,35 +166,24 @@ func (r *AccessRuleService) Get(ctx context.Context, identifier interface{}, que return } -type AccessRuleCIDRConfiguration struct { +type AccessRuleCIDRConfigurationParam struct { // The configuration target. You must set the target to `ip_range` when specifying // an IP address range in the rule. - Target AccessRuleCIDRConfigurationTarget `json:"target"` + Target param.Field[AccessRuleCIDRConfigurationTarget] `json:"target"` // The IP address range to match. You can only use prefix lengths `/16` and `/24` // for IPv4 ranges, and prefix lengths `/32`, `/48`, and `/64` for IPv6 ranges. - Value string `json:"value"` - JSON accessRuleCIDRConfigurationJSON `json:"-"` + Value param.Field[string] `json:"value"` } -// accessRuleCIDRConfigurationJSON contains the JSON metadata for the struct -// [AccessRuleCIDRConfiguration] -type accessRuleCIDRConfigurationJSON struct { - Target apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field +func (r AccessRuleCIDRConfigurationParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -func (r *AccessRuleCIDRConfiguration) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} +func (r AccessRuleCIDRConfigurationParam) implementsFirewallAccessRuleNewParamsConfigurationUnion() {} -func (r accessRuleCIDRConfigurationJSON) RawJSON() string { - return r.raw +func (r AccessRuleCIDRConfigurationParam) implementsFirewallAccessRuleEditParamsConfigurationUnion() { } -func (r AccessRuleCIDRConfiguration) implementsUserFirewallRuleConfiguration() {} - // The configuration target. You must set the target to `ip_range` when specifying // an IP address range in the rule. type AccessRuleCIDRConfigurationTarget string @@ -211,55 +200,22 @@ func (r AccessRuleCIDRConfigurationTarget) IsKnown() bool { return false } -type AccessRuleCIDRConfigurationParam struct { - // The configuration target. You must set the target to `ip_range` when specifying - // an IP address range in the rule. - Target param.Field[AccessRuleCIDRConfigurationTarget] `json:"target"` - // The IP address range to match. You can only use prefix lengths `/16` and `/24` - // for IPv4 ranges, and prefix lengths `/32`, `/48`, and `/64` for IPv6 ranges. - Value param.Field[string] `json:"value"` -} - -func (r AccessRuleCIDRConfigurationParam) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessRuleCIDRConfigurationParam) implementsUserFirewallAccessRuleNewParamsConfigurationUnion() { -} - -func (r AccessRuleCIDRConfigurationParam) implementsFirewallAccessRuleNewParamsConfigurationUnion() {} - -func (r AccessRuleCIDRConfigurationParam) implementsFirewallAccessRuleEditParamsConfigurationUnion() { -} - -type AccessRuleIPConfiguration struct { +type AccessRuleIPConfigurationParam struct { // The configuration target. You must set the target to `ip` when specifying an IP // address in the rule. - Target AccessRuleIPConfigurationTarget `json:"target"` + Target param.Field[AccessRuleIPConfigurationTarget] `json:"target"` // The IP address to match. This address will be compared to the IP address of // incoming requests. - Value string `json:"value"` - JSON accessRuleIPConfigurationJSON `json:"-"` -} - -// accessRuleIPConfigurationJSON contains the JSON metadata for the struct -// [AccessRuleIPConfiguration] -type accessRuleIPConfigurationJSON struct { - Target apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field + Value param.Field[string] `json:"value"` } -func (r *AccessRuleIPConfiguration) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) +func (r AccessRuleIPConfigurationParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -func (r accessRuleIPConfigurationJSON) RawJSON() string { - return r.raw -} +func (r AccessRuleIPConfigurationParam) implementsFirewallAccessRuleNewParamsConfigurationUnion() {} -func (r AccessRuleIPConfiguration) implementsUserFirewallRuleConfiguration() {} +func (r AccessRuleIPConfigurationParam) implementsFirewallAccessRuleEditParamsConfigurationUnion() {} // The configuration target. You must set the target to `ip` when specifying an IP // address in the rule. @@ -277,53 +233,21 @@ func (r AccessRuleIPConfigurationTarget) IsKnown() bool { return false } -type AccessRuleIPConfigurationParam struct { - // The configuration target. You must set the target to `ip` when specifying an IP - // address in the rule. - Target param.Field[AccessRuleIPConfigurationTarget] `json:"target"` - // The IP address to match. This address will be compared to the IP address of - // incoming requests. - Value param.Field[string] `json:"value"` -} - -func (r AccessRuleIPConfigurationParam) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r AccessRuleIPConfigurationParam) implementsUserFirewallAccessRuleNewParamsConfigurationUnion() { -} - -func (r AccessRuleIPConfigurationParam) implementsFirewallAccessRuleNewParamsConfigurationUnion() {} - -func (r AccessRuleIPConfigurationParam) implementsFirewallAccessRuleEditParamsConfigurationUnion() {} - -type ASNConfiguration struct { +type ASNConfigurationParam struct { // The configuration target. You must set the target to `asn` when specifying an // Autonomous System Number (ASN) in the rule. - Target ASNConfigurationTarget `json:"target"` + Target param.Field[ASNConfigurationTarget] `json:"target"` // The AS number to match. - Value string `json:"value"` - JSON asnConfigurationJSON `json:"-"` -} - -// asnConfigurationJSON contains the JSON metadata for the struct -// [ASNConfiguration] -type asnConfigurationJSON struct { - Target apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field + Value param.Field[string] `json:"value"` } -func (r *ASNConfiguration) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) +func (r ASNConfigurationParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -func (r asnConfigurationJSON) RawJSON() string { - return r.raw -} +func (r ASNConfigurationParam) implementsFirewallAccessRuleNewParamsConfigurationUnion() {} -func (r ASNConfiguration) implementsUserFirewallRuleConfiguration() {} +func (r ASNConfigurationParam) implementsFirewallAccessRuleEditParamsConfigurationUnion() {} // The configuration target. You must set the target to `asn` when specifying an // Autonomous System Number (ASN) in the rule. @@ -341,52 +265,22 @@ func (r ASNConfigurationTarget) IsKnown() bool { return false } -type ASNConfigurationParam struct { - // The configuration target. You must set the target to `asn` when specifying an - // Autonomous System Number (ASN) in the rule. - Target param.Field[ASNConfigurationTarget] `json:"target"` - // The AS number to match. - Value param.Field[string] `json:"value"` -} - -func (r ASNConfigurationParam) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r ASNConfigurationParam) implementsUserFirewallAccessRuleNewParamsConfigurationUnion() {} - -func (r ASNConfigurationParam) implementsFirewallAccessRuleNewParamsConfigurationUnion() {} - -func (r ASNConfigurationParam) implementsFirewallAccessRuleEditParamsConfigurationUnion() {} - -type CountryConfiguration struct { +type CountryConfigurationParam struct { // The configuration target. You must set the target to `country` when specifying a // country code in the rule. - Target CountryConfigurationTarget `json:"target"` + Target param.Field[CountryConfigurationTarget] `json:"target"` // The two-letter ISO-3166-1 alpha-2 code to match. For more information, refer to // [IP Access rules: Parameters](https://developers.cloudflare.com/waf/tools/ip-access-rules/parameters/#country). - Value string `json:"value"` - JSON countryConfigurationJSON `json:"-"` -} - -// countryConfigurationJSON contains the JSON metadata for the struct -// [CountryConfiguration] -type countryConfigurationJSON struct { - Target apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field + Value param.Field[string] `json:"value"` } -func (r *CountryConfiguration) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) +func (r CountryConfigurationParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -func (r countryConfigurationJSON) RawJSON() string { - return r.raw -} +func (r CountryConfigurationParam) implementsFirewallAccessRuleNewParamsConfigurationUnion() {} -func (r CountryConfiguration) implementsUserFirewallRuleConfiguration() {} +func (r CountryConfigurationParam) implementsFirewallAccessRuleEditParamsConfigurationUnion() {} // The configuration target. You must set the target to `country` when specifying a // country code in the rule. @@ -404,52 +298,21 @@ func (r CountryConfigurationTarget) IsKnown() bool { return false } -type CountryConfigurationParam struct { - // The configuration target. You must set the target to `country` when specifying a - // country code in the rule. - Target param.Field[CountryConfigurationTarget] `json:"target"` - // The two-letter ISO-3166-1 alpha-2 code to match. For more information, refer to - // [IP Access rules: Parameters](https://developers.cloudflare.com/waf/tools/ip-access-rules/parameters/#country). - Value param.Field[string] `json:"value"` -} - -func (r CountryConfigurationParam) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r CountryConfigurationParam) implementsUserFirewallAccessRuleNewParamsConfigurationUnion() {} - -func (r CountryConfigurationParam) implementsFirewallAccessRuleNewParamsConfigurationUnion() {} - -func (r CountryConfigurationParam) implementsFirewallAccessRuleEditParamsConfigurationUnion() {} - -type IPV6Configuration struct { +type IPV6ConfigurationParam struct { // The configuration target. You must set the target to `ip6` when specifying an // IPv6 address in the rule. - Target IPV6ConfigurationTarget `json:"target"` + Target param.Field[IPV6ConfigurationTarget] `json:"target"` // The IPv6 address to match. - Value string `json:"value"` - JSON ipv6ConfigurationJSON `json:"-"` -} - -// ipv6ConfigurationJSON contains the JSON metadata for the struct -// [IPV6Configuration] -type ipv6ConfigurationJSON struct { - Target apijson.Field - Value apijson.Field - raw string - ExtraFields map[string]apijson.Field + Value param.Field[string] `json:"value"` } -func (r *IPV6Configuration) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) +func (r IPV6ConfigurationParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) } -func (r ipv6ConfigurationJSON) RawJSON() string { - return r.raw -} +func (r IPV6ConfigurationParam) implementsFirewallAccessRuleNewParamsConfigurationUnion() {} -func (r IPV6Configuration) implementsUserFirewallRuleConfiguration() {} +func (r IPV6ConfigurationParam) implementsFirewallAccessRuleEditParamsConfigurationUnion() {} // The configuration target. You must set the target to `ip6` when specifying an // IPv6 address in the rule. @@ -467,24 +330,6 @@ func (r IPV6ConfigurationTarget) IsKnown() bool { return false } -type IPV6ConfigurationParam struct { - // The configuration target. You must set the target to `ip6` when specifying an - // IPv6 address in the rule. - Target param.Field[IPV6ConfigurationTarget] `json:"target"` - // The IPv6 address to match. - Value param.Field[string] `json:"value"` -} - -func (r IPV6ConfigurationParam) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r IPV6ConfigurationParam) implementsUserFirewallAccessRuleNewParamsConfigurationUnion() {} - -func (r IPV6ConfigurationParam) implementsFirewallAccessRuleNewParamsConfigurationUnion() {} - -func (r IPV6ConfigurationParam) implementsFirewallAccessRuleEditParamsConfigurationUnion() {} - type AccessRuleListResponse = interface{} type AccessRuleDeleteResponse struct { diff --git a/firewall/lockdown.go b/firewall/lockdown.go index 8c5016228e2..a38252f3fea 100644 --- a/firewall/lockdown.go +++ b/firewall/lockdown.go @@ -240,7 +240,7 @@ type Lockdown struct { // The URLs to include in the rule definition. You can use wildcards. Each entered // URL will be escaped before use, which means you can only use simple wildcard // patterns. - URLs []URLsItem `json:"urls,required"` + URLs []URLs `json:"urls,required"` JSON lockdownJSON `json:"-"` } @@ -354,7 +354,7 @@ func (r LockdownIPConfigurationTarget) IsKnown() bool { return false } -type URLsItem = string +type URLs = string type LockdownDeleteResponse struct { // The unique identifier of the Zone Lockdown rule. diff --git a/firewall/rule.go b/firewall/rule.go index ad1d5efac98..2fc6dc6405b 100644 --- a/firewall/rule.go +++ b/firewall/rule.go @@ -129,21 +129,21 @@ func (r *RuleService) Get(ctx context.Context, zoneIdentifier string, params Rul } // A list of products to bypass for a request when using the `bypass` action. -type ProductsItem string +type Products string const ( - ProductsItemZoneLockdown ProductsItem = "zoneLockdown" - ProductsItemUABlock ProductsItem = "uaBlock" - ProductsItemBic ProductsItem = "bic" - ProductsItemHot ProductsItem = "hot" - ProductsItemSecurityLevel ProductsItem = "securityLevel" - ProductsItemRateLimit ProductsItem = "rateLimit" - ProductsItemWAF ProductsItem = "waf" + ProductsZoneLockdown Products = "zoneLockdown" + ProductsUABlock Products = "uaBlock" + ProductsBic Products = "bic" + ProductsHot Products = "hot" + ProductsSecurityLevel Products = "securityLevel" + ProductsRateLimit Products = "rateLimit" + ProductsWAF Products = "waf" ) -func (r ProductsItem) IsKnown() bool { +func (r Products) IsKnown() bool { switch r { - case ProductsItemZoneLockdown, ProductsItemUABlock, ProductsItemBic, ProductsItemHot, ProductsItemSecurityLevel, ProductsItemRateLimit, ProductsItemWAF: + case ProductsZoneLockdown, ProductsUABlock, ProductsBic, ProductsHot, ProductsSecurityLevel, ProductsRateLimit, ProductsWAF: return true } return false @@ -163,8 +163,8 @@ type Rule struct { // The priority of the rule. Optional value used to define the processing order. A // lower number indicates a higher priority. If not provided, rules with a defined // priority will be processed before rules without a priority. - Priority float64 `json:"priority"` - Products []ProductsItem `json:"products"` + Priority float64 `json:"priority"` + Products []Products `json:"products"` // A short reference tag. Allows you to select related firewall rules. Ref string `json:"ref"` JSON ruleJSON `json:"-"` diff --git a/firewall/wafoverride.go b/firewall/wafoverride.go index 1a644d68480..1901d76a516 100644 --- a/firewall/wafoverride.go +++ b/firewall/wafoverride.go @@ -274,6 +274,8 @@ func (r Rule) IsKnown() bool { return false } +type RulesParam map[string]Rule + type URLs = string type WAFOverrideDeleteResponse struct { diff --git a/intel/sinkhole.go b/intel/sinkhole.go index 70db1ed70cf..726252fb5cb 100644 --- a/intel/sinkhole.go +++ b/intel/sinkhole.go @@ -33,7 +33,7 @@ func NewSinkholeService(opts ...option.RequestOption) (r *SinkholeService) { } // List sinkholes owned by this account -func (r *SinkholeService) List(ctx context.Context, query SinkholeListParams, opts ...option.RequestOption) (res *pagination.SinglePage[SinkholeItem], err error) { +func (r *SinkholeService) List(ctx context.Context, query SinkholeListParams, opts ...option.RequestOption) (res *pagination.SinglePage[Sinkhole], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -51,11 +51,11 @@ func (r *SinkholeService) List(ctx context.Context, query SinkholeListParams, op } // List sinkholes owned by this account -func (r *SinkholeService) ListAutoPaging(ctx context.Context, query SinkholeListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[SinkholeItem] { +func (r *SinkholeService) ListAutoPaging(ctx context.Context, query SinkholeListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[Sinkhole] { return pagination.NewSinglePageAutoPager(r.List(ctx, query, opts...)) } -type SinkholeItem struct { +type Sinkhole struct { // The unique identifier for the sinkhole ID int64 `json:"id"` // The account tag that owns this sinkhole @@ -69,12 +69,12 @@ type SinkholeItem struct { // The name of the R2 bucket to store results R2Bucket string `json:"r2_bucket"` // The id of the R2 instance - R2ID string `json:"r2_id"` - JSON sinkholeItemJSON `json:"-"` + R2ID string `json:"r2_id"` + JSON sinkholeJSON `json:"-"` } -// sinkholeItemJSON contains the JSON metadata for the struct [SinkholeItem] -type sinkholeItemJSON struct { +// sinkholeJSON contains the JSON metadata for the struct [Sinkhole] +type sinkholeJSON struct { ID apijson.Field AccountTag apijson.Field CreatedOn apijson.Field @@ -86,11 +86,11 @@ type sinkholeItemJSON struct { ExtraFields map[string]apijson.Field } -func (r *SinkholeItem) UnmarshalJSON(data []byte) (err error) { +func (r *Sinkhole) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r sinkholeItemJSON) RawJSON() string { +func (r sinkholeJSON) RawJSON() string { return r.raw } diff --git a/internal/shared/union.go b/internal/shared/union.go index b06671adbc5..2e5150461d3 100644 --- a/internal/shared/union.go +++ b/internal/shared/union.go @@ -6,15 +6,14 @@ type UnionString string func (UnionString) ImplementsSharedUnnamedSchemaRef9444735ca60712dbcf8afd832eb5716aUnion() {} func (UnionString) ImplementsUserAuditLogListResponse() {} -func (UnionString) ImplementsUserLoadBalancingPoolHealthResponseUnion() {} func (UnionString) ImplementsZonesCustomNameserverUpdateResponseUnion() {} func (UnionString) ImplementsZonesCustomNameserverGetResponseUnion() {} func (UnionString) ImplementsLoadBalancersPoolHealthGetResponseUnion() {} func (UnionString) ImplementsLoadBalancersRegionGetResponseUnion() {} func (UnionString) ImplementsCacheCachePurgeParamsCachePurgeFilesFileUnion() {} func (UnionString) ImplementsCustomNameserversCustomNameserverDeleteResponseUnion() {} -func (UnionString) ImplementsDNSFirewallIPsItemUnionParam() {} -func (UnionString) ImplementsDNSFirewallIPsItemUnion() {} +func (UnionString) ImplementsDNSFirewallIPsUnionParam() {} +func (UnionString) ImplementsDNSFirewallIPsUnion() {} func (UnionString) ImplementsDNSUpstreamIPsUnionParam() {} func (UnionString) ImplementsDNSUpstreamIPsUnion() {} func (UnionString) ImplementsDNSSECDNSSECDeleteResponseUnion() {} diff --git a/load_balancers/loadbalancer.go b/load_balancers/loadbalancer.go index 2477b59418f..3f1b5f3f505 100644 --- a/load_balancers/loadbalancer.go +++ b/load_balancers/loadbalancer.go @@ -216,9 +216,9 @@ func (r CheckRegion) IsKnown() bool { return false } -type DefaultPoolsItem = string +type DefaultPools = string -type DefaultPoolsItemParam = string +type DefaultPoolsParam = string // Filter options for a particular resource type (pool or origin). Use null to // reset. @@ -266,7 +266,7 @@ func (r FilterOptionsParam) MarshalJSON() (data []byte, err error) { 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"` + Host []Host `json:"Host"` JSON headerJSON `json:"-"` } @@ -290,16 +290,16 @@ func (r headerJSON) RawJSON() string { 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"` + Host param.Field[[]HostParam] `json:"Host"` } func (r HeaderParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } -type HostItem = string +type Host = string -type HostItemParam = string +type HostParam = string type LoadBalancer struct { ID string `json:"id"` @@ -318,7 +318,7 @@ type LoadBalancer struct { CreatedOn time.Time `json:"created_on" format:"date-time"` // A list of pool IDs ordered by their failover priority. Pools defined here are // used by default, or when region_pools are not configured for a given region. - DefaultPools []DefaultPoolsItem `json:"default_pools"` + DefaultPools []DefaultPools `json:"default_pools"` // Object description. Description string `json:"description"` // Whether to enable (the default) this load balancer. @@ -355,7 +355,7 @@ type LoadBalancer struct { RegionPools interface{} `json:"region_pools"` // BETA Field Not General Access: A list of rules for this load balancer to // execute. - Rules []RulesItem `json:"rules"` + Rules []Rules `json:"rules"` // Specifies the type of session affinity the load balancer should use unless // specified as `"none"` or "" (default). The supported types are: // @@ -1018,7 +1018,7 @@ func (r RandomSteeringParam) MarshalJSON() (data []byte, err error) { // A rule object containing conditions and overrides for this load balancer to // evaluate. -type RulesItem struct { +type Rules struct { // The condition expressions to evaluate. If the condition evaluates to true, the // overrides or fixed_response in this rule will be applied. An empty condition is // always true. For more details on condition expressions, please see @@ -1030,12 +1030,12 @@ type RulesItem struct { // A collection of fields used to directly respond to the eyeball instead of // routing to a pool. If a fixed_response is supplied the rule will be marked as // terminates. - FixedResponse RulesItemFixedResponse `json:"fixed_response"` + FixedResponse RulesFixedResponse `json:"fixed_response"` // Name of this rule. Only used for human readability. Name string `json:"name"` // A collection of overrides to apply to the load balancer when this rule's // condition is true. All fields are optional. - Overrides RulesItemOverrides `json:"overrides"` + Overrides RulesOverrides `json:"overrides"` // The order in which rules should be executed in relation to each other. Lower // values are executed first. Values do not need to be sequential. If no value is // provided for any rule the array order of the rules field will be used to assign @@ -1043,12 +1043,12 @@ type RulesItem struct { Priority int64 `json:"priority"` // If this rule's condition is true, this causes rule evaluation to stop after // processing this rule. - Terminates bool `json:"terminates"` - JSON rulesItemJSON `json:"-"` + Terminates bool `json:"terminates"` + JSON rulesJSON `json:"-"` } -// rulesItemJSON contains the JSON metadata for the struct [RulesItem] -type rulesItemJSON struct { +// rulesJSON contains the JSON metadata for the struct [Rules] +type rulesJSON struct { Condition apijson.Field Disabled apijson.Field FixedResponse apijson.Field @@ -1060,18 +1060,18 @@ type rulesItemJSON struct { ExtraFields map[string]apijson.Field } -func (r *RulesItem) UnmarshalJSON(data []byte) (err error) { +func (r *Rules) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r rulesItemJSON) RawJSON() string { +func (r rulesJSON) RawJSON() string { return r.raw } // A collection of fields used to directly respond to the eyeball instead of // routing to a pool. If a fixed_response is supplied the rule will be marked as // terminates. -type RulesItemFixedResponse struct { +type RulesFixedResponse struct { // The http 'Content-Type' header to include in the response. ContentType string `json:"content_type"` // The http 'Location' header to include in the response. @@ -1079,13 +1079,13 @@ type RulesItemFixedResponse struct { // Text to include as the http body. MessageBody string `json:"message_body"` // The http status code to respond with. - StatusCode int64 `json:"status_code"` - JSON rulesItemFixedResponseJSON `json:"-"` + StatusCode int64 `json:"status_code"` + JSON rulesFixedResponseJSON `json:"-"` } -// rulesItemFixedResponseJSON contains the JSON metadata for the struct -// [RulesItemFixedResponse] -type rulesItemFixedResponseJSON struct { +// rulesFixedResponseJSON contains the JSON metadata for the struct +// [RulesFixedResponse] +type rulesFixedResponseJSON struct { ContentType apijson.Field Location apijson.Field MessageBody apijson.Field @@ -1094,17 +1094,17 @@ type rulesItemFixedResponseJSON struct { ExtraFields map[string]apijson.Field } -func (r *RulesItemFixedResponse) UnmarshalJSON(data []byte) (err error) { +func (r *RulesFixedResponse) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r rulesItemFixedResponseJSON) RawJSON() string { +func (r rulesFixedResponseJSON) RawJSON() string { return r.raw } // A collection of overrides to apply to the load balancer when this rule's // condition is true. All fields are optional. -type RulesItemOverrides struct { +type RulesOverrides struct { // Controls features that modify the routing of requests to pools and origins in // response to dynamic conditions, such as during the interval between active // health monitoring requests. For example, zero-downtime failover occurs @@ -1119,7 +1119,7 @@ type RulesItemOverrides struct { CountryPools interface{} `json:"country_pools"` // A list of pool IDs ordered by their failover priority. Pools defined here are // used by default, or when region_pools are not configured for a given region. - DefaultPools []DefaultPoolsItem `json:"default_pools"` + DefaultPools []DefaultPools `json:"default_pools"` // The pool ID to use when all other pools are detected as unhealthy. FallbackPool interface{} `json:"fallback_pool"` // Controls location-based steering for non-proxied requests. See `steering_policy` @@ -1166,7 +1166,7 @@ type RulesItemOverrides struct { // server is unhealthy, then a new origin server is calculated and used. See // `headers` in `session_affinity_attributes` for additional required // configuration. - SessionAffinity RulesItemOverridesSessionAffinity `json:"session_affinity"` + SessionAffinity RulesOverridesSessionAffinity `json:"session_affinity"` // Configures attributes for session affinity. SessionAffinityAttributes SessionAffinityAttributes `json:"session_affinity_attributes"` // Time, in seconds, until a client's session expires after being created. Once the @@ -1202,16 +1202,15 @@ type RulesItemOverrides struct { // others. Supported for HTTP/1 and HTTP/2 connections. // - `""`: Will map to `"geo"` if you use // `region_pools`/`country_pools`/`pop_pools` otherwise `"off"`. - SteeringPolicy RulesItemOverridesSteeringPolicy `json:"steering_policy"` + SteeringPolicy RulesOverridesSteeringPolicy `json:"steering_policy"` // Time to live (TTL) of the DNS entry for the IP address returned by this load // balancer. This only applies to gray-clouded (unproxied) load balancers. - TTL float64 `json:"ttl"` - JSON rulesItemOverridesJSON `json:"-"` + TTL float64 `json:"ttl"` + JSON rulesOverridesJSON `json:"-"` } -// rulesItemOverridesJSON contains the JSON metadata for the struct -// [RulesItemOverrides] -type rulesItemOverridesJSON struct { +// rulesOverridesJSON contains the JSON metadata for the struct [RulesOverrides] +type rulesOverridesJSON struct { AdaptiveRouting apijson.Field CountryPools apijson.Field DefaultPools apijson.Field @@ -1229,11 +1228,11 @@ type rulesItemOverridesJSON struct { ExtraFields map[string]apijson.Field } -func (r *RulesItemOverrides) UnmarshalJSON(data []byte) (err error) { +func (r *RulesOverrides) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r rulesItemOverridesJSON) RawJSON() string { +func (r rulesOverridesJSON) RawJSON() string { return r.raw } @@ -1260,19 +1259,19 @@ func (r rulesItemOverridesJSON) RawJSON() string { // server is unhealthy, then a new origin server is calculated and used. See // `headers` in `session_affinity_attributes` for additional required // configuration. -type RulesItemOverridesSessionAffinity string +type RulesOverridesSessionAffinity string const ( - RulesItemOverridesSessionAffinityNone RulesItemOverridesSessionAffinity = "none" - RulesItemOverridesSessionAffinityCookie RulesItemOverridesSessionAffinity = "cookie" - RulesItemOverridesSessionAffinityIPCookie RulesItemOverridesSessionAffinity = "ip_cookie" - RulesItemOverridesSessionAffinityHeader RulesItemOverridesSessionAffinity = "header" - RulesItemOverridesSessionAffinityEmpty RulesItemOverridesSessionAffinity = "\"\"" + RulesOverridesSessionAffinityNone RulesOverridesSessionAffinity = "none" + RulesOverridesSessionAffinityCookie RulesOverridesSessionAffinity = "cookie" + RulesOverridesSessionAffinityIPCookie RulesOverridesSessionAffinity = "ip_cookie" + RulesOverridesSessionAffinityHeader RulesOverridesSessionAffinity = "header" + RulesOverridesSessionAffinityEmpty RulesOverridesSessionAffinity = "\"\"" ) -func (r RulesItemOverridesSessionAffinity) IsKnown() bool { +func (r RulesOverridesSessionAffinity) IsKnown() bool { switch r { - case RulesItemOverridesSessionAffinityNone, RulesItemOverridesSessionAffinityCookie, RulesItemOverridesSessionAffinityIPCookie, RulesItemOverridesSessionAffinityHeader, RulesItemOverridesSessionAffinityEmpty: + case RulesOverridesSessionAffinityNone, RulesOverridesSessionAffinityCookie, RulesOverridesSessionAffinityIPCookie, RulesOverridesSessionAffinityHeader, RulesOverridesSessionAffinityEmpty: return true } return false @@ -1300,22 +1299,22 @@ func (r RulesItemOverridesSessionAffinity) IsKnown() bool { // others. Supported for HTTP/1 and HTTP/2 connections. // - `""`: Will map to `"geo"` if you use // `region_pools`/`country_pools`/`pop_pools` otherwise `"off"`. -type RulesItemOverridesSteeringPolicy string +type RulesOverridesSteeringPolicy string const ( - RulesItemOverridesSteeringPolicyOff RulesItemOverridesSteeringPolicy = "off" - RulesItemOverridesSteeringPolicyGeo RulesItemOverridesSteeringPolicy = "geo" - RulesItemOverridesSteeringPolicyRandom RulesItemOverridesSteeringPolicy = "random" - RulesItemOverridesSteeringPolicyDynamicLatency RulesItemOverridesSteeringPolicy = "dynamic_latency" - RulesItemOverridesSteeringPolicyProximity RulesItemOverridesSteeringPolicy = "proximity" - RulesItemOverridesSteeringPolicyLeastOutstandingRequests RulesItemOverridesSteeringPolicy = "least_outstanding_requests" - RulesItemOverridesSteeringPolicyLeastConnections RulesItemOverridesSteeringPolicy = "least_connections" - RulesItemOverridesSteeringPolicyEmpty RulesItemOverridesSteeringPolicy = "\"\"" + RulesOverridesSteeringPolicyOff RulesOverridesSteeringPolicy = "off" + RulesOverridesSteeringPolicyGeo RulesOverridesSteeringPolicy = "geo" + RulesOverridesSteeringPolicyRandom RulesOverridesSteeringPolicy = "random" + RulesOverridesSteeringPolicyDynamicLatency RulesOverridesSteeringPolicy = "dynamic_latency" + RulesOverridesSteeringPolicyProximity RulesOverridesSteeringPolicy = "proximity" + RulesOverridesSteeringPolicyLeastOutstandingRequests RulesOverridesSteeringPolicy = "least_outstanding_requests" + RulesOverridesSteeringPolicyLeastConnections RulesOverridesSteeringPolicy = "least_connections" + RulesOverridesSteeringPolicyEmpty RulesOverridesSteeringPolicy = "\"\"" ) -func (r RulesItemOverridesSteeringPolicy) IsKnown() bool { +func (r RulesOverridesSteeringPolicy) IsKnown() bool { switch r { - case RulesItemOverridesSteeringPolicyOff, RulesItemOverridesSteeringPolicyGeo, RulesItemOverridesSteeringPolicyRandom, RulesItemOverridesSteeringPolicyDynamicLatency, RulesItemOverridesSteeringPolicyProximity, RulesItemOverridesSteeringPolicyLeastOutstandingRequests, RulesItemOverridesSteeringPolicyLeastConnections, RulesItemOverridesSteeringPolicyEmpty: + case RulesOverridesSteeringPolicyOff, RulesOverridesSteeringPolicyGeo, RulesOverridesSteeringPolicyRandom, RulesOverridesSteeringPolicyDynamicLatency, RulesOverridesSteeringPolicyProximity, RulesOverridesSteeringPolicyLeastOutstandingRequests, RulesOverridesSteeringPolicyLeastConnections, RulesOverridesSteeringPolicyEmpty: return true } return false @@ -1323,7 +1322,7 @@ func (r RulesItemOverridesSteeringPolicy) IsKnown() bool { // A rule object containing conditions and overrides for this load balancer to // evaluate. -type RulesItemParam struct { +type RulesParam struct { // The condition expressions to evaluate. If the condition evaluates to true, the // overrides or fixed_response in this rule will be applied. An empty condition is // always true. For more details on condition expressions, please see @@ -1335,12 +1334,12 @@ type RulesItemParam struct { // A collection of fields used to directly respond to the eyeball instead of // routing to a pool. If a fixed_response is supplied the rule will be marked as // terminates. - FixedResponse param.Field[RulesItemFixedResponseParam] `json:"fixed_response"` + FixedResponse param.Field[RulesFixedResponseParam] `json:"fixed_response"` // Name of this rule. Only used for human readability. Name param.Field[string] `json:"name"` // A collection of overrides to apply to the load balancer when this rule's // condition is true. All fields are optional. - Overrides param.Field[RulesItemOverridesParam] `json:"overrides"` + Overrides param.Field[RulesOverridesParam] `json:"overrides"` // The order in which rules should be executed in relation to each other. Lower // values are executed first. Values do not need to be sequential. If no value is // provided for any rule the array order of the rules field will be used to assign @@ -1351,14 +1350,14 @@ type RulesItemParam struct { Terminates param.Field[bool] `json:"terminates"` } -func (r RulesItemParam) MarshalJSON() (data []byte, err error) { +func (r RulesParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // A collection of fields used to directly respond to the eyeball instead of // routing to a pool. If a fixed_response is supplied the rule will be marked as // terminates. -type RulesItemFixedResponseParam struct { +type RulesFixedResponseParam struct { // The http 'Content-Type' header to include in the response. ContentType param.Field[string] `json:"content_type"` // The http 'Location' header to include in the response. @@ -1369,13 +1368,13 @@ type RulesItemFixedResponseParam struct { StatusCode param.Field[int64] `json:"status_code"` } -func (r RulesItemFixedResponseParam) MarshalJSON() (data []byte, err error) { +func (r RulesFixedResponseParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } // A collection of overrides to apply to the load balancer when this rule's // condition is true. All fields are optional. -type RulesItemOverridesParam struct { +type RulesOverridesParam struct { // Controls features that modify the routing of requests to pools and origins in // response to dynamic conditions, such as during the interval between active // health monitoring requests. For example, zero-downtime failover occurs @@ -1390,7 +1389,7 @@ type RulesItemOverridesParam struct { CountryPools param.Field[interface{}] `json:"country_pools"` // A list of pool IDs ordered by their failover priority. Pools defined here are // used by default, or when region_pools are not configured for a given region. - DefaultPools param.Field[[]DefaultPoolsItemParam] `json:"default_pools"` + DefaultPools param.Field[[]DefaultPoolsParam] `json:"default_pools"` // The pool ID to use when all other pools are detected as unhealthy. FallbackPool param.Field[interface{}] `json:"fallback_pool"` // Controls location-based steering for non-proxied requests. See `steering_policy` @@ -1437,7 +1436,7 @@ type RulesItemOverridesParam struct { // server is unhealthy, then a new origin server is calculated and used. See // `headers` in `session_affinity_attributes` for additional required // configuration. - SessionAffinity param.Field[RulesItemOverridesSessionAffinity] `json:"session_affinity"` + SessionAffinity param.Field[RulesOverridesSessionAffinity] `json:"session_affinity"` // Configures attributes for session affinity. SessionAffinityAttributes param.Field[SessionAffinityAttributesParam] `json:"session_affinity_attributes"` // Time, in seconds, until a client's session expires after being created. Once the @@ -1473,13 +1472,13 @@ type RulesItemOverridesParam struct { // others. Supported for HTTP/1 and HTTP/2 connections. // - `""`: Will map to `"geo"` if you use // `region_pools`/`country_pools`/`pop_pools` otherwise `"off"`. - SteeringPolicy param.Field[RulesItemOverridesSteeringPolicy] `json:"steering_policy"` + SteeringPolicy param.Field[RulesOverridesSteeringPolicy] `json:"steering_policy"` // Time to live (TTL) of the DNS entry for the IP address returned by this load // balancer. This only applies to gray-clouded (unproxied) load balancers. TTL param.Field[float64] `json:"ttl"` } -func (r RulesItemOverridesParam) MarshalJSON() (data []byte, err error) { +func (r RulesOverridesParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } @@ -1697,7 +1696,7 @@ type LoadBalancerNewParams struct { ZoneID param.Field[string] `path:"zone_id,required"` // A list of pool IDs ordered by their failover priority. Pools defined here are // used by default, or when region_pools are not configured for a given region. - DefaultPools param.Field[[]DefaultPoolsItemParam] `json:"default_pools,required"` + DefaultPools param.Field[[]DefaultPoolsParam] `json:"default_pools,required"` // The pool ID to use when all other pools are detected as unhealthy. FallbackPool param.Field[interface{}] `json:"fallback_pool,required"` // The DNS hostname to associate with your Load Balancer. If this hostname already @@ -1743,7 +1742,7 @@ type LoadBalancerNewParams struct { RegionPools param.Field[interface{}] `json:"region_pools"` // BETA Field Not General Access: A list of rules for this load balancer to // execute. - Rules param.Field[[]RulesItemParam] `json:"rules"` + Rules param.Field[[]RulesParam] `json:"rules"` // Specifies the type of session affinity the load balancer should use unless // specified as `"none"` or "" (default). The supported types are: // @@ -1944,7 +1943,7 @@ type LoadBalancerUpdateParams struct { ZoneID param.Field[string] `path:"zone_id,required"` // A list of pool IDs ordered by their failover priority. Pools defined here are // used by default, or when region_pools are not configured for a given region. - DefaultPools param.Field[[]DefaultPoolsItemParam] `json:"default_pools,required"` + DefaultPools param.Field[[]DefaultPoolsParam] `json:"default_pools,required"` // The pool ID to use when all other pools are detected as unhealthy. FallbackPool param.Field[interface{}] `json:"fallback_pool,required"` // The DNS hostname to associate with your Load Balancer. If this hostname already @@ -1992,7 +1991,7 @@ type LoadBalancerUpdateParams struct { RegionPools param.Field[interface{}] `json:"region_pools"` // BETA Field Not General Access: A list of rules for this load balancer to // execute. - Rules param.Field[[]RulesItemParam] `json:"rules"` + Rules param.Field[[]RulesParam] `json:"rules"` // Specifies the type of session affinity the load balancer should use unless // specified as `"none"` or "" (default). The supported types are: // @@ -2261,7 +2260,7 @@ type LoadBalancerEditParams struct { CountryPools param.Field[interface{}] `json:"country_pools"` // A list of pool IDs ordered by their failover priority. Pools defined here are // used by default, or when region_pools are not configured for a given region. - DefaultPools param.Field[[]DefaultPoolsItemParam] `json:"default_pools"` + DefaultPools param.Field[[]DefaultPoolsParam] `json:"default_pools"` // Object description. Description param.Field[string] `json:"description"` // Whether to enable (the default) this load balancer. @@ -2297,7 +2296,7 @@ type LoadBalancerEditParams struct { RegionPools param.Field[interface{}] `json:"region_pools"` // BETA Field Not General Access: A list of rules for this load balancer to // execute. - Rules param.Field[[]RulesItemParam] `json:"rules"` + Rules param.Field[[]RulesParam] `json:"rules"` // Specifies the type of session affinity the load balancer should use unless // specified as `"none"` or "" (default). The supported types are: // diff --git a/load_balancers/loadbalancer_test.go b/load_balancers/loadbalancer_test.go index 18f2e0137ed..b24a96c591d 100644 --- a/load_balancers/loadbalancer_test.go +++ b/load_balancers/loadbalancer_test.go @@ -30,7 +30,7 @@ func TestLoadBalancerNewWithOptionalParams(t *testing.T) { ) _, err := client.LoadBalancers.New(context.TODO(), load_balancers.LoadBalancerNewParams{ ZoneID: cloudflare.F("699d98642c564d2e855e9661899b7252"), - DefaultPools: cloudflare.F([]load_balancers.DefaultPoolsItemParam{"17b5962d775c646f3f9725cbc7a53df4", "9290f38c5d07c2e2f4df57b1f61d4196", "00920f38ce07c2e2f4df50b1f61d4194"}), + DefaultPools: cloudflare.F([]load_balancers.DefaultPoolsParam{"17b5962d775c646f3f9725cbc7a53df4", "9290f38c5d07c2e2f4df57b1f61d4196", "00920f38ce07c2e2f4df50b1f61d4194"}), FallbackPool: cloudflare.F[any](map[string]interface{}{}), Name: cloudflare.F("www.example.com"), AdaptiveRouting: cloudflare.F(load_balancers.AdaptiveRoutingParam{ @@ -80,17 +80,17 @@ func TestLoadBalancerNewWithOptionalParams(t *testing.T) { "1": "9290f38c5d07c2e2f4df57b1f61d4196", }, }), - Rules: cloudflare.F([]load_balancers.RulesItemParam{{ + Rules: cloudflare.F([]load_balancers.RulesParam{{ Condition: cloudflare.F("http.request.uri.path contains \"/testing\""), Disabled: cloudflare.F(true), - FixedResponse: cloudflare.F(load_balancers.RulesItemFixedResponseParam{ + FixedResponse: cloudflare.F(load_balancers.RulesFixedResponseParam{ ContentType: cloudflare.F("application/json"), Location: cloudflare.F("www.example.com"), MessageBody: cloudflare.F("Testing Hello"), StatusCode: cloudflare.F(int64(0)), }), Name: cloudflare.F("route the path /testing to testing datacenter."), - Overrides: cloudflare.F(load_balancers.RulesItemOverridesParam{ + Overrides: cloudflare.F(load_balancers.RulesOverridesParam{ AdaptiveRouting: cloudflare.F(load_balancers.AdaptiveRoutingParam{ FailoverAcrossPools: cloudflare.F(true), }), @@ -103,7 +103,7 @@ func TestLoadBalancerNewWithOptionalParams(t *testing.T) { "1": "00920f38ce07c2e2f4df50b1f61d4194", }, }), - DefaultPools: cloudflare.F([]load_balancers.DefaultPoolsItemParam{"17b5962d775c646f3f9725cbc7a53df4", "9290f38c5d07c2e2f4df57b1f61d4196", "00920f38ce07c2e2f4df50b1f61d4194"}), + DefaultPools: cloudflare.F([]load_balancers.DefaultPoolsParam{"17b5962d775c646f3f9725cbc7a53df4", "9290f38c5d07c2e2f4df57b1f61d4196", "00920f38ce07c2e2f4df50b1f61d4194"}), FallbackPool: cloudflare.F[any](map[string]interface{}{}), LocationStrategy: cloudflare.F(load_balancers.LocationStrategyParam{ Mode: cloudflare.F(load_balancers.LocationStrategyModeResolverIP), @@ -138,7 +138,7 @@ func TestLoadBalancerNewWithOptionalParams(t *testing.T) { "1": "9290f38c5d07c2e2f4df57b1f61d4196", }, }), - SessionAffinity: cloudflare.F(load_balancers.RulesItemOverridesSessionAffinityCookie), + SessionAffinity: cloudflare.F(load_balancers.RulesOverridesSessionAffinityCookie), SessionAffinityAttributes: cloudflare.F(load_balancers.SessionAffinityAttributesParam{ DrainDuration: cloudflare.F(100.000000), Headers: cloudflare.F([]string{"x"}), @@ -148,7 +148,7 @@ func TestLoadBalancerNewWithOptionalParams(t *testing.T) { ZeroDowntimeFailover: cloudflare.F(load_balancers.SessionAffinityAttributesZeroDowntimeFailoverSticky), }), SessionAffinityTTL: cloudflare.F(1800.000000), - SteeringPolicy: cloudflare.F(load_balancers.RulesItemOverridesSteeringPolicyDynamicLatency), + SteeringPolicy: cloudflare.F(load_balancers.RulesOverridesSteeringPolicyDynamicLatency), TTL: cloudflare.F(30.000000), }), Priority: cloudflare.F(int64(0)), @@ -156,14 +156,14 @@ func TestLoadBalancerNewWithOptionalParams(t *testing.T) { }, { Condition: cloudflare.F("http.request.uri.path contains \"/testing\""), Disabled: cloudflare.F(true), - FixedResponse: cloudflare.F(load_balancers.RulesItemFixedResponseParam{ + FixedResponse: cloudflare.F(load_balancers.RulesFixedResponseParam{ ContentType: cloudflare.F("application/json"), Location: cloudflare.F("www.example.com"), MessageBody: cloudflare.F("Testing Hello"), StatusCode: cloudflare.F(int64(0)), }), Name: cloudflare.F("route the path /testing to testing datacenter."), - Overrides: cloudflare.F(load_balancers.RulesItemOverridesParam{ + Overrides: cloudflare.F(load_balancers.RulesOverridesParam{ AdaptiveRouting: cloudflare.F(load_balancers.AdaptiveRoutingParam{ FailoverAcrossPools: cloudflare.F(true), }), @@ -176,7 +176,7 @@ func TestLoadBalancerNewWithOptionalParams(t *testing.T) { "1": "00920f38ce07c2e2f4df50b1f61d4194", }, }), - DefaultPools: cloudflare.F([]load_balancers.DefaultPoolsItemParam{"17b5962d775c646f3f9725cbc7a53df4", "9290f38c5d07c2e2f4df57b1f61d4196", "00920f38ce07c2e2f4df50b1f61d4194"}), + DefaultPools: cloudflare.F([]load_balancers.DefaultPoolsParam{"17b5962d775c646f3f9725cbc7a53df4", "9290f38c5d07c2e2f4df57b1f61d4196", "00920f38ce07c2e2f4df50b1f61d4194"}), FallbackPool: cloudflare.F[any](map[string]interface{}{}), LocationStrategy: cloudflare.F(load_balancers.LocationStrategyParam{ Mode: cloudflare.F(load_balancers.LocationStrategyModeResolverIP), @@ -211,7 +211,7 @@ func TestLoadBalancerNewWithOptionalParams(t *testing.T) { "1": "9290f38c5d07c2e2f4df57b1f61d4196", }, }), - SessionAffinity: cloudflare.F(load_balancers.RulesItemOverridesSessionAffinityCookie), + SessionAffinity: cloudflare.F(load_balancers.RulesOverridesSessionAffinityCookie), SessionAffinityAttributes: cloudflare.F(load_balancers.SessionAffinityAttributesParam{ DrainDuration: cloudflare.F(100.000000), Headers: cloudflare.F([]string{"x"}), @@ -221,7 +221,7 @@ func TestLoadBalancerNewWithOptionalParams(t *testing.T) { ZeroDowntimeFailover: cloudflare.F(load_balancers.SessionAffinityAttributesZeroDowntimeFailoverSticky), }), SessionAffinityTTL: cloudflare.F(1800.000000), - SteeringPolicy: cloudflare.F(load_balancers.RulesItemOverridesSteeringPolicyDynamicLatency), + SteeringPolicy: cloudflare.F(load_balancers.RulesOverridesSteeringPolicyDynamicLatency), TTL: cloudflare.F(30.000000), }), Priority: cloudflare.F(int64(0)), @@ -229,14 +229,14 @@ func TestLoadBalancerNewWithOptionalParams(t *testing.T) { }, { Condition: cloudflare.F("http.request.uri.path contains \"/testing\""), Disabled: cloudflare.F(true), - FixedResponse: cloudflare.F(load_balancers.RulesItemFixedResponseParam{ + FixedResponse: cloudflare.F(load_balancers.RulesFixedResponseParam{ ContentType: cloudflare.F("application/json"), Location: cloudflare.F("www.example.com"), MessageBody: cloudflare.F("Testing Hello"), StatusCode: cloudflare.F(int64(0)), }), Name: cloudflare.F("route the path /testing to testing datacenter."), - Overrides: cloudflare.F(load_balancers.RulesItemOverridesParam{ + Overrides: cloudflare.F(load_balancers.RulesOverridesParam{ AdaptiveRouting: cloudflare.F(load_balancers.AdaptiveRoutingParam{ FailoverAcrossPools: cloudflare.F(true), }), @@ -249,7 +249,7 @@ func TestLoadBalancerNewWithOptionalParams(t *testing.T) { "1": "00920f38ce07c2e2f4df50b1f61d4194", }, }), - DefaultPools: cloudflare.F([]load_balancers.DefaultPoolsItemParam{"17b5962d775c646f3f9725cbc7a53df4", "9290f38c5d07c2e2f4df57b1f61d4196", "00920f38ce07c2e2f4df50b1f61d4194"}), + DefaultPools: cloudflare.F([]load_balancers.DefaultPoolsParam{"17b5962d775c646f3f9725cbc7a53df4", "9290f38c5d07c2e2f4df57b1f61d4196", "00920f38ce07c2e2f4df50b1f61d4194"}), FallbackPool: cloudflare.F[any](map[string]interface{}{}), LocationStrategy: cloudflare.F(load_balancers.LocationStrategyParam{ Mode: cloudflare.F(load_balancers.LocationStrategyModeResolverIP), @@ -284,7 +284,7 @@ func TestLoadBalancerNewWithOptionalParams(t *testing.T) { "1": "9290f38c5d07c2e2f4df57b1f61d4196", }, }), - SessionAffinity: cloudflare.F(load_balancers.RulesItemOverridesSessionAffinityCookie), + SessionAffinity: cloudflare.F(load_balancers.RulesOverridesSessionAffinityCookie), SessionAffinityAttributes: cloudflare.F(load_balancers.SessionAffinityAttributesParam{ DrainDuration: cloudflare.F(100.000000), Headers: cloudflare.F([]string{"x"}), @@ -294,7 +294,7 @@ func TestLoadBalancerNewWithOptionalParams(t *testing.T) { ZeroDowntimeFailover: cloudflare.F(load_balancers.SessionAffinityAttributesZeroDowntimeFailoverSticky), }), SessionAffinityTTL: cloudflare.F(1800.000000), - SteeringPolicy: cloudflare.F(load_balancers.RulesItemOverridesSteeringPolicyDynamicLatency), + SteeringPolicy: cloudflare.F(load_balancers.RulesOverridesSteeringPolicyDynamicLatency), TTL: cloudflare.F(30.000000), }), Priority: cloudflare.F(int64(0)), @@ -341,7 +341,7 @@ func TestLoadBalancerUpdateWithOptionalParams(t *testing.T) { "699d98642c564d2e855e9661899b7252", load_balancers.LoadBalancerUpdateParams{ ZoneID: cloudflare.F("699d98642c564d2e855e9661899b7252"), - DefaultPools: cloudflare.F([]load_balancers.DefaultPoolsItemParam{"17b5962d775c646f3f9725cbc7a53df4", "9290f38c5d07c2e2f4df57b1f61d4196", "00920f38ce07c2e2f4df50b1f61d4194"}), + DefaultPools: cloudflare.F([]load_balancers.DefaultPoolsParam{"17b5962d775c646f3f9725cbc7a53df4", "9290f38c5d07c2e2f4df57b1f61d4196", "00920f38ce07c2e2f4df50b1f61d4194"}), FallbackPool: cloudflare.F[any](map[string]interface{}{}), Name: cloudflare.F("www.example.com"), AdaptiveRouting: cloudflare.F(load_balancers.AdaptiveRoutingParam{ @@ -392,17 +392,17 @@ func TestLoadBalancerUpdateWithOptionalParams(t *testing.T) { "1": "9290f38c5d07c2e2f4df57b1f61d4196", }, }), - Rules: cloudflare.F([]load_balancers.RulesItemParam{{ + Rules: cloudflare.F([]load_balancers.RulesParam{{ Condition: cloudflare.F("http.request.uri.path contains \"/testing\""), Disabled: cloudflare.F(true), - FixedResponse: cloudflare.F(load_balancers.RulesItemFixedResponseParam{ + FixedResponse: cloudflare.F(load_balancers.RulesFixedResponseParam{ ContentType: cloudflare.F("application/json"), Location: cloudflare.F("www.example.com"), MessageBody: cloudflare.F("Testing Hello"), StatusCode: cloudflare.F(int64(0)), }), Name: cloudflare.F("route the path /testing to testing datacenter."), - Overrides: cloudflare.F(load_balancers.RulesItemOverridesParam{ + Overrides: cloudflare.F(load_balancers.RulesOverridesParam{ AdaptiveRouting: cloudflare.F(load_balancers.AdaptiveRoutingParam{ FailoverAcrossPools: cloudflare.F(true), }), @@ -415,7 +415,7 @@ func TestLoadBalancerUpdateWithOptionalParams(t *testing.T) { "1": "00920f38ce07c2e2f4df50b1f61d4194", }, }), - DefaultPools: cloudflare.F([]load_balancers.DefaultPoolsItemParam{"17b5962d775c646f3f9725cbc7a53df4", "9290f38c5d07c2e2f4df57b1f61d4196", "00920f38ce07c2e2f4df50b1f61d4194"}), + DefaultPools: cloudflare.F([]load_balancers.DefaultPoolsParam{"17b5962d775c646f3f9725cbc7a53df4", "9290f38c5d07c2e2f4df57b1f61d4196", "00920f38ce07c2e2f4df50b1f61d4194"}), FallbackPool: cloudflare.F[any](map[string]interface{}{}), LocationStrategy: cloudflare.F(load_balancers.LocationStrategyParam{ Mode: cloudflare.F(load_balancers.LocationStrategyModeResolverIP), @@ -450,7 +450,7 @@ func TestLoadBalancerUpdateWithOptionalParams(t *testing.T) { "1": "9290f38c5d07c2e2f4df57b1f61d4196", }, }), - SessionAffinity: cloudflare.F(load_balancers.RulesItemOverridesSessionAffinityCookie), + SessionAffinity: cloudflare.F(load_balancers.RulesOverridesSessionAffinityCookie), SessionAffinityAttributes: cloudflare.F(load_balancers.SessionAffinityAttributesParam{ DrainDuration: cloudflare.F(100.000000), Headers: cloudflare.F([]string{"x"}), @@ -460,7 +460,7 @@ func TestLoadBalancerUpdateWithOptionalParams(t *testing.T) { ZeroDowntimeFailover: cloudflare.F(load_balancers.SessionAffinityAttributesZeroDowntimeFailoverSticky), }), SessionAffinityTTL: cloudflare.F(1800.000000), - SteeringPolicy: cloudflare.F(load_balancers.RulesItemOverridesSteeringPolicyDynamicLatency), + SteeringPolicy: cloudflare.F(load_balancers.RulesOverridesSteeringPolicyDynamicLatency), TTL: cloudflare.F(30.000000), }), Priority: cloudflare.F(int64(0)), @@ -468,14 +468,14 @@ func TestLoadBalancerUpdateWithOptionalParams(t *testing.T) { }, { Condition: cloudflare.F("http.request.uri.path contains \"/testing\""), Disabled: cloudflare.F(true), - FixedResponse: cloudflare.F(load_balancers.RulesItemFixedResponseParam{ + FixedResponse: cloudflare.F(load_balancers.RulesFixedResponseParam{ ContentType: cloudflare.F("application/json"), Location: cloudflare.F("www.example.com"), MessageBody: cloudflare.F("Testing Hello"), StatusCode: cloudflare.F(int64(0)), }), Name: cloudflare.F("route the path /testing to testing datacenter."), - Overrides: cloudflare.F(load_balancers.RulesItemOverridesParam{ + Overrides: cloudflare.F(load_balancers.RulesOverridesParam{ AdaptiveRouting: cloudflare.F(load_balancers.AdaptiveRoutingParam{ FailoverAcrossPools: cloudflare.F(true), }), @@ -488,7 +488,7 @@ func TestLoadBalancerUpdateWithOptionalParams(t *testing.T) { "1": "00920f38ce07c2e2f4df50b1f61d4194", }, }), - DefaultPools: cloudflare.F([]load_balancers.DefaultPoolsItemParam{"17b5962d775c646f3f9725cbc7a53df4", "9290f38c5d07c2e2f4df57b1f61d4196", "00920f38ce07c2e2f4df50b1f61d4194"}), + DefaultPools: cloudflare.F([]load_balancers.DefaultPoolsParam{"17b5962d775c646f3f9725cbc7a53df4", "9290f38c5d07c2e2f4df57b1f61d4196", "00920f38ce07c2e2f4df50b1f61d4194"}), FallbackPool: cloudflare.F[any](map[string]interface{}{}), LocationStrategy: cloudflare.F(load_balancers.LocationStrategyParam{ Mode: cloudflare.F(load_balancers.LocationStrategyModeResolverIP), @@ -523,7 +523,7 @@ func TestLoadBalancerUpdateWithOptionalParams(t *testing.T) { "1": "9290f38c5d07c2e2f4df57b1f61d4196", }, }), - SessionAffinity: cloudflare.F(load_balancers.RulesItemOverridesSessionAffinityCookie), + SessionAffinity: cloudflare.F(load_balancers.RulesOverridesSessionAffinityCookie), SessionAffinityAttributes: cloudflare.F(load_balancers.SessionAffinityAttributesParam{ DrainDuration: cloudflare.F(100.000000), Headers: cloudflare.F([]string{"x"}), @@ -533,7 +533,7 @@ func TestLoadBalancerUpdateWithOptionalParams(t *testing.T) { ZeroDowntimeFailover: cloudflare.F(load_balancers.SessionAffinityAttributesZeroDowntimeFailoverSticky), }), SessionAffinityTTL: cloudflare.F(1800.000000), - SteeringPolicy: cloudflare.F(load_balancers.RulesItemOverridesSteeringPolicyDynamicLatency), + SteeringPolicy: cloudflare.F(load_balancers.RulesOverridesSteeringPolicyDynamicLatency), TTL: cloudflare.F(30.000000), }), Priority: cloudflare.F(int64(0)), @@ -541,14 +541,14 @@ func TestLoadBalancerUpdateWithOptionalParams(t *testing.T) { }, { Condition: cloudflare.F("http.request.uri.path contains \"/testing\""), Disabled: cloudflare.F(true), - FixedResponse: cloudflare.F(load_balancers.RulesItemFixedResponseParam{ + FixedResponse: cloudflare.F(load_balancers.RulesFixedResponseParam{ ContentType: cloudflare.F("application/json"), Location: cloudflare.F("www.example.com"), MessageBody: cloudflare.F("Testing Hello"), StatusCode: cloudflare.F(int64(0)), }), Name: cloudflare.F("route the path /testing to testing datacenter."), - Overrides: cloudflare.F(load_balancers.RulesItemOverridesParam{ + Overrides: cloudflare.F(load_balancers.RulesOverridesParam{ AdaptiveRouting: cloudflare.F(load_balancers.AdaptiveRoutingParam{ FailoverAcrossPools: cloudflare.F(true), }), @@ -561,7 +561,7 @@ func TestLoadBalancerUpdateWithOptionalParams(t *testing.T) { "1": "00920f38ce07c2e2f4df50b1f61d4194", }, }), - DefaultPools: cloudflare.F([]load_balancers.DefaultPoolsItemParam{"17b5962d775c646f3f9725cbc7a53df4", "9290f38c5d07c2e2f4df57b1f61d4196", "00920f38ce07c2e2f4df50b1f61d4194"}), + DefaultPools: cloudflare.F([]load_balancers.DefaultPoolsParam{"17b5962d775c646f3f9725cbc7a53df4", "9290f38c5d07c2e2f4df57b1f61d4196", "00920f38ce07c2e2f4df50b1f61d4194"}), FallbackPool: cloudflare.F[any](map[string]interface{}{}), LocationStrategy: cloudflare.F(load_balancers.LocationStrategyParam{ Mode: cloudflare.F(load_balancers.LocationStrategyModeResolverIP), @@ -596,7 +596,7 @@ func TestLoadBalancerUpdateWithOptionalParams(t *testing.T) { "1": "9290f38c5d07c2e2f4df57b1f61d4196", }, }), - SessionAffinity: cloudflare.F(load_balancers.RulesItemOverridesSessionAffinityCookie), + SessionAffinity: cloudflare.F(load_balancers.RulesOverridesSessionAffinityCookie), SessionAffinityAttributes: cloudflare.F(load_balancers.SessionAffinityAttributesParam{ DrainDuration: cloudflare.F(100.000000), Headers: cloudflare.F([]string{"x"}), @@ -606,7 +606,7 @@ func TestLoadBalancerUpdateWithOptionalParams(t *testing.T) { ZeroDowntimeFailover: cloudflare.F(load_balancers.SessionAffinityAttributesZeroDowntimeFailoverSticky), }), SessionAffinityTTL: cloudflare.F(1800.000000), - SteeringPolicy: cloudflare.F(load_balancers.RulesItemOverridesSteeringPolicyDynamicLatency), + SteeringPolicy: cloudflare.F(load_balancers.RulesOverridesSteeringPolicyDynamicLatency), TTL: cloudflare.F(30.000000), }), Priority: cloudflare.F(int64(0)), @@ -723,7 +723,7 @@ func TestLoadBalancerEditWithOptionalParams(t *testing.T) { "1": "00920f38ce07c2e2f4df50b1f61d4194", }, }), - DefaultPools: cloudflare.F([]load_balancers.DefaultPoolsItemParam{"17b5962d775c646f3f9725cbc7a53df4", "9290f38c5d07c2e2f4df57b1f61d4196", "00920f38ce07c2e2f4df50b1f61d4194"}), + DefaultPools: cloudflare.F([]load_balancers.DefaultPoolsParam{"17b5962d775c646f3f9725cbc7a53df4", "9290f38c5d07c2e2f4df57b1f61d4196", "00920f38ce07c2e2f4df50b1f61d4194"}), Description: cloudflare.F("Load Balancer for www.example.com"), Enabled: cloudflare.F(true), FallbackPool: cloudflare.F[any](map[string]interface{}{}), @@ -762,17 +762,17 @@ func TestLoadBalancerEditWithOptionalParams(t *testing.T) { "1": "9290f38c5d07c2e2f4df57b1f61d4196", }, }), - Rules: cloudflare.F([]load_balancers.RulesItemParam{{ + Rules: cloudflare.F([]load_balancers.RulesParam{{ Condition: cloudflare.F("http.request.uri.path contains \"/testing\""), Disabled: cloudflare.F(true), - FixedResponse: cloudflare.F(load_balancers.RulesItemFixedResponseParam{ + FixedResponse: cloudflare.F(load_balancers.RulesFixedResponseParam{ ContentType: cloudflare.F("application/json"), Location: cloudflare.F("www.example.com"), MessageBody: cloudflare.F("Testing Hello"), StatusCode: cloudflare.F(int64(0)), }), Name: cloudflare.F("route the path /testing to testing datacenter."), - Overrides: cloudflare.F(load_balancers.RulesItemOverridesParam{ + Overrides: cloudflare.F(load_balancers.RulesOverridesParam{ AdaptiveRouting: cloudflare.F(load_balancers.AdaptiveRoutingParam{ FailoverAcrossPools: cloudflare.F(true), }), @@ -785,7 +785,7 @@ func TestLoadBalancerEditWithOptionalParams(t *testing.T) { "1": "00920f38ce07c2e2f4df50b1f61d4194", }, }), - DefaultPools: cloudflare.F([]load_balancers.DefaultPoolsItemParam{"17b5962d775c646f3f9725cbc7a53df4", "9290f38c5d07c2e2f4df57b1f61d4196", "00920f38ce07c2e2f4df50b1f61d4194"}), + DefaultPools: cloudflare.F([]load_balancers.DefaultPoolsParam{"17b5962d775c646f3f9725cbc7a53df4", "9290f38c5d07c2e2f4df57b1f61d4196", "00920f38ce07c2e2f4df50b1f61d4194"}), FallbackPool: cloudflare.F[any](map[string]interface{}{}), LocationStrategy: cloudflare.F(load_balancers.LocationStrategyParam{ Mode: cloudflare.F(load_balancers.LocationStrategyModeResolverIP), @@ -820,7 +820,7 @@ func TestLoadBalancerEditWithOptionalParams(t *testing.T) { "1": "9290f38c5d07c2e2f4df57b1f61d4196", }, }), - SessionAffinity: cloudflare.F(load_balancers.RulesItemOverridesSessionAffinityCookie), + SessionAffinity: cloudflare.F(load_balancers.RulesOverridesSessionAffinityCookie), SessionAffinityAttributes: cloudflare.F(load_balancers.SessionAffinityAttributesParam{ DrainDuration: cloudflare.F(100.000000), Headers: cloudflare.F([]string{"x"}), @@ -830,7 +830,7 @@ func TestLoadBalancerEditWithOptionalParams(t *testing.T) { ZeroDowntimeFailover: cloudflare.F(load_balancers.SessionAffinityAttributesZeroDowntimeFailoverSticky), }), SessionAffinityTTL: cloudflare.F(1800.000000), - SteeringPolicy: cloudflare.F(load_balancers.RulesItemOverridesSteeringPolicyDynamicLatency), + SteeringPolicy: cloudflare.F(load_balancers.RulesOverridesSteeringPolicyDynamicLatency), TTL: cloudflare.F(30.000000), }), Priority: cloudflare.F(int64(0)), @@ -838,14 +838,14 @@ func TestLoadBalancerEditWithOptionalParams(t *testing.T) { }, { Condition: cloudflare.F("http.request.uri.path contains \"/testing\""), Disabled: cloudflare.F(true), - FixedResponse: cloudflare.F(load_balancers.RulesItemFixedResponseParam{ + FixedResponse: cloudflare.F(load_balancers.RulesFixedResponseParam{ ContentType: cloudflare.F("application/json"), Location: cloudflare.F("www.example.com"), MessageBody: cloudflare.F("Testing Hello"), StatusCode: cloudflare.F(int64(0)), }), Name: cloudflare.F("route the path /testing to testing datacenter."), - Overrides: cloudflare.F(load_balancers.RulesItemOverridesParam{ + Overrides: cloudflare.F(load_balancers.RulesOverridesParam{ AdaptiveRouting: cloudflare.F(load_balancers.AdaptiveRoutingParam{ FailoverAcrossPools: cloudflare.F(true), }), @@ -858,7 +858,7 @@ func TestLoadBalancerEditWithOptionalParams(t *testing.T) { "1": "00920f38ce07c2e2f4df50b1f61d4194", }, }), - DefaultPools: cloudflare.F([]load_balancers.DefaultPoolsItemParam{"17b5962d775c646f3f9725cbc7a53df4", "9290f38c5d07c2e2f4df57b1f61d4196", "00920f38ce07c2e2f4df50b1f61d4194"}), + DefaultPools: cloudflare.F([]load_balancers.DefaultPoolsParam{"17b5962d775c646f3f9725cbc7a53df4", "9290f38c5d07c2e2f4df57b1f61d4196", "00920f38ce07c2e2f4df50b1f61d4194"}), FallbackPool: cloudflare.F[any](map[string]interface{}{}), LocationStrategy: cloudflare.F(load_balancers.LocationStrategyParam{ Mode: cloudflare.F(load_balancers.LocationStrategyModeResolverIP), @@ -893,7 +893,7 @@ func TestLoadBalancerEditWithOptionalParams(t *testing.T) { "1": "9290f38c5d07c2e2f4df57b1f61d4196", }, }), - SessionAffinity: cloudflare.F(load_balancers.RulesItemOverridesSessionAffinityCookie), + SessionAffinity: cloudflare.F(load_balancers.RulesOverridesSessionAffinityCookie), SessionAffinityAttributes: cloudflare.F(load_balancers.SessionAffinityAttributesParam{ DrainDuration: cloudflare.F(100.000000), Headers: cloudflare.F([]string{"x"}), @@ -903,7 +903,7 @@ func TestLoadBalancerEditWithOptionalParams(t *testing.T) { ZeroDowntimeFailover: cloudflare.F(load_balancers.SessionAffinityAttributesZeroDowntimeFailoverSticky), }), SessionAffinityTTL: cloudflare.F(1800.000000), - SteeringPolicy: cloudflare.F(load_balancers.RulesItemOverridesSteeringPolicyDynamicLatency), + SteeringPolicy: cloudflare.F(load_balancers.RulesOverridesSteeringPolicyDynamicLatency), TTL: cloudflare.F(30.000000), }), Priority: cloudflare.F(int64(0)), @@ -911,14 +911,14 @@ func TestLoadBalancerEditWithOptionalParams(t *testing.T) { }, { Condition: cloudflare.F("http.request.uri.path contains \"/testing\""), Disabled: cloudflare.F(true), - FixedResponse: cloudflare.F(load_balancers.RulesItemFixedResponseParam{ + FixedResponse: cloudflare.F(load_balancers.RulesFixedResponseParam{ ContentType: cloudflare.F("application/json"), Location: cloudflare.F("www.example.com"), MessageBody: cloudflare.F("Testing Hello"), StatusCode: cloudflare.F(int64(0)), }), Name: cloudflare.F("route the path /testing to testing datacenter."), - Overrides: cloudflare.F(load_balancers.RulesItemOverridesParam{ + Overrides: cloudflare.F(load_balancers.RulesOverridesParam{ AdaptiveRouting: cloudflare.F(load_balancers.AdaptiveRoutingParam{ FailoverAcrossPools: cloudflare.F(true), }), @@ -931,7 +931,7 @@ func TestLoadBalancerEditWithOptionalParams(t *testing.T) { "1": "00920f38ce07c2e2f4df50b1f61d4194", }, }), - DefaultPools: cloudflare.F([]load_balancers.DefaultPoolsItemParam{"17b5962d775c646f3f9725cbc7a53df4", "9290f38c5d07c2e2f4df57b1f61d4196", "00920f38ce07c2e2f4df50b1f61d4194"}), + DefaultPools: cloudflare.F([]load_balancers.DefaultPoolsParam{"17b5962d775c646f3f9725cbc7a53df4", "9290f38c5d07c2e2f4df57b1f61d4196", "00920f38ce07c2e2f4df50b1f61d4194"}), FallbackPool: cloudflare.F[any](map[string]interface{}{}), LocationStrategy: cloudflare.F(load_balancers.LocationStrategyParam{ Mode: cloudflare.F(load_balancers.LocationStrategyModeResolverIP), @@ -966,7 +966,7 @@ func TestLoadBalancerEditWithOptionalParams(t *testing.T) { "1": "9290f38c5d07c2e2f4df57b1f61d4196", }, }), - SessionAffinity: cloudflare.F(load_balancers.RulesItemOverridesSessionAffinityCookie), + SessionAffinity: cloudflare.F(load_balancers.RulesOverridesSessionAffinityCookie), SessionAffinityAttributes: cloudflare.F(load_balancers.SessionAffinityAttributesParam{ DrainDuration: cloudflare.F(100.000000), Headers: cloudflare.F([]string{"x"}), @@ -976,7 +976,7 @@ func TestLoadBalancerEditWithOptionalParams(t *testing.T) { ZeroDowntimeFailover: cloudflare.F(load_balancers.SessionAffinityAttributesZeroDowntimeFailoverSticky), }), SessionAffinityTTL: cloudflare.F(1800.000000), - SteeringPolicy: cloudflare.F(load_balancers.RulesItemOverridesSteeringPolicyDynamicLatency), + SteeringPolicy: cloudflare.F(load_balancers.RulesOverridesSteeringPolicyDynamicLatency), TTL: cloudflare.F(30.000000), }), Priority: cloudflare.F(int64(0)), diff --git a/load_balancers/pool_test.go b/load_balancers/pool_test.go index 7122bfc34d7..c7561521162 100644 --- a/load_balancers/pool_test.go +++ b/load_balancers/pool_test.go @@ -35,7 +35,7 @@ func TestPoolNewWithOptionalParams(t *testing.T) { Address: cloudflare.F("0.0.0.0"), Enabled: cloudflare.F(true), Header: cloudflare.F(load_balancers.HeaderParam{ - Host: cloudflare.F([]load_balancers.HostItemParam{"example.com", "example.com", "example.com"}), + Host: cloudflare.F([]load_balancers.HostParam{"example.com", "example.com", "example.com"}), }), Name: cloudflare.F("app-server-1"), VirtualNetworkID: cloudflare.F("a5624d4e-044a-4ff0-b3e1-e2465353d4b4"), @@ -44,7 +44,7 @@ func TestPoolNewWithOptionalParams(t *testing.T) { Address: cloudflare.F("0.0.0.0"), Enabled: cloudflare.F(true), Header: cloudflare.F(load_balancers.HeaderParam{ - Host: cloudflare.F([]load_balancers.HostItemParam{"example.com", "example.com", "example.com"}), + Host: cloudflare.F([]load_balancers.HostParam{"example.com", "example.com", "example.com"}), }), Name: cloudflare.F("app-server-1"), VirtualNetworkID: cloudflare.F("a5624d4e-044a-4ff0-b3e1-e2465353d4b4"), @@ -53,7 +53,7 @@ func TestPoolNewWithOptionalParams(t *testing.T) { Address: cloudflare.F("0.0.0.0"), Enabled: cloudflare.F(true), Header: cloudflare.F(load_balancers.HeaderParam{ - Host: cloudflare.F([]load_balancers.HostItemParam{"example.com", "example.com", "example.com"}), + Host: cloudflare.F([]load_balancers.HostParam{"example.com", "example.com", "example.com"}), }), Name: cloudflare.F("app-server-1"), VirtualNetworkID: cloudflare.F("a5624d4e-044a-4ff0-b3e1-e2465353d4b4"), @@ -119,7 +119,7 @@ func TestPoolUpdateWithOptionalParams(t *testing.T) { Address: cloudflare.F("0.0.0.0"), Enabled: cloudflare.F(true), Header: cloudflare.F(load_balancers.HeaderParam{ - Host: cloudflare.F([]load_balancers.HostItemParam{"example.com", "example.com", "example.com"}), + Host: cloudflare.F([]load_balancers.HostParam{"example.com", "example.com", "example.com"}), }), Name: cloudflare.F("app-server-1"), VirtualNetworkID: cloudflare.F("a5624d4e-044a-4ff0-b3e1-e2465353d4b4"), @@ -128,7 +128,7 @@ func TestPoolUpdateWithOptionalParams(t *testing.T) { Address: cloudflare.F("0.0.0.0"), Enabled: cloudflare.F(true), Header: cloudflare.F(load_balancers.HeaderParam{ - Host: cloudflare.F([]load_balancers.HostItemParam{"example.com", "example.com", "example.com"}), + Host: cloudflare.F([]load_balancers.HostParam{"example.com", "example.com", "example.com"}), }), Name: cloudflare.F("app-server-1"), VirtualNetworkID: cloudflare.F("a5624d4e-044a-4ff0-b3e1-e2465353d4b4"), @@ -137,7 +137,7 @@ func TestPoolUpdateWithOptionalParams(t *testing.T) { Address: cloudflare.F("0.0.0.0"), Enabled: cloudflare.F(true), Header: cloudflare.F(load_balancers.HeaderParam{ - Host: cloudflare.F([]load_balancers.HostItemParam{"example.com", "example.com", "example.com"}), + Host: cloudflare.F([]load_balancers.HostParam{"example.com", "example.com", "example.com"}), }), Name: cloudflare.F("app-server-1"), VirtualNetworkID: cloudflare.F("a5624d4e-044a-4ff0-b3e1-e2465353d4b4"), @@ -290,7 +290,7 @@ func TestPoolEditWithOptionalParams(t *testing.T) { Address: cloudflare.F("0.0.0.0"), Enabled: cloudflare.F(true), Header: cloudflare.F(load_balancers.HeaderParam{ - Host: cloudflare.F([]load_balancers.HostItemParam{"example.com", "example.com", "example.com"}), + Host: cloudflare.F([]load_balancers.HostParam{"example.com", "example.com", "example.com"}), }), Name: cloudflare.F("app-server-1"), VirtualNetworkID: cloudflare.F("a5624d4e-044a-4ff0-b3e1-e2465353d4b4"), @@ -299,7 +299,7 @@ func TestPoolEditWithOptionalParams(t *testing.T) { Address: cloudflare.F("0.0.0.0"), Enabled: cloudflare.F(true), Header: cloudflare.F(load_balancers.HeaderParam{ - Host: cloudflare.F([]load_balancers.HostItemParam{"example.com", "example.com", "example.com"}), + Host: cloudflare.F([]load_balancers.HostParam{"example.com", "example.com", "example.com"}), }), Name: cloudflare.F("app-server-1"), VirtualNetworkID: cloudflare.F("a5624d4e-044a-4ff0-b3e1-e2465353d4b4"), @@ -308,7 +308,7 @@ func TestPoolEditWithOptionalParams(t *testing.T) { Address: cloudflare.F("0.0.0.0"), Enabled: cloudflare.F(true), Header: cloudflare.F(load_balancers.HeaderParam{ - Host: cloudflare.F([]load_balancers.HostItemParam{"example.com", "example.com", "example.com"}), + Host: cloudflare.F([]load_balancers.HostParam{"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 26db2a7cb7a..9cf2a3f474e 100644 --- a/memberships/membership.go +++ b/memberships/membership.go @@ -16,7 +16,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/cloudflare/cloudflare-go/v2/user" ) // MembershipService contains methods and other services that help with interacting @@ -108,7 +107,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 user.Permission `json:"permissions"` + Permissions MembershipPermissions `json:"permissions"` // List of role names for the user at the account. Roles accounts.MemberRoles `json:"roles"` // Status of this membership. @@ -137,6 +136,50 @@ func (r membershipJSON) RawJSON() string { return r.raw } +// All access permissions for the user at the account. +type MembershipPermissions 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 membershipPermissionsJSON `json:"-"` +} + +// membershipPermissionsJSON contains the JSON metadata for the struct +// [MembershipPermissions] +type membershipPermissionsJSON 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 *MembershipPermissions) UnmarshalJSON(data []byte) (err error) { + return apijson.UnmarshalRoot(data, r) +} + +func (r membershipPermissionsJSON) RawJSON() string { + return r.raw +} + // Status of this membership. type MembershipStatus string diff --git a/request_tracers/trace.go b/request_tracers/trace.go index d2a6e5b69eb..3831a6a336b 100644 --- a/request_tracers/trace.go +++ b/request_tracers/trace.go @@ -46,54 +46,6 @@ func (r *TraceService) New(ctx context.Context, accountIdentifier string, body T type Trace []TraceItem -// List of steps acting on request/response -type TraceItem struct { - // If step type is rule, then action performed by this rule - Action string `json:"action"` - // If step type is rule, then action parameters of this rule as JSON - ActionParameters interface{} `json:"action_parameters"` - // If step type is rule or ruleset, the description of this entity - Description string `json:"description"` - // If step type is rule, then expression used to match for this rule - Expression string `json:"expression"` - // If step type is ruleset, then kind of this ruleset - Kind string `json:"kind"` - // Whether tracing step affected tracing request/response - Matched bool `json:"matched"` - // If step type is ruleset, then name of this ruleset - Name string `json:"name"` - // Tracing step identifying name - StepName string `json:"step_name"` - Trace Trace `json:"trace"` - // Tracing step type - Type string `json:"type"` - JSON traceItemJSON `json:"-"` -} - -// traceItemJSON contains the JSON metadata for the struct [TraceItem] -type traceItemJSON struct { - Action apijson.Field - ActionParameters apijson.Field - Description apijson.Field - Expression apijson.Field - Kind apijson.Field - Matched apijson.Field - Name apijson.Field - StepName apijson.Field - Trace apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *TraceItem) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r traceItemJSON) RawJSON() string { - return r.raw -} - // Trace result with an origin status code type TraceNewResponse struct { // HTTP Status code of zone response diff --git a/spectrum/analyticsevent.go b/spectrum/analyticsevent.go index 46acca4b42e..e4b2be94c2e 100644 --- a/spectrum/analyticsevent.go +++ b/spectrum/analyticsevent.go @@ -28,18 +28,18 @@ func NewAnalyticsEventService(opts ...option.RequestOption) (r *AnalyticsEventSe return } -type DimensionItem string +type Dimension string const ( - DimensionItemEvent DimensionItem = "event" - DimensionItemAppID DimensionItem = "appID" - DimensionItemColoName DimensionItem = "coloName" - DimensionItemIPVersion DimensionItem = "ipVersion" + DimensionEvent Dimension = "event" + DimensionAppID Dimension = "appID" + DimensionColoName Dimension = "coloName" + DimensionIPVersion Dimension = "ipVersion" ) -func (r DimensionItem) IsKnown() bool { +func (r Dimension) IsKnown() bool { switch r { - case DimensionItemEvent, DimensionItemAppID, DimensionItemColoName, DimensionItemIPVersion: + case DimensionEvent, DimensionAppID, DimensionColoName, DimensionIPVersion: return true } return false diff --git a/spectrum/analyticseventbytime.go b/spectrum/analyticseventbytime.go index 3f4fb1f93dc..4edef0db69c 100644 --- a/spectrum/analyticseventbytime.go +++ b/spectrum/analyticseventbytime.go @@ -76,7 +76,7 @@ type AnalyticsEventBytimeGetParams struct { // | appID | Application ID | 40d67c87c6cd4b889a4fd57805225e85 | // | coloName | Colo Name | SFO | // | ipVersion | IP version used by the client | 4, 6. | - Dimensions param.Field[[]DimensionItem] `query:"dimensions"` + Dimensions param.Field[[]Dimension] `query:"dimensions"` // Used to filter rows by one or more dimensions. Filters can be combined using OR // and AND boolean logic. AND takes precedence over OR in all the expressions. The // OR operator is defined using a comma (,) or OR keyword surrounded by whitespace. diff --git a/spectrum/analyticseventbytime_test.go b/spectrum/analyticseventbytime_test.go index 794f91a5354..e6071b1d045 100644 --- a/spectrum/analyticseventbytime_test.go +++ b/spectrum/analyticseventbytime_test.go @@ -33,7 +33,7 @@ func TestAnalyticsEventBytimeGetWithOptionalParams(t *testing.T) { context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", spectrum.AnalyticsEventBytimeGetParams{ - Dimensions: cloudflare.F([]spectrum.DimensionItem{spectrum.DimensionItemEvent, spectrum.DimensionItemAppID}), + Dimensions: cloudflare.F([]spectrum.Dimension{spectrum.DimensionEvent, spectrum.DimensionAppID}), Filters: cloudflare.F("event==disconnect%20AND%20coloName!=SFO"), Metrics: cloudflare.F([]spectrum.AnalyticsEventBytimeGetParamsMetric{spectrum.AnalyticsEventBytimeGetParamsMetricCount, spectrum.AnalyticsEventBytimeGetParamsMetricBytesIngress}), Since: cloudflare.F(time.Now()), diff --git a/spectrum/analyticseventsummary.go b/spectrum/analyticseventsummary.go index 45460afb8c0..ce125d821a5 100644 --- a/spectrum/analyticseventsummary.go +++ b/spectrum/analyticseventsummary.go @@ -76,7 +76,7 @@ type AnalyticsEventSummaryGetParams struct { // | appID | Application ID | 40d67c87c6cd4b889a4fd57805225e85 | // | coloName | Colo Name | SFO | // | ipVersion | IP version used by the client | 4, 6. | - Dimensions param.Field[[]DimensionItem] `query:"dimensions"` + Dimensions param.Field[[]Dimension] `query:"dimensions"` // Used to filter rows by one or more dimensions. Filters can be combined using OR // and AND boolean logic. AND takes precedence over OR in all the expressions. The // OR operator is defined using a comma (,) or OR keyword surrounded by whitespace. diff --git a/spectrum/analyticseventsummary_test.go b/spectrum/analyticseventsummary_test.go index f1b0639cae0..9cdd3838c86 100644 --- a/spectrum/analyticseventsummary_test.go +++ b/spectrum/analyticseventsummary_test.go @@ -33,7 +33,7 @@ func TestAnalyticsEventSummaryGetWithOptionalParams(t *testing.T) { context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", spectrum.AnalyticsEventSummaryGetParams{ - Dimensions: cloudflare.F([]spectrum.DimensionItem{spectrum.DimensionItemEvent, spectrum.DimensionItemAppID}), + Dimensions: cloudflare.F([]spectrum.Dimension{spectrum.DimensionEvent, spectrum.DimensionAppID}), Filters: cloudflare.F("event==disconnect%20AND%20coloName!=SFO"), Metrics: cloudflare.F([]spectrum.AnalyticsEventSummaryGetParamsMetric{spectrum.AnalyticsEventSummaryGetParamsMetricCount, spectrum.AnalyticsEventSummaryGetParamsMetricBytesIngress}), Since: cloudflare.F(time.Now()), diff --git a/ssl/certificatepack.go b/ssl/certificatepack.go index c84cad25362..eeb592c63e6 100644 --- a/ssl/certificatepack.go +++ b/ssl/certificatepack.go @@ -103,9 +103,9 @@ func (r *CertificatePackService) Get(ctx context.Context, certificatePackID stri return } -type HostItem = string +type Host = string -type HostItemParam = string +type HostParam = string type CertificatePackListResponse = interface{} @@ -143,7 +143,7 @@ type CertificatePackEditResponse struct { CloudflareBranding bool `json:"cloudflare_branding"` // Comma separated list of valid host names for the certificate packs. Must contain // the zone apex, may not contain more than 50 hosts, and may not be empty. - Hosts []HostItem `json:"hosts"` + Hosts []Host `json:"hosts"` // Status of certificate pack. Status CertificatePackEditResponseStatus `json:"status"` // Type of certificate pack. diff --git a/ssl/certificatepackorder.go b/ssl/certificatepackorder.go index ffa882cce4d..7a2d6c53930 100644 --- a/ssl/certificatepackorder.go +++ b/ssl/certificatepackorder.go @@ -57,7 +57,7 @@ type CertificatePackOrderNewResponse struct { CloudflareBranding bool `json:"cloudflare_branding"` // Comma separated list of valid host names for the certificate packs. Must contain // the zone apex, may not contain more than 50 hosts, and may not be empty. - Hosts []HostItem `json:"hosts"` + Hosts []Host `json:"hosts"` // Status of certificate pack. Status CertificatePackOrderNewResponseStatus `json:"status"` // Type of certificate pack. @@ -204,7 +204,7 @@ type CertificatePackOrderNewParams struct { CertificateAuthority param.Field[CertificatePackOrderNewParamsCertificateAuthority] `json:"certificate_authority,required"` // Comma separated list of valid host names for the certificate packs. Must contain // the zone apex, may not contain more than 50 hosts, and may not be empty. - Hosts param.Field[[]HostItemParam] `json:"hosts,required"` + Hosts param.Field[[]HostParam] `json:"hosts,required"` // Type of certificate pack. Type param.Field[CertificatePackOrderNewParamsType] `json:"type,required"` // Validation Method selected for the order. diff --git a/ssl/certificatepackorder_test.go b/ssl/certificatepackorder_test.go index 91db1ff7ab6..65ac40c08d3 100644 --- a/ssl/certificatepackorder_test.go +++ b/ssl/certificatepackorder_test.go @@ -31,7 +31,7 @@ func TestCertificatePackOrderNewWithOptionalParams(t *testing.T) { _, err := client.SSL.CertificatePacks.Order.New(context.TODO(), ssl.CertificatePackOrderNewParams{ ZoneID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), CertificateAuthority: cloudflare.F(ssl.CertificatePackOrderNewParamsCertificateAuthorityLetsEncrypt), - Hosts: cloudflare.F([]ssl.HostItemParam{"example.com", "*.example.com", "www.example.com"}), + Hosts: cloudflare.F([]ssl.HostParam{"example.com", "*.example.com", "www.example.com"}), Type: cloudflare.F(ssl.CertificatePackOrderNewParamsTypeAdvanced), ValidationMethod: cloudflare.F(ssl.CertificatePackOrderNewParamsValidationMethodTXT), ValidityDays: cloudflare.F(ssl.CertificatePackOrderNewParamsValidityDays14), diff --git a/stream/clip.go b/stream/clip.go index dbf84155d01..2925f3d4f44 100644 --- a/stream/clip.go +++ b/stream/clip.go @@ -49,7 +49,7 @@ type Clip struct { // Lists the origins allowed to display the video. Enter allowed origin domains in // an array and use `*` for wildcard subdomains. Empty arrays allow the video to be // viewed on any origin. - AllowedOrigins []AllowedOriginsItem `json:"allowedOrigins"` + AllowedOrigins []AllowedOrigins `json:"allowedOrigins"` // The unique video identifier (UID). ClippedFromVideoUid string `json:"clippedFromVideoUID"` // The date and time the clip was created. @@ -193,7 +193,7 @@ type ClipNewParams struct { // Lists the origins allowed to display the video. Enter allowed origin domains in // an array and use `*` for wildcard subdomains. Empty arrays allow the video to be // viewed on any origin. - AllowedOrigins param.Field[[]AllowedOriginsItemParam] `json:"allowedOrigins"` + AllowedOrigins param.Field[[]AllowedOriginsParam] `json:"allowedOrigins"` // A user-defined identifier for the media creator. Creator param.Field[string] `json:"creator"` // The maximum duration in seconds for a video upload. Can be set for a video that diff --git a/stream/clip_test.go b/stream/clip_test.go index 6b13bd0ae2e..aa0c6423fed 100644 --- a/stream/clip_test.go +++ b/stream/clip_test.go @@ -33,7 +33,7 @@ func TestClipNewWithOptionalParams(t *testing.T) { ClippedFromVideoUid: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), EndTimeSeconds: cloudflare.F(int64(0)), StartTimeSeconds: cloudflare.F(int64(0)), - AllowedOrigins: cloudflare.F([]stream.AllowedOriginsItemParam{"example.com"}), + AllowedOrigins: cloudflare.F([]stream.AllowedOriginsParam{"example.com"}), Creator: cloudflare.F("creator-id_abcde12345"), MaxDurationSeconds: cloudflare.F(int64(1)), RequireSignedURLs: cloudflare.F(true), diff --git a/stream/copy.go b/stream/copy.go index cc5d48bb6a7..85a4ec4a3b7 100644 --- a/stream/copy.go +++ b/stream/copy.go @@ -55,7 +55,7 @@ type CopyNewParams struct { // Lists the origins allowed to display the video. Enter allowed origin domains in // an array and use `*` for wildcard subdomains. Empty arrays allow the video to be // viewed on any origin. - AllowedOrigins param.Field[[]AllowedOriginsItemParam] `json:"allowedOrigins"` + AllowedOrigins param.Field[[]AllowedOriginsParam] `json:"allowedOrigins"` // A user-defined identifier for the media creator. Creator param.Field[string] `json:"creator"` // A user modifiable key-value store used to reference other systems of record for diff --git a/stream/copy_test.go b/stream/copy_test.go index d492a7fea79..296127af6d9 100644 --- a/stream/copy_test.go +++ b/stream/copy_test.go @@ -32,7 +32,7 @@ func TestCopyNewWithOptionalParams(t *testing.T) { _, err := client.Stream.Copy.New(context.TODO(), stream.CopyNewParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), URL: cloudflare.F("https://example.com/myvideo.mp4"), - AllowedOrigins: cloudflare.F([]stream.AllowedOriginsItemParam{"example.com"}), + AllowedOrigins: cloudflare.F([]stream.AllowedOriginsParam{"example.com"}), Creator: cloudflare.F("creator-id_abcde12345"), Meta: cloudflare.F[any](map[string]interface{}{ "name": "video12345.mp4", diff --git a/stream/directupload.go b/stream/directupload.go index ca094259375..b2c1b0e6b1f 100644 --- a/stream/directupload.go +++ b/stream/directupload.go @@ -90,7 +90,7 @@ type DirectUploadNewParams struct { // Lists the origins allowed to display the video. Enter allowed origin domains in // an array and use `*` for wildcard subdomains. Empty arrays allow the video to be // viewed on any origin. - AllowedOrigins param.Field[[]AllowedOriginsItemParam] `json:"allowedOrigins"` + AllowedOrigins param.Field[[]AllowedOriginsParam] `json:"allowedOrigins"` // A user-defined identifier for the media creator. Creator param.Field[string] `json:"creator"` // The date and time after upload when videos will not be accepted. diff --git a/stream/directupload_test.go b/stream/directupload_test.go index a2f7404ef96..d4c3add86cb 100644 --- a/stream/directupload_test.go +++ b/stream/directupload_test.go @@ -32,7 +32,7 @@ func TestDirectUploadNewWithOptionalParams(t *testing.T) { _, err := client.Stream.DirectUpload.New(context.TODO(), stream.DirectUploadNewParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), MaxDurationSeconds: cloudflare.F(int64(1)), - AllowedOrigins: cloudflare.F([]stream.AllowedOriginsItemParam{"example.com"}), + AllowedOrigins: cloudflare.F([]stream.AllowedOriginsParam{"example.com"}), Creator: cloudflare.F("creator-id_abcde12345"), Expiry: cloudflare.F(time.Now()), Meta: cloudflare.F[any](map[string]interface{}{ diff --git a/stream/stream.go b/stream/stream.go index 9ce34f7bd4b..1a645e12326 100644 --- a/stream/stream.go +++ b/stream/stream.go @@ -120,15 +120,15 @@ func (r *StreamService) Get(ctx context.Context, identifier string, query Stream return } -type AllowedOriginsItem = string +type AllowedOrigins = string -type AllowedOriginsItemParam = string +type AllowedOriginsParam = string type Video struct { // Lists the origins allowed to display the video. Enter allowed origin domains in // an array and use `*` for wildcard subdomains. Empty arrays allow the video to be // viewed on any origin. - AllowedOrigins []AllowedOriginsItem `json:"allowedOrigins"` + AllowedOrigins []AllowedOrigins `json:"allowedOrigins"` // The date and time the media item was created. Created time.Time `json:"created" format:"date-time"` // A user-defined identifier for the media creator. diff --git a/user/firewall.go b/user/firewall.go deleted file mode 100644 index 1b78c409b4b..00000000000 --- a/user/firewall.go +++ /dev/null @@ -1,26 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -package user - -import ( - "github.com/cloudflare/cloudflare-go/v2/option" -) - -// FirewallService contains methods and other services that help with interacting -// with the cloudflare API. Note, unlike clients, this service does not read -// variables from the environment automatically. You should not instantiate this -// service directly, and instead use the [NewFirewallService] method instead. -type FirewallService struct { - Options []option.RequestOption - AccessRules *FirewallAccessRuleService -} - -// NewFirewallService generates a new service that applies the given options to -// each request. These options are applied after the parent client's options (if -// there is one), and before any request-specific options. -func NewFirewallService(opts ...option.RequestOption) (r *FirewallService) { - r = &FirewallService{} - r.Options = opts - r.AccessRules = NewFirewallAccessRuleService(opts...) - return -} diff --git a/user/firewallaccessrule.go b/user/firewallaccessrule.go deleted file mode 100644 index b864d020962..00000000000 --- a/user/firewallaccessrule.go +++ /dev/null @@ -1,714 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -package user - -import ( - "context" - "fmt" - "net/http" - "net/url" - "reflect" - "time" - - "github.com/cloudflare/cloudflare-go/v2/firewall" - "github.com/cloudflare/cloudflare-go/v2/internal/apijson" - "github.com/cloudflare/cloudflare-go/v2/internal/apiquery" - "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/internal/shared" - "github.com/cloudflare/cloudflare-go/v2/option" - "github.com/tidwall/gjson" -) - -// FirewallAccessRuleService contains methods and other services that help with -// interacting with the cloudflare API. Note, unlike clients, this service does not -// read variables from the environment automatically. You should not instantiate -// this service directly, and instead use the [NewFirewallAccessRuleService] method -// instead. -type FirewallAccessRuleService struct { -Options []option.RequestOption -} - -// NewFirewallAccessRuleService generates a new service that applies the given -// options to each request. These options are applied after the parent client's -// options (if there is one), and before any request-specific options. -func NewFirewallAccessRuleService(opts ...option.RequestOption) (r *FirewallAccessRuleService) { - r = &FirewallAccessRuleService{} - r.Options = opts - return -} - -// Creates a new IP Access rule for all zones owned by the current user. -// -// Note: To create an IP Access rule that applies to a specific zone, refer to the -// [IP Access rules for a zone](#ip-access-rules-for-a-zone) endpoints. -func (r *FirewallAccessRuleService) New(ctx context.Context, body FirewallAccessRuleNewParams, opts ...option.RequestOption) (res *FirewallRule, err error) { - opts = append(r.Options[:], opts...) - var env FirewallAccessRuleNewResponseEnvelope - path := "user/firewall/access_rules/rules" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetches IP Access rules of the user. You can filter the results using several -// optional parameters. -func (r *FirewallAccessRuleService) List(ctx context.Context, query FirewallAccessRuleListParams, opts ...option.RequestOption) (res *pagination.V4PagePaginationArray[FirewallRule], err error) { - var raw *http.Response - opts = append(r.Options, opts...) - opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) - path := "user/firewall/access_rules/rules" - cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...) - if err != nil { - return nil, err - } - err = cfg.Execute() - if err != nil { - return nil, err - } - res.SetPageConfig(cfg, raw) - return res, nil -} - -// Fetches IP Access rules of the user. You can filter the results using several -// optional parameters. -func (r *FirewallAccessRuleService) ListAutoPaging(ctx context.Context, query FirewallAccessRuleListParams, opts ...option.RequestOption) (*pagination.V4PagePaginationArrayAutoPager[FirewallRule]) { - return pagination.NewV4PagePaginationArrayAutoPager(r.List(ctx, query, opts...)) -} - -// Deletes an IP Access rule at the user level. -// -// Note: Deleting a user-level rule will affect all zones owned by the user. -func (r *FirewallAccessRuleService) Delete(ctx context.Context, identifier string, body FirewallAccessRuleDeleteParams, opts ...option.RequestOption) (res *FirewallAccessRuleDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env FirewallAccessRuleDeleteResponseEnvelope - path := fmt.Sprintf("user/firewall/access_rules/rules/%s", identifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Updates an IP Access rule defined at the user level. You can only update the -// rule action (`mode` parameter) and notes. -func (r *FirewallAccessRuleService) Edit(ctx context.Context, identifier string, body FirewallAccessRuleEditParams, opts ...option.RequestOption) (res *FirewallRule, err error) { - opts = append(r.Options[:], opts...) - var env FirewallAccessRuleEditResponseEnvelope - path := fmt.Sprintf("user/firewall/access_rules/rules/%s", identifier) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type FirewallRule struct { -// The unique identifier of the IP Access rule. -ID string `json:"id,required"` -// The available actions that a rule can apply to a matched request. -AllowedModes []FirewallRuleAllowedMode `json:"allowed_modes,required"` -// The rule configuration. -Configuration FirewallRuleConfiguration `json:"configuration,required"` -// The action to apply to a matched request. -Mode FirewallRuleMode `json:"mode,required"` -// The timestamp of when the rule was created. -CreatedOn time.Time `json:"created_on" format:"date-time"` -// The timestamp of when the rule was last modified. -ModifiedOn time.Time `json:"modified_on" format:"date-time"` -// An informative summary of the rule, typically used as a reminder or explanation. -Notes string `json:"notes"` -JSON firewallRuleJSON `json:"-"` -} - -// firewallRuleJSON contains the JSON metadata for the struct [FirewallRule] -type firewallRuleJSON struct { -ID apijson.Field -AllowedModes apijson.Field -Configuration apijson.Field -Mode apijson.Field -CreatedOn apijson.Field -ModifiedOn apijson.Field -Notes apijson.Field -raw string -ExtraFields map[string]apijson.Field -} - -func (r *FirewallRule) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallRuleJSON) RawJSON() (string) { - return r.raw -} - -// The action to apply to a matched request. -type FirewallRuleAllowedMode string - -const ( - FirewallRuleAllowedModeBlock FirewallRuleAllowedMode = "block" - FirewallRuleAllowedModeChallenge FirewallRuleAllowedMode = "challenge" - FirewallRuleAllowedModeWhitelist FirewallRuleAllowedMode = "whitelist" - FirewallRuleAllowedModeJsChallenge FirewallRuleAllowedMode = "js_challenge" - FirewallRuleAllowedModeManagedChallenge FirewallRuleAllowedMode = "managed_challenge" -) - -func (r FirewallRuleAllowedMode) IsKnown() (bool) { - switch r { - case FirewallRuleAllowedModeBlock, FirewallRuleAllowedModeChallenge, FirewallRuleAllowedModeWhitelist, FirewallRuleAllowedModeJsChallenge, FirewallRuleAllowedModeManagedChallenge: - return true - } - return false -} - -// The rule configuration. -type FirewallRuleConfiguration struct { -// The configuration target. You must set the target to `ip` when specifying an IP -// address in the rule. -Target firewall.FirewallRuleConfigurationTarget `json:"target"` -// The IP address to match. This address will be compared to the IP address of -// incoming requests. -Value string `json:"value"` -JSON firewallRuleConfigurationJSON `json:"-"` -union FirewallRuleConfigurationUnion -} - -// firewallRuleConfigurationJSON contains the JSON metadata for the struct -// [FirewallRuleConfiguration] -type firewallRuleConfigurationJSON struct { -Target apijson.Field -Value apijson.Field -raw string -ExtraFields map[string]apijson.Field -} - -func (r firewallRuleConfigurationJSON) RawJSON() (string) { - return r.raw -} - -func (r *FirewallRuleConfiguration) UnmarshalJSON(data []byte) (err error) { - err = apijson.UnmarshalRoot(data, &r.union) - if err != nil { - return err - } - return apijson.Port(r.union, &r) -} - -func (r FirewallRuleConfiguration) AsUnion() (FirewallRuleConfigurationUnion) { - return r.union -} - -// The rule configuration. -// -// Union satisfied by [firewall.AccessRuleIPConfiguration], -// [firewall.IPV6Configuration], [firewall.AccessRuleCIDRConfiguration], -// [firewall.ASNConfiguration] or [firewall.CountryConfiguration]. -type FirewallRuleConfigurationUnion interface { - implementsUserFirewallRuleConfiguration() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*FirewallRuleConfigurationUnion)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(firewall.AccessRuleIPConfiguration{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(firewall.IPV6Configuration{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(firewall.AccessRuleCIDRConfiguration{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(firewall.ASNConfiguration{}), - }, - apijson.UnionVariant{ - TypeFilter: gjson.JSON, - Type: reflect.TypeOf(firewall.CountryConfiguration{}), - }, - ) -} - -// The configuration target. You must set the target to `ip` when specifying an IP -// address in the rule. -type firewall.FirewallRuleConfigurationTarget string - -const ( - firewall.FirewallRuleConfigurationTargetIP firewall.FirewallRuleConfigurationTarget = "ip" - firewall.FirewallRuleConfigurationTargetIp6 firewall.FirewallRuleConfigurationTarget = "ip6" - firewall.FirewallRuleConfigurationTargetIPRange firewall.FirewallRuleConfigurationTarget = "ip_range" - firewall.FirewallRuleConfigurationTargetASN firewall.FirewallRuleConfigurationTarget = "asn" - firewall.FirewallRuleConfigurationTargetCountry firewall.FirewallRuleConfigurationTarget = "country" -) - -func (r firewall.FirewallRuleConfigurationTarget) IsKnown() (bool) { - switch r { - case firewall.FirewallRuleConfigurationTargetIP, firewall.FirewallRuleConfigurationTargetIp6, firewall.FirewallRuleConfigurationTargetIPRange, firewall.FirewallRuleConfigurationTargetASN, firewall.FirewallRuleConfigurationTargetCountry: - return true - } - return false -} - -// The action to apply to a matched request. -type FirewallRuleMode string - -const ( - FirewallRuleModeBlock FirewallRuleMode = "block" - FirewallRuleModeChallenge FirewallRuleMode = "challenge" - FirewallRuleModeWhitelist FirewallRuleMode = "whitelist" - FirewallRuleModeJsChallenge FirewallRuleMode = "js_challenge" - FirewallRuleModeManagedChallenge FirewallRuleMode = "managed_challenge" -) - -func (r FirewallRuleMode) IsKnown() (bool) { - switch r { - case FirewallRuleModeBlock, FirewallRuleModeChallenge, FirewallRuleModeWhitelist, FirewallRuleModeJsChallenge, FirewallRuleModeManagedChallenge: - return true - } - return false -} - -type FirewallAccessRuleDeleteResponse struct { -// The unique identifier of the IP Access rule. -ID string `json:"id"` -JSON firewallAccessRuleDeleteResponseJSON `json:"-"` -} - -// firewallAccessRuleDeleteResponseJSON contains the JSON metadata for the struct -// [FirewallAccessRuleDeleteResponse] -type firewallAccessRuleDeleteResponseJSON struct { -ID apijson.Field -raw string -ExtraFields map[string]apijson.Field -} - -func (r *FirewallAccessRuleDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallAccessRuleDeleteResponseJSON) RawJSON() (string) { - return r.raw -} - -type FirewallAccessRuleNewParams struct { -// The rule configuration. -Configuration param.Field[FirewallAccessRuleNewParamsConfigurationUnion] `json:"configuration,required"` -// The action to apply to a matched request. -Mode param.Field[FirewallAccessRuleNewParamsMode] `json:"mode,required"` -// An informative summary of the rule, typically used as a reminder or explanation. -Notes param.Field[string] `json:"notes"` -} - -func (r FirewallAccessRuleNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The rule configuration. -type FirewallAccessRuleNewParamsConfiguration struct { -// The configuration target. You must set the target to `ip` when specifying an IP -// address in the rule. -Target param.Field[FirewallAccessRuleNewParamsConfigurationTarget] `json:"target"` -// The IP address to match. This address will be compared to the IP address of -// incoming requests. -Value param.Field[string] `json:"value"` -} - -func (r FirewallAccessRuleNewParamsConfiguration) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -func (r FirewallAccessRuleNewParamsConfiguration) implementsUserFirewallAccessRuleNewParamsConfigurationUnion() {} - -// The rule configuration. -// -// Satisfied by [firewall.AccessRuleIPConfigurationParam], -// [firewall.IPV6ConfigurationParam], [firewall.AccessRuleCIDRConfigurationParam], -// [firewall.ASNConfigurationParam], [firewall.CountryConfigurationParam], -// [FirewallAccessRuleNewParamsConfiguration]. -type FirewallAccessRuleNewParamsConfigurationUnion interface { - implementsUserFirewallAccessRuleNewParamsConfigurationUnion() -} - -// The configuration target. You must set the target to `ip` when specifying an IP -// address in the rule. -type FirewallAccessRuleNewParamsConfigurationTarget string - -const ( - FirewallAccessRuleNewParamsConfigurationTargetIP FirewallAccessRuleNewParamsConfigurationTarget = "ip" - FirewallAccessRuleNewParamsConfigurationTargetIp6 FirewallAccessRuleNewParamsConfigurationTarget = "ip6" - FirewallAccessRuleNewParamsConfigurationTargetIPRange FirewallAccessRuleNewParamsConfigurationTarget = "ip_range" - FirewallAccessRuleNewParamsConfigurationTargetASN FirewallAccessRuleNewParamsConfigurationTarget = "asn" - FirewallAccessRuleNewParamsConfigurationTargetCountry FirewallAccessRuleNewParamsConfigurationTarget = "country" -) - -func (r FirewallAccessRuleNewParamsConfigurationTarget) IsKnown() (bool) { - switch r { - case FirewallAccessRuleNewParamsConfigurationTargetIP, FirewallAccessRuleNewParamsConfigurationTargetIp6, FirewallAccessRuleNewParamsConfigurationTargetIPRange, FirewallAccessRuleNewParamsConfigurationTargetASN, FirewallAccessRuleNewParamsConfigurationTargetCountry: - return true - } - return false -} - -// The action to apply to a matched request. -type FirewallAccessRuleNewParamsMode string - -const ( - FirewallAccessRuleNewParamsModeBlock FirewallAccessRuleNewParamsMode = "block" - FirewallAccessRuleNewParamsModeChallenge FirewallAccessRuleNewParamsMode = "challenge" - FirewallAccessRuleNewParamsModeWhitelist FirewallAccessRuleNewParamsMode = "whitelist" - FirewallAccessRuleNewParamsModeJsChallenge FirewallAccessRuleNewParamsMode = "js_challenge" - FirewallAccessRuleNewParamsModeManagedChallenge FirewallAccessRuleNewParamsMode = "managed_challenge" -) - -func (r FirewallAccessRuleNewParamsMode) IsKnown() (bool) { - switch r { - case FirewallAccessRuleNewParamsModeBlock, FirewallAccessRuleNewParamsModeChallenge, FirewallAccessRuleNewParamsModeWhitelist, FirewallAccessRuleNewParamsModeJsChallenge, FirewallAccessRuleNewParamsModeManagedChallenge: - return true - } - return false -} - -type FirewallAccessRuleNewResponseEnvelope struct { -Errors []shared.ResponseInfo `json:"errors,required"` -Messages []shared.ResponseInfo `json:"messages,required"` -Result FirewallRule `json:"result,required"` -// Whether the API call was successful -Success FirewallAccessRuleNewResponseEnvelopeSuccess `json:"success,required"` -JSON firewallAccessRuleNewResponseEnvelopeJSON `json:"-"` -} - -// firewallAccessRuleNewResponseEnvelopeJSON contains the JSON metadata for the -// struct [FirewallAccessRuleNewResponseEnvelope] -type firewallAccessRuleNewResponseEnvelopeJSON struct { -Errors apijson.Field -Messages apijson.Field -Result apijson.Field -Success apijson.Field -raw string -ExtraFields map[string]apijson.Field -} - -func (r *FirewallAccessRuleNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallAccessRuleNewResponseEnvelopeJSON) RawJSON() (string) { - return r.raw -} - -// Whether the API call was successful -type FirewallAccessRuleNewResponseEnvelopeSuccess bool - -const ( - FirewallAccessRuleNewResponseEnvelopeSuccessTrue FirewallAccessRuleNewResponseEnvelopeSuccess = true -) - -func (r FirewallAccessRuleNewResponseEnvelopeSuccess) IsKnown() (bool) { - switch r { - case FirewallAccessRuleNewResponseEnvelopeSuccessTrue: - return true - } - return false -} - -type FirewallAccessRuleListParams struct { -// The direction used to sort returned rules. -Direction param.Field[FirewallAccessRuleListParamsDirection] `query:"direction"` -EgsPagination param.Field[FirewallAccessRuleListParamsEgsPagination] `query:"egs-pagination"` -Filters param.Field[FirewallAccessRuleListParamsFilters] `query:"filters"` -// The field used to sort returned rules. -Order param.Field[FirewallAccessRuleListParamsOrder] `query:"order"` -// Requested page within paginated list of results. -Page param.Field[float64] `query:"page"` -// Maximum number of results requested. -PerPage param.Field[float64] `query:"per_page"` -} - -// URLQuery serializes [FirewallAccessRuleListParams]'s query parameters as -// `url.Values`. -func (r FirewallAccessRuleListParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatRepeat, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// The direction used to sort returned rules. -type FirewallAccessRuleListParamsDirection string - -const ( - FirewallAccessRuleListParamsDirectionAsc FirewallAccessRuleListParamsDirection = "asc" - FirewallAccessRuleListParamsDirectionDesc FirewallAccessRuleListParamsDirection = "desc" -) - -func (r FirewallAccessRuleListParamsDirection) IsKnown() (bool) { - switch r { - case FirewallAccessRuleListParamsDirectionAsc, FirewallAccessRuleListParamsDirectionDesc: - return true - } - return false -} - -type FirewallAccessRuleListParamsEgsPagination struct { -Json param.Field[FirewallAccessRuleListParamsEgsPaginationJson] `query:"json"` -} - -// URLQuery serializes [FirewallAccessRuleListParamsEgsPagination]'s query -// parameters as `url.Values`. -func (r FirewallAccessRuleListParamsEgsPagination) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatRepeat, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type FirewallAccessRuleListParamsEgsPaginationJson struct { -// The page number of paginated results. -Page param.Field[float64] `query:"page"` -// The maximum number of results per page. You can only set the value to `1` or to -// a multiple of 5 such as `5`, `10`, `15`, or `20`. -PerPage param.Field[float64] `query:"per_page"` -} - -// URLQuery serializes [FirewallAccessRuleListParamsEgsPaginationJson]'s query -// parameters as `url.Values`. -func (r FirewallAccessRuleListParamsEgsPaginationJson) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatRepeat, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type FirewallAccessRuleListParamsFilters struct { -// The target to search in existing rules. -ConfigurationTarget param.Field[FirewallAccessRuleListParamsFiltersConfigurationTarget] `query:"configuration.target"` -// The target value to search for in existing rules: an IP address, an IP address -// range, or a country code, depending on the provided `configuration.target`. -// Notes: You can search for a single IPv4 address, an IP address range with a -// subnet of '/16' or '/24', or a two-letter ISO-3166-1 alpha-2 country code. -ConfigurationValue param.Field[string] `query:"configuration.value"` -// When set to `all`, all the search requirements must match. When set to `any`, -// only one of the search requirements has to match. -Match param.Field[FirewallAccessRuleListParamsFiltersMatch] `query:"match"` -// The action to apply to a matched request. -Mode param.Field[FirewallAccessRuleListParamsFiltersMode] `query:"mode"` -// The string to search for in the notes of existing IP Access rules. Notes: For -// example, the string 'attack' would match IP Access rules with notes 'Attack -// 26/02' and 'Attack 27/02'. The search is case insensitive. -Notes param.Field[string] `query:"notes"` -} - -// URLQuery serializes [FirewallAccessRuleListParamsFilters]'s query parameters as -// `url.Values`. -func (r FirewallAccessRuleListParamsFilters) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatRepeat, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -// The target to search in existing rules. -type FirewallAccessRuleListParamsFiltersConfigurationTarget string - -const ( - FirewallAccessRuleListParamsFiltersConfigurationTargetIP FirewallAccessRuleListParamsFiltersConfigurationTarget = "ip" - FirewallAccessRuleListParamsFiltersConfigurationTargetIPRange FirewallAccessRuleListParamsFiltersConfigurationTarget = "ip_range" - FirewallAccessRuleListParamsFiltersConfigurationTargetASN FirewallAccessRuleListParamsFiltersConfigurationTarget = "asn" - FirewallAccessRuleListParamsFiltersConfigurationTargetCountry FirewallAccessRuleListParamsFiltersConfigurationTarget = "country" -) - -func (r FirewallAccessRuleListParamsFiltersConfigurationTarget) IsKnown() (bool) { - switch r { - case FirewallAccessRuleListParamsFiltersConfigurationTargetIP, FirewallAccessRuleListParamsFiltersConfigurationTargetIPRange, FirewallAccessRuleListParamsFiltersConfigurationTargetASN, FirewallAccessRuleListParamsFiltersConfigurationTargetCountry: - return true - } - return false -} - -// When set to `all`, all the search requirements must match. When set to `any`, -// only one of the search requirements has to match. -type FirewallAccessRuleListParamsFiltersMatch string - -const ( - FirewallAccessRuleListParamsFiltersMatchAny FirewallAccessRuleListParamsFiltersMatch = "any" - FirewallAccessRuleListParamsFiltersMatchAll FirewallAccessRuleListParamsFiltersMatch = "all" -) - -func (r FirewallAccessRuleListParamsFiltersMatch) IsKnown() (bool) { - switch r { - case FirewallAccessRuleListParamsFiltersMatchAny, FirewallAccessRuleListParamsFiltersMatchAll: - return true - } - return false -} - -// The action to apply to a matched request. -type FirewallAccessRuleListParamsFiltersMode string - -const ( - FirewallAccessRuleListParamsFiltersModeBlock FirewallAccessRuleListParamsFiltersMode = "block" - FirewallAccessRuleListParamsFiltersModeChallenge FirewallAccessRuleListParamsFiltersMode = "challenge" - FirewallAccessRuleListParamsFiltersModeWhitelist FirewallAccessRuleListParamsFiltersMode = "whitelist" - FirewallAccessRuleListParamsFiltersModeJsChallenge FirewallAccessRuleListParamsFiltersMode = "js_challenge" - FirewallAccessRuleListParamsFiltersModeManagedChallenge FirewallAccessRuleListParamsFiltersMode = "managed_challenge" -) - -func (r FirewallAccessRuleListParamsFiltersMode) IsKnown() (bool) { - switch r { - case FirewallAccessRuleListParamsFiltersModeBlock, FirewallAccessRuleListParamsFiltersModeChallenge, FirewallAccessRuleListParamsFiltersModeWhitelist, FirewallAccessRuleListParamsFiltersModeJsChallenge, FirewallAccessRuleListParamsFiltersModeManagedChallenge: - return true - } - return false -} - -// The field used to sort returned rules. -type FirewallAccessRuleListParamsOrder string - -const ( - FirewallAccessRuleListParamsOrderConfigurationTarget FirewallAccessRuleListParamsOrder = "configuration.target" - FirewallAccessRuleListParamsOrderConfigurationValue FirewallAccessRuleListParamsOrder = "configuration.value" - FirewallAccessRuleListParamsOrderMode FirewallAccessRuleListParamsOrder = "mode" -) - -func (r FirewallAccessRuleListParamsOrder) IsKnown() (bool) { - switch r { - case FirewallAccessRuleListParamsOrderConfigurationTarget, FirewallAccessRuleListParamsOrderConfigurationValue, FirewallAccessRuleListParamsOrderMode: - return true - } - return false -} - -type FirewallAccessRuleDeleteParams struct { -Body param.Field[interface{}] `json:"body,required"` -} - -func (r FirewallAccessRuleDeleteParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r.Body) -} - -type FirewallAccessRuleDeleteResponseEnvelope struct { -Errors []shared.ResponseInfo `json:"errors,required"` -Messages []shared.ResponseInfo `json:"messages,required"` -Result FirewallAccessRuleDeleteResponse `json:"result,required"` -// Whether the API call was successful -Success FirewallAccessRuleDeleteResponseEnvelopeSuccess `json:"success,required"` -JSON firewallAccessRuleDeleteResponseEnvelopeJSON `json:"-"` -} - -// firewallAccessRuleDeleteResponseEnvelopeJSON contains the JSON metadata for the -// struct [FirewallAccessRuleDeleteResponseEnvelope] -type firewallAccessRuleDeleteResponseEnvelopeJSON struct { -Errors apijson.Field -Messages apijson.Field -Result apijson.Field -Success apijson.Field -raw string -ExtraFields map[string]apijson.Field -} - -func (r *FirewallAccessRuleDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallAccessRuleDeleteResponseEnvelopeJSON) RawJSON() (string) { - return r.raw -} - -// Whether the API call was successful -type FirewallAccessRuleDeleteResponseEnvelopeSuccess bool - -const ( - FirewallAccessRuleDeleteResponseEnvelopeSuccessTrue FirewallAccessRuleDeleteResponseEnvelopeSuccess = true -) - -func (r FirewallAccessRuleDeleteResponseEnvelopeSuccess) IsKnown() (bool) { - switch r { - case FirewallAccessRuleDeleteResponseEnvelopeSuccessTrue: - return true - } - return false -} - -type FirewallAccessRuleEditParams struct { -// The action to apply to a matched request. -Mode param.Field[FirewallAccessRuleEditParamsMode] `json:"mode"` -// An informative summary of the rule, typically used as a reminder or explanation. -Notes param.Field[string] `json:"notes"` -} - -func (r FirewallAccessRuleEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The action to apply to a matched request. -type FirewallAccessRuleEditParamsMode string - -const ( - FirewallAccessRuleEditParamsModeBlock FirewallAccessRuleEditParamsMode = "block" - FirewallAccessRuleEditParamsModeChallenge FirewallAccessRuleEditParamsMode = "challenge" - FirewallAccessRuleEditParamsModeWhitelist FirewallAccessRuleEditParamsMode = "whitelist" - FirewallAccessRuleEditParamsModeJsChallenge FirewallAccessRuleEditParamsMode = "js_challenge" - FirewallAccessRuleEditParamsModeManagedChallenge FirewallAccessRuleEditParamsMode = "managed_challenge" -) - -func (r FirewallAccessRuleEditParamsMode) IsKnown() (bool) { - switch r { - case FirewallAccessRuleEditParamsModeBlock, FirewallAccessRuleEditParamsModeChallenge, FirewallAccessRuleEditParamsModeWhitelist, FirewallAccessRuleEditParamsModeJsChallenge, FirewallAccessRuleEditParamsModeManagedChallenge: - return true - } - return false -} - -type FirewallAccessRuleEditResponseEnvelope struct { -Errors []shared.ResponseInfo `json:"errors,required"` -Messages []shared.ResponseInfo `json:"messages,required"` -Result FirewallRule `json:"result,required"` -// Whether the API call was successful -Success FirewallAccessRuleEditResponseEnvelopeSuccess `json:"success,required"` -JSON firewallAccessRuleEditResponseEnvelopeJSON `json:"-"` -} - -// firewallAccessRuleEditResponseEnvelopeJSON contains the JSON metadata for the -// struct [FirewallAccessRuleEditResponseEnvelope] -type firewallAccessRuleEditResponseEnvelopeJSON struct { -Errors apijson.Field -Messages apijson.Field -Result apijson.Field -Success apijson.Field -raw string -ExtraFields map[string]apijson.Field -} - -func (r *FirewallAccessRuleEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r firewallAccessRuleEditResponseEnvelopeJSON) RawJSON() (string) { - return r.raw -} - -// Whether the API call was successful -type FirewallAccessRuleEditResponseEnvelopeSuccess bool - -const ( - FirewallAccessRuleEditResponseEnvelopeSuccessTrue FirewallAccessRuleEditResponseEnvelopeSuccess = true -) - -func (r FirewallAccessRuleEditResponseEnvelopeSuccess) IsKnown() (bool) { - switch r { - case FirewallAccessRuleEditResponseEnvelopeSuccessTrue: - return true - } - return false -} diff --git a/user/firewallaccessrule_test.go b/user/firewallaccessrule_test.go deleted file mode 100644 index 78b3383c372..00000000000 --- a/user/firewallaccessrule_test.go +++ /dev/null @@ -1,150 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -package user_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go/v2" - "github.com/cloudflare/cloudflare-go/v2/firewall" - "github.com/cloudflare/cloudflare-go/v2/internal/testutil" - "github.com/cloudflare/cloudflare-go/v2/option" - "github.com/cloudflare/cloudflare-go/v2/user" -) - -func TestFirewallAccessRuleNewWithOptionalParams(t *testing.T) { - t.Skip("skipped: tests are disabled for the time being") - baseURL := "http://localhost:4010" - if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { - baseURL = envURL - } - if !testutil.CheckTestServer(t, baseURL) { - return - } - client := cloudflare.NewClient( - option.WithBaseURL(baseURL), - option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), - option.WithAPIEmail("user@example.com"), - ) - _, err := client.User.Firewall.AccessRules.New(context.TODO(), user.FirewallAccessRuleNewParams{ - Configuration: cloudflare.F[user.FirewallAccessRuleNewParamsConfigurationUnion](firewall.AccessRuleIPConfigurationParam{ - Target: cloudflare.F(firewall.AccessRuleIPConfigurationTargetIP), - Value: cloudflare.F("198.51.100.4"), - }), - Mode: cloudflare.F(user.FirewallAccessRuleNewParamsModeChallenge), - Notes: cloudflare.F("This rule is enabled because of an event that occurred on date X."), - }) - if err != nil { - var apierr *cloudflare.Error - if errors.As(err, &apierr) { - t.Log(string(apierr.DumpRequest(true))) - } - t.Fatalf("err should be nil: %s", err.Error()) - } -} - -func TestFirewallAccessRuleListWithOptionalParams(t *testing.T) { - t.Skip("skipped: tests are disabled for the time being") - baseURL := "http://localhost:4010" - if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { - baseURL = envURL - } - if !testutil.CheckTestServer(t, baseURL) { - return - } - client := cloudflare.NewClient( - option.WithBaseURL(baseURL), - option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), - option.WithAPIEmail("user@example.com"), - ) - _, err := client.User.Firewall.AccessRules.List(context.TODO(), user.FirewallAccessRuleListParams{ - Direction: cloudflare.F(user.FirewallAccessRuleListParamsDirectionDesc), - EgsPagination: cloudflare.F(user.FirewallAccessRuleListParamsEgsPagination{ - Json: cloudflare.F(user.FirewallAccessRuleListParamsEgsPaginationJson{ - Page: cloudflare.F(1.000000), - PerPage: cloudflare.F(1.000000), - }), - }), - Filters: cloudflare.F(user.FirewallAccessRuleListParamsFilters{ - ConfigurationTarget: cloudflare.F(user.FirewallAccessRuleListParamsFiltersConfigurationTargetIP), - ConfigurationValue: cloudflare.F("198.51.100.4"), - Match: cloudflare.F(user.FirewallAccessRuleListParamsFiltersMatchAny), - Mode: cloudflare.F(user.FirewallAccessRuleListParamsFiltersModeChallenge), - Notes: cloudflare.F("my note"), - }), - Order: cloudflare.F(user.FirewallAccessRuleListParamsOrderMode), - Page: cloudflare.F(1.000000), - PerPage: cloudflare.F(20.000000), - }) - if err != nil { - var apierr *cloudflare.Error - if errors.As(err, &apierr) { - t.Log(string(apierr.DumpRequest(true))) - } - t.Fatalf("err should be nil: %s", err.Error()) - } -} - -func TestFirewallAccessRuleDelete(t *testing.T) { - t.Skip("skipped: tests are disabled for the time being") - baseURL := "http://localhost:4010" - if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { - baseURL = envURL - } - if !testutil.CheckTestServer(t, baseURL) { - return - } - client := cloudflare.NewClient( - option.WithBaseURL(baseURL), - option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), - option.WithAPIEmail("user@example.com"), - ) - _, err := client.User.Firewall.AccessRules.Delete( - context.TODO(), - "92f17202ed8bd63d69a66b86a49a8f6b", - user.FirewallAccessRuleDeleteParams{ - Body: cloudflare.F[any](map[string]interface{}{}), - }, - ) - if err != nil { - var apierr *cloudflare.Error - if errors.As(err, &apierr) { - t.Log(string(apierr.DumpRequest(true))) - } - t.Fatalf("err should be nil: %s", err.Error()) - } -} - -func TestFirewallAccessRuleEditWithOptionalParams(t *testing.T) { - t.Skip("skipped: tests are disabled for the time being") - baseURL := "http://localhost:4010" - if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { - baseURL = envURL - } - if !testutil.CheckTestServer(t, baseURL) { - return - } - client := cloudflare.NewClient( - option.WithBaseURL(baseURL), - option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), - option.WithAPIEmail("user@example.com"), - ) - _, err := client.User.Firewall.AccessRules.Edit( - context.TODO(), - "92f17202ed8bd63d69a66b86a49a8f6b", - user.FirewallAccessRuleEditParams{ - Mode: cloudflare.F(user.FirewallAccessRuleEditParamsModeChallenge), - Notes: cloudflare.F("This rule is enabled because of an event that occurred on date X."), - }, - ) - if err != nil { - var apierr *cloudflare.Error - if errors.As(err, &apierr) { - t.Log(string(apierr.DumpRequest(true))) - } - t.Fatalf("err should be nil: %s", err.Error()) - } -} diff --git a/user/loadbalancing.go b/user/loadbalancing.go deleted file mode 100644 index f3e7e0edb9a..00000000000 --- a/user/loadbalancing.go +++ /dev/null @@ -1,33 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -package user - -import ( - "github.com/cloudflare/cloudflare-go/v2/option" -) - -// LoadBalancingService contains methods and other services that help with -// interacting with the cloudflare API. Note, unlike clients, this service does not -// read variables from the environment automatically. You should not instantiate -// this service directly, and instead use the [NewLoadBalancingService] method -// instead. -type LoadBalancingService struct { - Options []option.RequestOption - Monitors *LoadBalancingMonitorService - Pools *LoadBalancingPoolService - Preview *LoadBalancingPreviewService - Analytics *LoadBalancingAnalyticsService -} - -// NewLoadBalancingService generates a new service that applies the given options -// to each request. These options are applied after the parent client's options (if -// there is one), and before any request-specific options. -func NewLoadBalancingService(opts ...option.RequestOption) (r *LoadBalancingService) { - r = &LoadBalancingService{} - r.Options = opts - r.Monitors = NewLoadBalancingMonitorService(opts...) - r.Pools = NewLoadBalancingPoolService(opts...) - r.Preview = NewLoadBalancingPreviewService(opts...) - r.Analytics = NewLoadBalancingAnalyticsService(opts...) - return -} diff --git a/user/loadbalancinganalytics.go b/user/loadbalancinganalytics.go deleted file mode 100644 index 0a65e5a2c0b..00000000000 --- a/user/loadbalancinganalytics.go +++ /dev/null @@ -1,56 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -package user - -import ( - "time" - - "github.com/cloudflare/cloudflare-go/v2/internal/apijson" - "github.com/cloudflare/cloudflare-go/v2/option" -) - -// LoadBalancingAnalyticsService contains methods and other services that help with -// interacting with the cloudflare API. Note, unlike clients, this service does not -// read variables from the environment automatically. You should not instantiate -// this service directly, and instead use the [NewLoadBalancingAnalyticsService] -// method instead. -type LoadBalancingAnalyticsService struct { - Options []option.RequestOption - Events *LoadBalancingAnalyticsEventService -} - -// NewLoadBalancingAnalyticsService generates a new service that applies the given -// options to each request. These options are applied after the parent client's -// options (if there is one), and before any request-specific options. -func NewLoadBalancingAnalyticsService(opts ...option.RequestOption) (r *LoadBalancingAnalyticsService) { - r = &LoadBalancingAnalyticsService{} - r.Options = opts - r.Events = NewLoadBalancingAnalyticsEventService(opts...) - return -} - -type Analytics struct { - ID int64 `json:"id"` - Origins []interface{} `json:"origins"` - Pool interface{} `json:"pool"` - Timestamp time.Time `json:"timestamp" format:"date-time"` - JSON analyticsJSON `json:"-"` -} - -// analyticsJSON contains the JSON metadata for the struct [Analytics] -type analyticsJSON struct { - ID apijson.Field - Origins apijson.Field - Pool apijson.Field - Timestamp apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *Analytics) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r analyticsJSON) RawJSON() string { - return r.raw -} diff --git a/user/loadbalancinganalyticsevent.go b/user/loadbalancinganalyticsevent.go deleted file mode 100644 index 71dc51fd1ca..00000000000 --- a/user/loadbalancinganalyticsevent.go +++ /dev/null @@ -1,84 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -package user - -import ( - "context" - "net/http" - "net/url" - "time" - - "github.com/cloudflare/cloudflare-go/v2/internal/apiquery" - "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" -) - -// LoadBalancingAnalyticsEventService contains methods and other services that help -// with interacting with the cloudflare API. Note, unlike clients, this service -// does not read variables from the environment automatically. You should not -// instantiate this service directly, and instead use the -// [NewLoadBalancingAnalyticsEventService] method instead. -type LoadBalancingAnalyticsEventService struct { - Options []option.RequestOption -} - -// NewLoadBalancingAnalyticsEventService generates a new service that applies the -// given options to each request. These options are applied after the parent -// client's options (if there is one), and before any request-specific options. -func NewLoadBalancingAnalyticsEventService(opts ...option.RequestOption) (r *LoadBalancingAnalyticsEventService) { - r = &LoadBalancingAnalyticsEventService{} - r.Options = opts - return -} - -// List origin health changes. -func (r *LoadBalancingAnalyticsEventService) List(ctx context.Context, query LoadBalancingAnalyticsEventListParams, opts ...option.RequestOption) (res *pagination.SinglePage[Analytics], err error) { - var raw *http.Response - opts = append(r.Options, opts...) - opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) - path := "user/load_balancing_analytics/events" - cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...) - if err != nil { - return nil, err - } - err = cfg.Execute() - if err != nil { - return nil, err - } - res.SetPageConfig(cfg, raw) - return res, nil -} - -// List origin health changes. -func (r *LoadBalancingAnalyticsEventService) ListAutoPaging(ctx context.Context, query LoadBalancingAnalyticsEventListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[Analytics] { - return pagination.NewSinglePageAutoPager(r.List(ctx, query, opts...)) -} - -type LoadBalancingAnalyticsEventListParams struct { - // If true, filter events where the origin status is healthy. If false, filter - // events where the origin status is unhealthy. - OriginHealthy param.Field[bool] `query:"origin_healthy"` - // The name for the origin to filter. - OriginName param.Field[string] `query:"origin_name"` - // If true, filter events where the pool status is healthy. If false, filter events - // where the pool status is unhealthy. - PoolHealthy param.Field[bool] `query:"pool_healthy"` - PoolID param.Field[string] `query:"pool_id"` - // The name for the pool to filter. - PoolName param.Field[string] `query:"pool_name"` - // Start date and time of requesting data period in the ISO8601 format. - Since param.Field[time.Time] `query:"since" format:"date-time"` - // End date and time of requesting data period in the ISO8601 format. - Until param.Field[time.Time] `query:"until" format:"date-time"` -} - -// URLQuery serializes [LoadBalancingAnalyticsEventListParams]'s query parameters -// as `url.Values`. -func (r LoadBalancingAnalyticsEventListParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatRepeat, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} diff --git a/user/loadbalancinganalyticsevent_test.go b/user/loadbalancinganalyticsevent_test.go deleted file mode 100644 index 308d4116a33..00000000000 --- a/user/loadbalancinganalyticsevent_test.go +++ /dev/null @@ -1,48 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -package user_test - -import ( - "context" - "errors" - "os" - "testing" - "time" - - "github.com/cloudflare/cloudflare-go/v2" - "github.com/cloudflare/cloudflare-go/v2/internal/testutil" - "github.com/cloudflare/cloudflare-go/v2/option" - "github.com/cloudflare/cloudflare-go/v2/user" -) - -func TestLoadBalancingAnalyticsEventListWithOptionalParams(t *testing.T) { - t.Skip("skipped: tests are disabled for the time being") - baseURL := "http://localhost:4010" - if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { - baseURL = envURL - } - if !testutil.CheckTestServer(t, baseURL) { - return - } - client := cloudflare.NewClient( - option.WithBaseURL(baseURL), - option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), - option.WithAPIEmail("user@example.com"), - ) - _, err := client.User.LoadBalancing.Analytics.Events.List(context.TODO(), user.LoadBalancingAnalyticsEventListParams{ - OriginHealthy: cloudflare.F(true), - OriginName: cloudflare.F("primary-dc-1"), - PoolHealthy: cloudflare.F(true), - PoolID: cloudflare.F("17b5962d775c646f3f9725cbc7a53df4"), - PoolName: cloudflare.F("primary-dc"), - Since: cloudflare.F(time.Now()), - Until: cloudflare.F(time.Now()), - }) - if err != nil { - var apierr *cloudflare.Error - if errors.As(err, &apierr) { - t.Log(string(apierr.DumpRequest(true))) - } - t.Fatalf("err should be nil: %s", err.Error()) - } -} diff --git a/user/loadbalancingmonitor.go b/user/loadbalancingmonitor.go deleted file mode 100644 index f36075cbc32..00000000000 --- a/user/loadbalancingmonitor.go +++ /dev/null @@ -1,1445 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -package user - -import ( - "context" - "fmt" - "net/http" - "time" - - "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/internal/shared" - "github.com/cloudflare/cloudflare-go/v2/option" -) - -// LoadBalancingMonitorService contains methods and other services that help with -// interacting with the cloudflare API. Note, unlike clients, this service does not -// read variables from the environment automatically. You should not instantiate -// this service directly, and instead use the [NewLoadBalancingMonitorService] -// method instead. -type LoadBalancingMonitorService struct { - Options []option.RequestOption -} - -// NewLoadBalancingMonitorService generates a new service that applies the given -// options to each request. These options are applied after the parent client's -// options (if there is one), and before any request-specific options. -func NewLoadBalancingMonitorService(opts ...option.RequestOption) (r *LoadBalancingMonitorService) { - r = &LoadBalancingMonitorService{} - r.Options = opts - return -} - -// Create a configured monitor. -func (r *LoadBalancingMonitorService) New(ctx context.Context, body LoadBalancingMonitorNewParams, opts ...option.RequestOption) (res *LoadBalancingMonitorNewResponse, err error) { - opts = append(r.Options[:], opts...) - var env LoadBalancingMonitorNewResponseEnvelope - path := "user/load_balancers/monitors" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Modify a configured monitor. -func (r *LoadBalancingMonitorService) Update(ctx context.Context, monitorID string, body LoadBalancingMonitorUpdateParams, opts ...option.RequestOption) (res *LoadBalancingMonitorUpdateResponse, err error) { - opts = append(r.Options[:], opts...) - var env LoadBalancingMonitorUpdateResponseEnvelope - path := fmt.Sprintf("user/load_balancers/monitors/%s", monitorID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// List configured monitors for a user. -func (r *LoadBalancingMonitorService) List(ctx context.Context, opts ...option.RequestOption) (res *pagination.SinglePage[LoadBalancingMonitorListResponse], err error) { - var raw *http.Response - opts = append(r.Options, opts...) - opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) - path := "user/load_balancers/monitors" - cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, nil, &res, opts...) - if err != nil { - return nil, err - } - err = cfg.Execute() - if err != nil { - return nil, err - } - res.SetPageConfig(cfg, raw) - return res, nil -} - -// List configured monitors for a user. -func (r *LoadBalancingMonitorService) ListAutoPaging(ctx context.Context, opts ...option.RequestOption) *pagination.SinglePageAutoPager[LoadBalancingMonitorListResponse] { - return pagination.NewSinglePageAutoPager(r.List(ctx, opts...)) -} - -// Delete a configured monitor. -func (r *LoadBalancingMonitorService) Delete(ctx context.Context, monitorID string, body LoadBalancingMonitorDeleteParams, opts ...option.RequestOption) (res *LoadBalancingMonitorDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env LoadBalancingMonitorDeleteResponseEnvelope - path := fmt.Sprintf("user/load_balancers/monitors/%s", monitorID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Apply changes to an existing monitor, overwriting the supplied properties. -func (r *LoadBalancingMonitorService) Edit(ctx context.Context, monitorID string, body LoadBalancingMonitorEditParams, opts ...option.RequestOption) (res *LoadBalancingMonitorEditResponse, err error) { - opts = append(r.Options[:], opts...) - var env LoadBalancingMonitorEditResponseEnvelope - path := fmt.Sprintf("user/load_balancers/monitors/%s", monitorID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// List a single configured monitor for a user. -func (r *LoadBalancingMonitorService) Get(ctx context.Context, monitorID string, opts ...option.RequestOption) (res *LoadBalancingMonitorGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env LoadBalancingMonitorGetResponseEnvelope - path := fmt.Sprintf("user/load_balancers/monitors/%s", monitorID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Preview pools using the specified monitor with provided monitor details. The -// returned preview_id can be used in the preview endpoint to retrieve the results. -func (r *LoadBalancingMonitorService) Preview(ctx context.Context, monitorID string, body LoadBalancingMonitorPreviewParams, opts ...option.RequestOption) (res *LoadBalancingMonitorPreviewResponse, err error) { - opts = append(r.Options[:], opts...) - var env LoadBalancingMonitorPreviewResponseEnvelope - path := fmt.Sprintf("user/load_balancers/monitors/%s/preview", monitorID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get the list of resources that reference the provided monitor. -func (r *LoadBalancingMonitorService) References(ctx context.Context, monitorID string, opts ...option.RequestOption) (res *[]LoadBalancingMonitorReferencesResponse, err error) { - opts = append(r.Options[:], opts...) - var env LoadBalancingMonitorReferencesResponseEnvelope - path := fmt.Sprintf("user/load_balancers/monitors/%s/references", monitorID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type LoadBalancingMonitorNewResponse struct { - ID string `json:"id"` - // Do not validate the certificate when monitor use HTTPS. This parameter is - // currently only valid for HTTP and HTTPS monitors. - AllowInsecure bool `json:"allow_insecure"` - // To be marked unhealthy the monitored origin must fail this healthcheck N - // consecutive times. - ConsecutiveDown int64 `json:"consecutive_down"` - // To be marked healthy the monitored origin must pass this healthcheck N - // consecutive times. - ConsecutiveUp int64 `json:"consecutive_up"` - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Object description. - Description string `json:"description"` - // A case-insensitive sub-string to look for in the response body. If this string - // is not found, the origin will be marked as unhealthy. This parameter is only - // valid for HTTP and HTTPS monitors. - ExpectedBody string `json:"expected_body"` - // The expected HTTP response code or code range of the health check. This - // parameter is only valid for HTTP and HTTPS monitors. - ExpectedCodes string `json:"expected_codes"` - // Follow redirects if returned by the origin. This parameter is only valid for - // HTTP and HTTPS monitors. - FollowRedirects bool `json:"follow_redirects"` - // The HTTP request headers to send in the health check. It is recommended you set - // a Host header by default. The User-Agent header cannot be overridden. This - // parameter is only valid for HTTP and HTTPS monitors. - Header interface{} `json:"header"` - // The interval between each health check. Shorter intervals may improve failover - // time, but will increase load on the origins as we check from multiple locations. - Interval int64 `json:"interval"` - // The method to use for the health check. This defaults to 'GET' for HTTP/HTTPS - // based checks and 'connection_established' for TCP based health checks. - Method string `json:"method"` - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // The endpoint path you want to conduct a health check against. This parameter is - // only valid for HTTP and HTTPS monitors. - Path string `json:"path"` - // The port number to connect to for the health check. Required for TCP, UDP, and - // SMTP checks. HTTP and HTTPS checks should only define the port when using a - // non-standard port (HTTP: default 80, HTTPS: default 443). - Port int64 `json:"port"` - // Assign this monitor to emulate the specified zone while probing. This parameter - // is only valid for HTTP and HTTPS monitors. - ProbeZone string `json:"probe_zone"` - // The number of retries to attempt in case of a timeout before marking the origin - // as unhealthy. Retries are attempted immediately. - Retries int64 `json:"retries"` - // The timeout (in seconds) before marking the health check as failed. - Timeout int64 `json:"timeout"` - // The protocol to use for the health check. Currently supported protocols are - // 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. - Type LoadBalancingMonitorNewResponseType `json:"type"` - JSON loadBalancingMonitorNewResponseJSON `json:"-"` -} - -// loadBalancingMonitorNewResponseJSON contains the JSON metadata for the struct -// [LoadBalancingMonitorNewResponse] -type loadBalancingMonitorNewResponseJSON struct { - ID apijson.Field - AllowInsecure apijson.Field - ConsecutiveDown apijson.Field - ConsecutiveUp apijson.Field - CreatedOn apijson.Field - Description apijson.Field - ExpectedBody apijson.Field - ExpectedCodes apijson.Field - FollowRedirects apijson.Field - Header apijson.Field - Interval apijson.Field - Method apijson.Field - ModifiedOn apijson.Field - Path apijson.Field - Port apijson.Field - ProbeZone apijson.Field - Retries apijson.Field - Timeout apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancingMonitorNewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancingMonitorNewResponseJSON) RawJSON() string { - return r.raw -} - -// The protocol to use for the health check. Currently supported protocols are -// 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. -type LoadBalancingMonitorNewResponseType string - -const ( - LoadBalancingMonitorNewResponseTypeHTTP LoadBalancingMonitorNewResponseType = "http" - LoadBalancingMonitorNewResponseTypeHTTPS LoadBalancingMonitorNewResponseType = "https" - LoadBalancingMonitorNewResponseTypeTCP LoadBalancingMonitorNewResponseType = "tcp" - LoadBalancingMonitorNewResponseTypeUdpIcmp LoadBalancingMonitorNewResponseType = "udp_icmp" - LoadBalancingMonitorNewResponseTypeIcmpPing LoadBalancingMonitorNewResponseType = "icmp_ping" - LoadBalancingMonitorNewResponseTypeSmtp LoadBalancingMonitorNewResponseType = "smtp" -) - -func (r LoadBalancingMonitorNewResponseType) IsKnown() bool { - switch r { - case LoadBalancingMonitorNewResponseTypeHTTP, LoadBalancingMonitorNewResponseTypeHTTPS, LoadBalancingMonitorNewResponseTypeTCP, LoadBalancingMonitorNewResponseTypeUdpIcmp, LoadBalancingMonitorNewResponseTypeIcmpPing, LoadBalancingMonitorNewResponseTypeSmtp: - return true - } - return false -} - -type LoadBalancingMonitorUpdateResponse struct { - ID string `json:"id"` - // Do not validate the certificate when monitor use HTTPS. This parameter is - // currently only valid for HTTP and HTTPS monitors. - AllowInsecure bool `json:"allow_insecure"` - // To be marked unhealthy the monitored origin must fail this healthcheck N - // consecutive times. - ConsecutiveDown int64 `json:"consecutive_down"` - // To be marked healthy the monitored origin must pass this healthcheck N - // consecutive times. - ConsecutiveUp int64 `json:"consecutive_up"` - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Object description. - Description string `json:"description"` - // A case-insensitive sub-string to look for in the response body. If this string - // is not found, the origin will be marked as unhealthy. This parameter is only - // valid for HTTP and HTTPS monitors. - ExpectedBody string `json:"expected_body"` - // The expected HTTP response code or code range of the health check. This - // parameter is only valid for HTTP and HTTPS monitors. - ExpectedCodes string `json:"expected_codes"` - // Follow redirects if returned by the origin. This parameter is only valid for - // HTTP and HTTPS monitors. - FollowRedirects bool `json:"follow_redirects"` - // The HTTP request headers to send in the health check. It is recommended you set - // a Host header by default. The User-Agent header cannot be overridden. This - // parameter is only valid for HTTP and HTTPS monitors. - Header interface{} `json:"header"` - // The interval between each health check. Shorter intervals may improve failover - // time, but will increase load on the origins as we check from multiple locations. - Interval int64 `json:"interval"` - // The method to use for the health check. This defaults to 'GET' for HTTP/HTTPS - // based checks and 'connection_established' for TCP based health checks. - Method string `json:"method"` - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // The endpoint path you want to conduct a health check against. This parameter is - // only valid for HTTP and HTTPS monitors. - Path string `json:"path"` - // The port number to connect to for the health check. Required for TCP, UDP, and - // SMTP checks. HTTP and HTTPS checks should only define the port when using a - // non-standard port (HTTP: default 80, HTTPS: default 443). - Port int64 `json:"port"` - // Assign this monitor to emulate the specified zone while probing. This parameter - // is only valid for HTTP and HTTPS monitors. - ProbeZone string `json:"probe_zone"` - // The number of retries to attempt in case of a timeout before marking the origin - // as unhealthy. Retries are attempted immediately. - Retries int64 `json:"retries"` - // The timeout (in seconds) before marking the health check as failed. - Timeout int64 `json:"timeout"` - // The protocol to use for the health check. Currently supported protocols are - // 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. - Type LoadBalancingMonitorUpdateResponseType `json:"type"` - JSON loadBalancingMonitorUpdateResponseJSON `json:"-"` -} - -// loadBalancingMonitorUpdateResponseJSON contains the JSON metadata for the struct -// [LoadBalancingMonitorUpdateResponse] -type loadBalancingMonitorUpdateResponseJSON struct { - ID apijson.Field - AllowInsecure apijson.Field - ConsecutiveDown apijson.Field - ConsecutiveUp apijson.Field - CreatedOn apijson.Field - Description apijson.Field - ExpectedBody apijson.Field - ExpectedCodes apijson.Field - FollowRedirects apijson.Field - Header apijson.Field - Interval apijson.Field - Method apijson.Field - ModifiedOn apijson.Field - Path apijson.Field - Port apijson.Field - ProbeZone apijson.Field - Retries apijson.Field - Timeout apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancingMonitorUpdateResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancingMonitorUpdateResponseJSON) RawJSON() string { - return r.raw -} - -// The protocol to use for the health check. Currently supported protocols are -// 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. -type LoadBalancingMonitorUpdateResponseType string - -const ( - LoadBalancingMonitorUpdateResponseTypeHTTP LoadBalancingMonitorUpdateResponseType = "http" - LoadBalancingMonitorUpdateResponseTypeHTTPS LoadBalancingMonitorUpdateResponseType = "https" - LoadBalancingMonitorUpdateResponseTypeTCP LoadBalancingMonitorUpdateResponseType = "tcp" - LoadBalancingMonitorUpdateResponseTypeUdpIcmp LoadBalancingMonitorUpdateResponseType = "udp_icmp" - LoadBalancingMonitorUpdateResponseTypeIcmpPing LoadBalancingMonitorUpdateResponseType = "icmp_ping" - LoadBalancingMonitorUpdateResponseTypeSmtp LoadBalancingMonitorUpdateResponseType = "smtp" -) - -func (r LoadBalancingMonitorUpdateResponseType) IsKnown() bool { - switch r { - case LoadBalancingMonitorUpdateResponseTypeHTTP, LoadBalancingMonitorUpdateResponseTypeHTTPS, LoadBalancingMonitorUpdateResponseTypeTCP, LoadBalancingMonitorUpdateResponseTypeUdpIcmp, LoadBalancingMonitorUpdateResponseTypeIcmpPing, LoadBalancingMonitorUpdateResponseTypeSmtp: - return true - } - return false -} - -type LoadBalancingMonitorListResponse struct { - ID string `json:"id"` - // Do not validate the certificate when monitor use HTTPS. This parameter is - // currently only valid for HTTP and HTTPS monitors. - AllowInsecure bool `json:"allow_insecure"` - // To be marked unhealthy the monitored origin must fail this healthcheck N - // consecutive times. - ConsecutiveDown int64 `json:"consecutive_down"` - // To be marked healthy the monitored origin must pass this healthcheck N - // consecutive times. - ConsecutiveUp int64 `json:"consecutive_up"` - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Object description. - Description string `json:"description"` - // A case-insensitive sub-string to look for in the response body. If this string - // is not found, the origin will be marked as unhealthy. This parameter is only - // valid for HTTP and HTTPS monitors. - ExpectedBody string `json:"expected_body"` - // The expected HTTP response code or code range of the health check. This - // parameter is only valid for HTTP and HTTPS monitors. - ExpectedCodes string `json:"expected_codes"` - // Follow redirects if returned by the origin. This parameter is only valid for - // HTTP and HTTPS monitors. - FollowRedirects bool `json:"follow_redirects"` - // The HTTP request headers to send in the health check. It is recommended you set - // a Host header by default. The User-Agent header cannot be overridden. This - // parameter is only valid for HTTP and HTTPS monitors. - Header interface{} `json:"header"` - // The interval between each health check. Shorter intervals may improve failover - // time, but will increase load on the origins as we check from multiple locations. - Interval int64 `json:"interval"` - // The method to use for the health check. This defaults to 'GET' for HTTP/HTTPS - // based checks and 'connection_established' for TCP based health checks. - Method string `json:"method"` - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // The endpoint path you want to conduct a health check against. This parameter is - // only valid for HTTP and HTTPS monitors. - Path string `json:"path"` - // The port number to connect to for the health check. Required for TCP, UDP, and - // SMTP checks. HTTP and HTTPS checks should only define the port when using a - // non-standard port (HTTP: default 80, HTTPS: default 443). - Port int64 `json:"port"` - // Assign this monitor to emulate the specified zone while probing. This parameter - // is only valid for HTTP and HTTPS monitors. - ProbeZone string `json:"probe_zone"` - // The number of retries to attempt in case of a timeout before marking the origin - // as unhealthy. Retries are attempted immediately. - Retries int64 `json:"retries"` - // The timeout (in seconds) before marking the health check as failed. - Timeout int64 `json:"timeout"` - // The protocol to use for the health check. Currently supported protocols are - // 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. - Type LoadBalancingMonitorListResponseType `json:"type"` - JSON loadBalancingMonitorListResponseJSON `json:"-"` -} - -// loadBalancingMonitorListResponseJSON contains the JSON metadata for the struct -// [LoadBalancingMonitorListResponse] -type loadBalancingMonitorListResponseJSON struct { - ID apijson.Field - AllowInsecure apijson.Field - ConsecutiveDown apijson.Field - ConsecutiveUp apijson.Field - CreatedOn apijson.Field - Description apijson.Field - ExpectedBody apijson.Field - ExpectedCodes apijson.Field - FollowRedirects apijson.Field - Header apijson.Field - Interval apijson.Field - Method apijson.Field - ModifiedOn apijson.Field - Path apijson.Field - Port apijson.Field - ProbeZone apijson.Field - Retries apijson.Field - Timeout apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancingMonitorListResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancingMonitorListResponseJSON) RawJSON() string { - return r.raw -} - -// The protocol to use for the health check. Currently supported protocols are -// 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. -type LoadBalancingMonitorListResponseType string - -const ( - LoadBalancingMonitorListResponseTypeHTTP LoadBalancingMonitorListResponseType = "http" - LoadBalancingMonitorListResponseTypeHTTPS LoadBalancingMonitorListResponseType = "https" - LoadBalancingMonitorListResponseTypeTCP LoadBalancingMonitorListResponseType = "tcp" - LoadBalancingMonitorListResponseTypeUdpIcmp LoadBalancingMonitorListResponseType = "udp_icmp" - LoadBalancingMonitorListResponseTypeIcmpPing LoadBalancingMonitorListResponseType = "icmp_ping" - LoadBalancingMonitorListResponseTypeSmtp LoadBalancingMonitorListResponseType = "smtp" -) - -func (r LoadBalancingMonitorListResponseType) IsKnown() bool { - switch r { - case LoadBalancingMonitorListResponseTypeHTTP, LoadBalancingMonitorListResponseTypeHTTPS, LoadBalancingMonitorListResponseTypeTCP, LoadBalancingMonitorListResponseTypeUdpIcmp, LoadBalancingMonitorListResponseTypeIcmpPing, LoadBalancingMonitorListResponseTypeSmtp: - return true - } - return false -} - -type LoadBalancingMonitorDeleteResponse struct { - ID string `json:"id"` - JSON loadBalancingMonitorDeleteResponseJSON `json:"-"` -} - -// loadBalancingMonitorDeleteResponseJSON contains the JSON metadata for the struct -// [LoadBalancingMonitorDeleteResponse] -type loadBalancingMonitorDeleteResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancingMonitorDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancingMonitorDeleteResponseJSON) RawJSON() string { - return r.raw -} - -type LoadBalancingMonitorEditResponse struct { - ID string `json:"id"` - // Do not validate the certificate when monitor use HTTPS. This parameter is - // currently only valid for HTTP and HTTPS monitors. - AllowInsecure bool `json:"allow_insecure"` - // To be marked unhealthy the monitored origin must fail this healthcheck N - // consecutive times. - ConsecutiveDown int64 `json:"consecutive_down"` - // To be marked healthy the monitored origin must pass this healthcheck N - // consecutive times. - ConsecutiveUp int64 `json:"consecutive_up"` - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Object description. - Description string `json:"description"` - // A case-insensitive sub-string to look for in the response body. If this string - // is not found, the origin will be marked as unhealthy. This parameter is only - // valid for HTTP and HTTPS monitors. - ExpectedBody string `json:"expected_body"` - // The expected HTTP response code or code range of the health check. This - // parameter is only valid for HTTP and HTTPS monitors. - ExpectedCodes string `json:"expected_codes"` - // Follow redirects if returned by the origin. This parameter is only valid for - // HTTP and HTTPS monitors. - FollowRedirects bool `json:"follow_redirects"` - // The HTTP request headers to send in the health check. It is recommended you set - // a Host header by default. The User-Agent header cannot be overridden. This - // parameter is only valid for HTTP and HTTPS monitors. - Header interface{} `json:"header"` - // The interval between each health check. Shorter intervals may improve failover - // time, but will increase load on the origins as we check from multiple locations. - Interval int64 `json:"interval"` - // The method to use for the health check. This defaults to 'GET' for HTTP/HTTPS - // based checks and 'connection_established' for TCP based health checks. - Method string `json:"method"` - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // The endpoint path you want to conduct a health check against. This parameter is - // only valid for HTTP and HTTPS monitors. - Path string `json:"path"` - // The port number to connect to for the health check. Required for TCP, UDP, and - // SMTP checks. HTTP and HTTPS checks should only define the port when using a - // non-standard port (HTTP: default 80, HTTPS: default 443). - Port int64 `json:"port"` - // Assign this monitor to emulate the specified zone while probing. This parameter - // is only valid for HTTP and HTTPS monitors. - ProbeZone string `json:"probe_zone"` - // The number of retries to attempt in case of a timeout before marking the origin - // as unhealthy. Retries are attempted immediately. - Retries int64 `json:"retries"` - // The timeout (in seconds) before marking the health check as failed. - Timeout int64 `json:"timeout"` - // The protocol to use for the health check. Currently supported protocols are - // 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. - Type LoadBalancingMonitorEditResponseType `json:"type"` - JSON loadBalancingMonitorEditResponseJSON `json:"-"` -} - -// loadBalancingMonitorEditResponseJSON contains the JSON metadata for the struct -// [LoadBalancingMonitorEditResponse] -type loadBalancingMonitorEditResponseJSON struct { - ID apijson.Field - AllowInsecure apijson.Field - ConsecutiveDown apijson.Field - ConsecutiveUp apijson.Field - CreatedOn apijson.Field - Description apijson.Field - ExpectedBody apijson.Field - ExpectedCodes apijson.Field - FollowRedirects apijson.Field - Header apijson.Field - Interval apijson.Field - Method apijson.Field - ModifiedOn apijson.Field - Path apijson.Field - Port apijson.Field - ProbeZone apijson.Field - Retries apijson.Field - Timeout apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancingMonitorEditResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancingMonitorEditResponseJSON) RawJSON() string { - return r.raw -} - -// The protocol to use for the health check. Currently supported protocols are -// 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. -type LoadBalancingMonitorEditResponseType string - -const ( - LoadBalancingMonitorEditResponseTypeHTTP LoadBalancingMonitorEditResponseType = "http" - LoadBalancingMonitorEditResponseTypeHTTPS LoadBalancingMonitorEditResponseType = "https" - LoadBalancingMonitorEditResponseTypeTCP LoadBalancingMonitorEditResponseType = "tcp" - LoadBalancingMonitorEditResponseTypeUdpIcmp LoadBalancingMonitorEditResponseType = "udp_icmp" - LoadBalancingMonitorEditResponseTypeIcmpPing LoadBalancingMonitorEditResponseType = "icmp_ping" - LoadBalancingMonitorEditResponseTypeSmtp LoadBalancingMonitorEditResponseType = "smtp" -) - -func (r LoadBalancingMonitorEditResponseType) IsKnown() bool { - switch r { - case LoadBalancingMonitorEditResponseTypeHTTP, LoadBalancingMonitorEditResponseTypeHTTPS, LoadBalancingMonitorEditResponseTypeTCP, LoadBalancingMonitorEditResponseTypeUdpIcmp, LoadBalancingMonitorEditResponseTypeIcmpPing, LoadBalancingMonitorEditResponseTypeSmtp: - return true - } - return false -} - -type LoadBalancingMonitorGetResponse struct { - ID string `json:"id"` - // Do not validate the certificate when monitor use HTTPS. This parameter is - // currently only valid for HTTP and HTTPS monitors. - AllowInsecure bool `json:"allow_insecure"` - // To be marked unhealthy the monitored origin must fail this healthcheck N - // consecutive times. - ConsecutiveDown int64 `json:"consecutive_down"` - // To be marked healthy the monitored origin must pass this healthcheck N - // consecutive times. - ConsecutiveUp int64 `json:"consecutive_up"` - CreatedOn time.Time `json:"created_on" format:"date-time"` - // Object description. - Description string `json:"description"` - // A case-insensitive sub-string to look for in the response body. If this string - // is not found, the origin will be marked as unhealthy. This parameter is only - // valid for HTTP and HTTPS monitors. - ExpectedBody string `json:"expected_body"` - // The expected HTTP response code or code range of the health check. This - // parameter is only valid for HTTP and HTTPS monitors. - ExpectedCodes string `json:"expected_codes"` - // Follow redirects if returned by the origin. This parameter is only valid for - // HTTP and HTTPS monitors. - FollowRedirects bool `json:"follow_redirects"` - // The HTTP request headers to send in the health check. It is recommended you set - // a Host header by default. The User-Agent header cannot be overridden. This - // parameter is only valid for HTTP and HTTPS monitors. - Header interface{} `json:"header"` - // The interval between each health check. Shorter intervals may improve failover - // time, but will increase load on the origins as we check from multiple locations. - Interval int64 `json:"interval"` - // The method to use for the health check. This defaults to 'GET' for HTTP/HTTPS - // based checks and 'connection_established' for TCP based health checks. - Method string `json:"method"` - ModifiedOn time.Time `json:"modified_on" format:"date-time"` - // The endpoint path you want to conduct a health check against. This parameter is - // only valid for HTTP and HTTPS monitors. - Path string `json:"path"` - // The port number to connect to for the health check. Required for TCP, UDP, and - // SMTP checks. HTTP and HTTPS checks should only define the port when using a - // non-standard port (HTTP: default 80, HTTPS: default 443). - Port int64 `json:"port"` - // Assign this monitor to emulate the specified zone while probing. This parameter - // is only valid for HTTP and HTTPS monitors. - ProbeZone string `json:"probe_zone"` - // The number of retries to attempt in case of a timeout before marking the origin - // as unhealthy. Retries are attempted immediately. - Retries int64 `json:"retries"` - // The timeout (in seconds) before marking the health check as failed. - Timeout int64 `json:"timeout"` - // The protocol to use for the health check. Currently supported protocols are - // 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. - Type LoadBalancingMonitorGetResponseType `json:"type"` - JSON loadBalancingMonitorGetResponseJSON `json:"-"` -} - -// loadBalancingMonitorGetResponseJSON contains the JSON metadata for the struct -// [LoadBalancingMonitorGetResponse] -type loadBalancingMonitorGetResponseJSON struct { - ID apijson.Field - AllowInsecure apijson.Field - ConsecutiveDown apijson.Field - ConsecutiveUp apijson.Field - CreatedOn apijson.Field - Description apijson.Field - ExpectedBody apijson.Field - ExpectedCodes apijson.Field - FollowRedirects apijson.Field - Header apijson.Field - Interval apijson.Field - Method apijson.Field - ModifiedOn apijson.Field - Path apijson.Field - Port apijson.Field - ProbeZone apijson.Field - Retries apijson.Field - Timeout apijson.Field - Type apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancingMonitorGetResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancingMonitorGetResponseJSON) RawJSON() string { - return r.raw -} - -// The protocol to use for the health check. Currently supported protocols are -// 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. -type LoadBalancingMonitorGetResponseType string - -const ( - LoadBalancingMonitorGetResponseTypeHTTP LoadBalancingMonitorGetResponseType = "http" - LoadBalancingMonitorGetResponseTypeHTTPS LoadBalancingMonitorGetResponseType = "https" - LoadBalancingMonitorGetResponseTypeTCP LoadBalancingMonitorGetResponseType = "tcp" - LoadBalancingMonitorGetResponseTypeUdpIcmp LoadBalancingMonitorGetResponseType = "udp_icmp" - LoadBalancingMonitorGetResponseTypeIcmpPing LoadBalancingMonitorGetResponseType = "icmp_ping" - LoadBalancingMonitorGetResponseTypeSmtp LoadBalancingMonitorGetResponseType = "smtp" -) - -func (r LoadBalancingMonitorGetResponseType) IsKnown() bool { - switch r { - case LoadBalancingMonitorGetResponseTypeHTTP, LoadBalancingMonitorGetResponseTypeHTTPS, LoadBalancingMonitorGetResponseTypeTCP, LoadBalancingMonitorGetResponseTypeUdpIcmp, LoadBalancingMonitorGetResponseTypeIcmpPing, LoadBalancingMonitorGetResponseTypeSmtp: - return true - } - return false -} - -type LoadBalancingMonitorPreviewResponse struct { - // Monitored pool IDs mapped to their respective names. - Pools map[string]string `json:"pools"` - PreviewID string `json:"preview_id"` - JSON loadBalancingMonitorPreviewResponseJSON `json:"-"` -} - -// loadBalancingMonitorPreviewResponseJSON contains the JSON metadata for the -// struct [LoadBalancingMonitorPreviewResponse] -type loadBalancingMonitorPreviewResponseJSON struct { - Pools apijson.Field - PreviewID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancingMonitorPreviewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancingMonitorPreviewResponseJSON) RawJSON() string { - return r.raw -} - -type LoadBalancingMonitorReferencesResponse struct { - ReferenceType LoadBalancingMonitorReferencesResponseReferenceType `json:"reference_type"` - ResourceID string `json:"resource_id"` - ResourceName string `json:"resource_name"` - ResourceType string `json:"resource_type"` - JSON loadBalancingMonitorReferencesResponseJSON `json:"-"` -} - -// loadBalancingMonitorReferencesResponseJSON contains the JSON metadata for the -// struct [LoadBalancingMonitorReferencesResponse] -type loadBalancingMonitorReferencesResponseJSON struct { - ReferenceType apijson.Field - ResourceID apijson.Field - ResourceName apijson.Field - ResourceType apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancingMonitorReferencesResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancingMonitorReferencesResponseJSON) RawJSON() string { - return r.raw -} - -type LoadBalancingMonitorReferencesResponseReferenceType string - -const ( - LoadBalancingMonitorReferencesResponseReferenceTypeStar LoadBalancingMonitorReferencesResponseReferenceType = "*" - LoadBalancingMonitorReferencesResponseReferenceTypeReferral LoadBalancingMonitorReferencesResponseReferenceType = "referral" - LoadBalancingMonitorReferencesResponseReferenceTypeReferrer LoadBalancingMonitorReferencesResponseReferenceType = "referrer" -) - -func (r LoadBalancingMonitorReferencesResponseReferenceType) IsKnown() bool { - switch r { - case LoadBalancingMonitorReferencesResponseReferenceTypeStar, LoadBalancingMonitorReferencesResponseReferenceTypeReferral, LoadBalancingMonitorReferencesResponseReferenceTypeReferrer: - return true - } - return false -} - -type LoadBalancingMonitorNewParams struct { - // The expected HTTP response code or code range of the health check. This - // parameter is only valid for HTTP and HTTPS monitors. - ExpectedCodes param.Field[string] `json:"expected_codes,required"` - // Do not validate the certificate when monitor use HTTPS. This parameter is - // currently only valid for HTTP and HTTPS monitors. - AllowInsecure param.Field[bool] `json:"allow_insecure"` - // To be marked unhealthy the monitored origin must fail this healthcheck N - // consecutive times. - ConsecutiveDown param.Field[int64] `json:"consecutive_down"` - // To be marked healthy the monitored origin must pass this healthcheck N - // consecutive times. - ConsecutiveUp param.Field[int64] `json:"consecutive_up"` - // Object description. - Description param.Field[string] `json:"description"` - // A case-insensitive sub-string to look for in the response body. If this string - // is not found, the origin will be marked as unhealthy. This parameter is only - // valid for HTTP and HTTPS monitors. - ExpectedBody param.Field[string] `json:"expected_body"` - // Follow redirects if returned by the origin. This parameter is only valid for - // HTTP and HTTPS monitors. - FollowRedirects param.Field[bool] `json:"follow_redirects"` - // The HTTP request headers to send in the health check. It is recommended you set - // a Host header by default. The User-Agent header cannot be overridden. This - // parameter is only valid for HTTP and HTTPS monitors. - Header param.Field[interface{}] `json:"header"` - // The interval between each health check. Shorter intervals may improve failover - // time, but will increase load on the origins as we check from multiple locations. - Interval param.Field[int64] `json:"interval"` - // The method to use for the health check. This defaults to 'GET' for HTTP/HTTPS - // based checks and 'connection_established' for TCP based health checks. - Method param.Field[string] `json:"method"` - // The endpoint path you want to conduct a health check against. This parameter is - // only valid for HTTP and HTTPS monitors. - Path param.Field[string] `json:"path"` - // The port number to connect to for the health check. Required for TCP, UDP, and - // SMTP checks. HTTP and HTTPS checks should only define the port when using a - // non-standard port (HTTP: default 80, HTTPS: default 443). - Port param.Field[int64] `json:"port"` - // Assign this monitor to emulate the specified zone while probing. This parameter - // is only valid for HTTP and HTTPS monitors. - ProbeZone param.Field[string] `json:"probe_zone"` - // The number of retries to attempt in case of a timeout before marking the origin - // as unhealthy. Retries are attempted immediately. - Retries param.Field[int64] `json:"retries"` - // The timeout (in seconds) before marking the health check as failed. - Timeout param.Field[int64] `json:"timeout"` - // The protocol to use for the health check. Currently supported protocols are - // 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. - Type param.Field[LoadBalancingMonitorNewParamsType] `json:"type"` -} - -func (r LoadBalancingMonitorNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The protocol to use for the health check. Currently supported protocols are -// 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. -type LoadBalancingMonitorNewParamsType string - -const ( - LoadBalancingMonitorNewParamsTypeHTTP LoadBalancingMonitorNewParamsType = "http" - LoadBalancingMonitorNewParamsTypeHTTPS LoadBalancingMonitorNewParamsType = "https" - LoadBalancingMonitorNewParamsTypeTCP LoadBalancingMonitorNewParamsType = "tcp" - LoadBalancingMonitorNewParamsTypeUdpIcmp LoadBalancingMonitorNewParamsType = "udp_icmp" - LoadBalancingMonitorNewParamsTypeIcmpPing LoadBalancingMonitorNewParamsType = "icmp_ping" - LoadBalancingMonitorNewParamsTypeSmtp LoadBalancingMonitorNewParamsType = "smtp" -) - -func (r LoadBalancingMonitorNewParamsType) IsKnown() bool { - switch r { - case LoadBalancingMonitorNewParamsTypeHTTP, LoadBalancingMonitorNewParamsTypeHTTPS, LoadBalancingMonitorNewParamsTypeTCP, LoadBalancingMonitorNewParamsTypeUdpIcmp, LoadBalancingMonitorNewParamsTypeIcmpPing, LoadBalancingMonitorNewParamsTypeSmtp: - return true - } - return false -} - -type LoadBalancingMonitorNewResponseEnvelope struct { - Errors []shared.ResponseInfo `json:"errors,required"` - Messages []shared.ResponseInfo `json:"messages,required"` - Result LoadBalancingMonitorNewResponse `json:"result,required"` - // Whether the API call was successful - Success LoadBalancingMonitorNewResponseEnvelopeSuccess `json:"success,required"` - JSON loadBalancingMonitorNewResponseEnvelopeJSON `json:"-"` -} - -// loadBalancingMonitorNewResponseEnvelopeJSON contains the JSON metadata for the -// struct [LoadBalancingMonitorNewResponseEnvelope] -type loadBalancingMonitorNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancingMonitorNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancingMonitorNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LoadBalancingMonitorNewResponseEnvelopeSuccess bool - -const ( - LoadBalancingMonitorNewResponseEnvelopeSuccessTrue LoadBalancingMonitorNewResponseEnvelopeSuccess = true -) - -func (r LoadBalancingMonitorNewResponseEnvelopeSuccess) IsKnown() bool { - switch r { - case LoadBalancingMonitorNewResponseEnvelopeSuccessTrue: - return true - } - return false -} - -type LoadBalancingMonitorUpdateParams struct { - // The expected HTTP response code or code range of the health check. This - // parameter is only valid for HTTP and HTTPS monitors. - ExpectedCodes param.Field[string] `json:"expected_codes,required"` - // Do not validate the certificate when monitor use HTTPS. This parameter is - // currently only valid for HTTP and HTTPS monitors. - AllowInsecure param.Field[bool] `json:"allow_insecure"` - // To be marked unhealthy the monitored origin must fail this healthcheck N - // consecutive times. - ConsecutiveDown param.Field[int64] `json:"consecutive_down"` - // To be marked healthy the monitored origin must pass this healthcheck N - // consecutive times. - ConsecutiveUp param.Field[int64] `json:"consecutive_up"` - // Object description. - Description param.Field[string] `json:"description"` - // A case-insensitive sub-string to look for in the response body. If this string - // is not found, the origin will be marked as unhealthy. This parameter is only - // valid for HTTP and HTTPS monitors. - ExpectedBody param.Field[string] `json:"expected_body"` - // Follow redirects if returned by the origin. This parameter is only valid for - // HTTP and HTTPS monitors. - FollowRedirects param.Field[bool] `json:"follow_redirects"` - // The HTTP request headers to send in the health check. It is recommended you set - // a Host header by default. The User-Agent header cannot be overridden. This - // parameter is only valid for HTTP and HTTPS monitors. - Header param.Field[interface{}] `json:"header"` - // The interval between each health check. Shorter intervals may improve failover - // time, but will increase load on the origins as we check from multiple locations. - Interval param.Field[int64] `json:"interval"` - // The method to use for the health check. This defaults to 'GET' for HTTP/HTTPS - // based checks and 'connection_established' for TCP based health checks. - Method param.Field[string] `json:"method"` - // The endpoint path you want to conduct a health check against. This parameter is - // only valid for HTTP and HTTPS monitors. - Path param.Field[string] `json:"path"` - // The port number to connect to for the health check. Required for TCP, UDP, and - // SMTP checks. HTTP and HTTPS checks should only define the port when using a - // non-standard port (HTTP: default 80, HTTPS: default 443). - Port param.Field[int64] `json:"port"` - // Assign this monitor to emulate the specified zone while probing. This parameter - // is only valid for HTTP and HTTPS monitors. - ProbeZone param.Field[string] `json:"probe_zone"` - // The number of retries to attempt in case of a timeout before marking the origin - // as unhealthy. Retries are attempted immediately. - Retries param.Field[int64] `json:"retries"` - // The timeout (in seconds) before marking the health check as failed. - Timeout param.Field[int64] `json:"timeout"` - // The protocol to use for the health check. Currently supported protocols are - // 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. - Type param.Field[LoadBalancingMonitorUpdateParamsType] `json:"type"` -} - -func (r LoadBalancingMonitorUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The protocol to use for the health check. Currently supported protocols are -// 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. -type LoadBalancingMonitorUpdateParamsType string - -const ( - LoadBalancingMonitorUpdateParamsTypeHTTP LoadBalancingMonitorUpdateParamsType = "http" - LoadBalancingMonitorUpdateParamsTypeHTTPS LoadBalancingMonitorUpdateParamsType = "https" - LoadBalancingMonitorUpdateParamsTypeTCP LoadBalancingMonitorUpdateParamsType = "tcp" - LoadBalancingMonitorUpdateParamsTypeUdpIcmp LoadBalancingMonitorUpdateParamsType = "udp_icmp" - LoadBalancingMonitorUpdateParamsTypeIcmpPing LoadBalancingMonitorUpdateParamsType = "icmp_ping" - LoadBalancingMonitorUpdateParamsTypeSmtp LoadBalancingMonitorUpdateParamsType = "smtp" -) - -func (r LoadBalancingMonitorUpdateParamsType) IsKnown() bool { - switch r { - case LoadBalancingMonitorUpdateParamsTypeHTTP, LoadBalancingMonitorUpdateParamsTypeHTTPS, LoadBalancingMonitorUpdateParamsTypeTCP, LoadBalancingMonitorUpdateParamsTypeUdpIcmp, LoadBalancingMonitorUpdateParamsTypeIcmpPing, LoadBalancingMonitorUpdateParamsTypeSmtp: - return true - } - return false -} - -type LoadBalancingMonitorUpdateResponseEnvelope struct { - Errors []shared.ResponseInfo `json:"errors,required"` - Messages []shared.ResponseInfo `json:"messages,required"` - Result LoadBalancingMonitorUpdateResponse `json:"result,required"` - // Whether the API call was successful - Success LoadBalancingMonitorUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON loadBalancingMonitorUpdateResponseEnvelopeJSON `json:"-"` -} - -// loadBalancingMonitorUpdateResponseEnvelopeJSON contains the JSON metadata for -// the struct [LoadBalancingMonitorUpdateResponseEnvelope] -type loadBalancingMonitorUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancingMonitorUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancingMonitorUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LoadBalancingMonitorUpdateResponseEnvelopeSuccess bool - -const ( - LoadBalancingMonitorUpdateResponseEnvelopeSuccessTrue LoadBalancingMonitorUpdateResponseEnvelopeSuccess = true -) - -func (r LoadBalancingMonitorUpdateResponseEnvelopeSuccess) IsKnown() bool { - switch r { - case LoadBalancingMonitorUpdateResponseEnvelopeSuccessTrue: - return true - } - return false -} - -type LoadBalancingMonitorDeleteParams struct { - Body param.Field[interface{}] `json:"body,required"` -} - -func (r LoadBalancingMonitorDeleteParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r.Body) -} - -type LoadBalancingMonitorDeleteResponseEnvelope struct { - Errors []shared.ResponseInfo `json:"errors,required"` - Messages []shared.ResponseInfo `json:"messages,required"` - Result LoadBalancingMonitorDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success LoadBalancingMonitorDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON loadBalancingMonitorDeleteResponseEnvelopeJSON `json:"-"` -} - -// loadBalancingMonitorDeleteResponseEnvelopeJSON contains the JSON metadata for -// the struct [LoadBalancingMonitorDeleteResponseEnvelope] -type loadBalancingMonitorDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancingMonitorDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancingMonitorDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LoadBalancingMonitorDeleteResponseEnvelopeSuccess bool - -const ( - LoadBalancingMonitorDeleteResponseEnvelopeSuccessTrue LoadBalancingMonitorDeleteResponseEnvelopeSuccess = true -) - -func (r LoadBalancingMonitorDeleteResponseEnvelopeSuccess) IsKnown() bool { - switch r { - case LoadBalancingMonitorDeleteResponseEnvelopeSuccessTrue: - return true - } - return false -} - -type LoadBalancingMonitorEditParams struct { - // The expected HTTP response code or code range of the health check. This - // parameter is only valid for HTTP and HTTPS monitors. - ExpectedCodes param.Field[string] `json:"expected_codes,required"` - // Do not validate the certificate when monitor use HTTPS. This parameter is - // currently only valid for HTTP and HTTPS monitors. - AllowInsecure param.Field[bool] `json:"allow_insecure"` - // To be marked unhealthy the monitored origin must fail this healthcheck N - // consecutive times. - ConsecutiveDown param.Field[int64] `json:"consecutive_down"` - // To be marked healthy the monitored origin must pass this healthcheck N - // consecutive times. - ConsecutiveUp param.Field[int64] `json:"consecutive_up"` - // Object description. - Description param.Field[string] `json:"description"` - // A case-insensitive sub-string to look for in the response body. If this string - // is not found, the origin will be marked as unhealthy. This parameter is only - // valid for HTTP and HTTPS monitors. - ExpectedBody param.Field[string] `json:"expected_body"` - // Follow redirects if returned by the origin. This parameter is only valid for - // HTTP and HTTPS monitors. - FollowRedirects param.Field[bool] `json:"follow_redirects"` - // The HTTP request headers to send in the health check. It is recommended you set - // a Host header by default. The User-Agent header cannot be overridden. This - // parameter is only valid for HTTP and HTTPS monitors. - Header param.Field[interface{}] `json:"header"` - // The interval between each health check. Shorter intervals may improve failover - // time, but will increase load on the origins as we check from multiple locations. - Interval param.Field[int64] `json:"interval"` - // The method to use for the health check. This defaults to 'GET' for HTTP/HTTPS - // based checks and 'connection_established' for TCP based health checks. - Method param.Field[string] `json:"method"` - // The endpoint path you want to conduct a health check against. This parameter is - // only valid for HTTP and HTTPS monitors. - Path param.Field[string] `json:"path"` - // The port number to connect to for the health check. Required for TCP, UDP, and - // SMTP checks. HTTP and HTTPS checks should only define the port when using a - // non-standard port (HTTP: default 80, HTTPS: default 443). - Port param.Field[int64] `json:"port"` - // Assign this monitor to emulate the specified zone while probing. This parameter - // is only valid for HTTP and HTTPS monitors. - ProbeZone param.Field[string] `json:"probe_zone"` - // The number of retries to attempt in case of a timeout before marking the origin - // as unhealthy. Retries are attempted immediately. - Retries param.Field[int64] `json:"retries"` - // The timeout (in seconds) before marking the health check as failed. - Timeout param.Field[int64] `json:"timeout"` - // The protocol to use for the health check. Currently supported protocols are - // 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. - Type param.Field[LoadBalancingMonitorEditParamsType] `json:"type"` -} - -func (r LoadBalancingMonitorEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The protocol to use for the health check. Currently supported protocols are -// 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. -type LoadBalancingMonitorEditParamsType string - -const ( - LoadBalancingMonitorEditParamsTypeHTTP LoadBalancingMonitorEditParamsType = "http" - LoadBalancingMonitorEditParamsTypeHTTPS LoadBalancingMonitorEditParamsType = "https" - LoadBalancingMonitorEditParamsTypeTCP LoadBalancingMonitorEditParamsType = "tcp" - LoadBalancingMonitorEditParamsTypeUdpIcmp LoadBalancingMonitorEditParamsType = "udp_icmp" - LoadBalancingMonitorEditParamsTypeIcmpPing LoadBalancingMonitorEditParamsType = "icmp_ping" - LoadBalancingMonitorEditParamsTypeSmtp LoadBalancingMonitorEditParamsType = "smtp" -) - -func (r LoadBalancingMonitorEditParamsType) IsKnown() bool { - switch r { - case LoadBalancingMonitorEditParamsTypeHTTP, LoadBalancingMonitorEditParamsTypeHTTPS, LoadBalancingMonitorEditParamsTypeTCP, LoadBalancingMonitorEditParamsTypeUdpIcmp, LoadBalancingMonitorEditParamsTypeIcmpPing, LoadBalancingMonitorEditParamsTypeSmtp: - return true - } - return false -} - -type LoadBalancingMonitorEditResponseEnvelope struct { - Errors []shared.ResponseInfo `json:"errors,required"` - Messages []shared.ResponseInfo `json:"messages,required"` - Result LoadBalancingMonitorEditResponse `json:"result,required"` - // Whether the API call was successful - Success LoadBalancingMonitorEditResponseEnvelopeSuccess `json:"success,required"` - JSON loadBalancingMonitorEditResponseEnvelopeJSON `json:"-"` -} - -// loadBalancingMonitorEditResponseEnvelopeJSON contains the JSON metadata for the -// struct [LoadBalancingMonitorEditResponseEnvelope] -type loadBalancingMonitorEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancingMonitorEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancingMonitorEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LoadBalancingMonitorEditResponseEnvelopeSuccess bool - -const ( - LoadBalancingMonitorEditResponseEnvelopeSuccessTrue LoadBalancingMonitorEditResponseEnvelopeSuccess = true -) - -func (r LoadBalancingMonitorEditResponseEnvelopeSuccess) IsKnown() bool { - switch r { - case LoadBalancingMonitorEditResponseEnvelopeSuccessTrue: - return true - } - return false -} - -type LoadBalancingMonitorGetResponseEnvelope struct { - Errors []shared.ResponseInfo `json:"errors,required"` - Messages []shared.ResponseInfo `json:"messages,required"` - Result LoadBalancingMonitorGetResponse `json:"result,required"` - // Whether the API call was successful - Success LoadBalancingMonitorGetResponseEnvelopeSuccess `json:"success,required"` - JSON loadBalancingMonitorGetResponseEnvelopeJSON `json:"-"` -} - -// loadBalancingMonitorGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [LoadBalancingMonitorGetResponseEnvelope] -type loadBalancingMonitorGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancingMonitorGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancingMonitorGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LoadBalancingMonitorGetResponseEnvelopeSuccess bool - -const ( - LoadBalancingMonitorGetResponseEnvelopeSuccessTrue LoadBalancingMonitorGetResponseEnvelopeSuccess = true -) - -func (r LoadBalancingMonitorGetResponseEnvelopeSuccess) IsKnown() bool { - switch r { - case LoadBalancingMonitorGetResponseEnvelopeSuccessTrue: - return true - } - return false -} - -type LoadBalancingMonitorPreviewParams struct { - // The expected HTTP response code or code range of the health check. This - // parameter is only valid for HTTP and HTTPS monitors. - ExpectedCodes param.Field[string] `json:"expected_codes,required"` - // Do not validate the certificate when monitor use HTTPS. This parameter is - // currently only valid for HTTP and HTTPS monitors. - AllowInsecure param.Field[bool] `json:"allow_insecure"` - // To be marked unhealthy the monitored origin must fail this healthcheck N - // consecutive times. - ConsecutiveDown param.Field[int64] `json:"consecutive_down"` - // To be marked healthy the monitored origin must pass this healthcheck N - // consecutive times. - ConsecutiveUp param.Field[int64] `json:"consecutive_up"` - // Object description. - Description param.Field[string] `json:"description"` - // A case-insensitive sub-string to look for in the response body. If this string - // is not found, the origin will be marked as unhealthy. This parameter is only - // valid for HTTP and HTTPS monitors. - ExpectedBody param.Field[string] `json:"expected_body"` - // Follow redirects if returned by the origin. This parameter is only valid for - // HTTP and HTTPS monitors. - FollowRedirects param.Field[bool] `json:"follow_redirects"` - // The HTTP request headers to send in the health check. It is recommended you set - // a Host header by default. The User-Agent header cannot be overridden. This - // parameter is only valid for HTTP and HTTPS monitors. - Header param.Field[interface{}] `json:"header"` - // The interval between each health check. Shorter intervals may improve failover - // time, but will increase load on the origins as we check from multiple locations. - Interval param.Field[int64] `json:"interval"` - // The method to use for the health check. This defaults to 'GET' for HTTP/HTTPS - // based checks and 'connection_established' for TCP based health checks. - Method param.Field[string] `json:"method"` - // The endpoint path you want to conduct a health check against. This parameter is - // only valid for HTTP and HTTPS monitors. - Path param.Field[string] `json:"path"` - // The port number to connect to for the health check. Required for TCP, UDP, and - // SMTP checks. HTTP and HTTPS checks should only define the port when using a - // non-standard port (HTTP: default 80, HTTPS: default 443). - Port param.Field[int64] `json:"port"` - // Assign this monitor to emulate the specified zone while probing. This parameter - // is only valid for HTTP and HTTPS monitors. - ProbeZone param.Field[string] `json:"probe_zone"` - // The number of retries to attempt in case of a timeout before marking the origin - // as unhealthy. Retries are attempted immediately. - Retries param.Field[int64] `json:"retries"` - // The timeout (in seconds) before marking the health check as failed. - Timeout param.Field[int64] `json:"timeout"` - // The protocol to use for the health check. Currently supported protocols are - // 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. - Type param.Field[LoadBalancingMonitorPreviewParamsType] `json:"type"` -} - -func (r LoadBalancingMonitorPreviewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The protocol to use for the health check. Currently supported protocols are -// 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. -type LoadBalancingMonitorPreviewParamsType string - -const ( - LoadBalancingMonitorPreviewParamsTypeHTTP LoadBalancingMonitorPreviewParamsType = "http" - LoadBalancingMonitorPreviewParamsTypeHTTPS LoadBalancingMonitorPreviewParamsType = "https" - LoadBalancingMonitorPreviewParamsTypeTCP LoadBalancingMonitorPreviewParamsType = "tcp" - LoadBalancingMonitorPreviewParamsTypeUdpIcmp LoadBalancingMonitorPreviewParamsType = "udp_icmp" - LoadBalancingMonitorPreviewParamsTypeIcmpPing LoadBalancingMonitorPreviewParamsType = "icmp_ping" - LoadBalancingMonitorPreviewParamsTypeSmtp LoadBalancingMonitorPreviewParamsType = "smtp" -) - -func (r LoadBalancingMonitorPreviewParamsType) IsKnown() bool { - switch r { - case LoadBalancingMonitorPreviewParamsTypeHTTP, LoadBalancingMonitorPreviewParamsTypeHTTPS, LoadBalancingMonitorPreviewParamsTypeTCP, LoadBalancingMonitorPreviewParamsTypeUdpIcmp, LoadBalancingMonitorPreviewParamsTypeIcmpPing, LoadBalancingMonitorPreviewParamsTypeSmtp: - return true - } - return false -} - -type LoadBalancingMonitorPreviewResponseEnvelope struct { - Errors []shared.ResponseInfo `json:"errors,required"` - Messages []shared.ResponseInfo `json:"messages,required"` - Result LoadBalancingMonitorPreviewResponse `json:"result,required"` - // Whether the API call was successful - Success LoadBalancingMonitorPreviewResponseEnvelopeSuccess `json:"success,required"` - JSON loadBalancingMonitorPreviewResponseEnvelopeJSON `json:"-"` -} - -// loadBalancingMonitorPreviewResponseEnvelopeJSON contains the JSON metadata for -// the struct [LoadBalancingMonitorPreviewResponseEnvelope] -type loadBalancingMonitorPreviewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancingMonitorPreviewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancingMonitorPreviewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LoadBalancingMonitorPreviewResponseEnvelopeSuccess bool - -const ( - LoadBalancingMonitorPreviewResponseEnvelopeSuccessTrue LoadBalancingMonitorPreviewResponseEnvelopeSuccess = true -) - -func (r LoadBalancingMonitorPreviewResponseEnvelopeSuccess) IsKnown() bool { - switch r { - case LoadBalancingMonitorPreviewResponseEnvelopeSuccessTrue: - return true - } - return false -} - -type LoadBalancingMonitorReferencesResponseEnvelope struct { - Errors []shared.ResponseInfo `json:"errors,required"` - Messages []shared.ResponseInfo `json:"messages,required"` - // List of resources that reference a given monitor. - Result []LoadBalancingMonitorReferencesResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success LoadBalancingMonitorReferencesResponseEnvelopeSuccess `json:"success,required"` - ResultInfo LoadBalancingMonitorReferencesResponseEnvelopeResultInfo `json:"result_info"` - JSON loadBalancingMonitorReferencesResponseEnvelopeJSON `json:"-"` -} - -// loadBalancingMonitorReferencesResponseEnvelopeJSON contains the JSON metadata -// for the struct [LoadBalancingMonitorReferencesResponseEnvelope] -type loadBalancingMonitorReferencesResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - ResultInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancingMonitorReferencesResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancingMonitorReferencesResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LoadBalancingMonitorReferencesResponseEnvelopeSuccess bool - -const ( - LoadBalancingMonitorReferencesResponseEnvelopeSuccessTrue LoadBalancingMonitorReferencesResponseEnvelopeSuccess = true -) - -func (r LoadBalancingMonitorReferencesResponseEnvelopeSuccess) IsKnown() bool { - switch r { - case LoadBalancingMonitorReferencesResponseEnvelopeSuccessTrue: - return true - } - return false -} - -type LoadBalancingMonitorReferencesResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON loadBalancingMonitorReferencesResponseEnvelopeResultInfoJSON `json:"-"` -} - -// loadBalancingMonitorReferencesResponseEnvelopeResultInfoJSON contains the JSON -// metadata for the struct -// [LoadBalancingMonitorReferencesResponseEnvelopeResultInfo] -type loadBalancingMonitorReferencesResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancingMonitorReferencesResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancingMonitorReferencesResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} diff --git a/user/loadbalancingmonitor_test.go b/user/loadbalancingmonitor_test.go deleted file mode 100644 index 54ef6170d80..00000000000 --- a/user/loadbalancingmonitor_test.go +++ /dev/null @@ -1,321 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -package user_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go/v2" - "github.com/cloudflare/cloudflare-go/v2/internal/testutil" - "github.com/cloudflare/cloudflare-go/v2/option" - "github.com/cloudflare/cloudflare-go/v2/user" -) - -func TestLoadBalancingMonitorNewWithOptionalParams(t *testing.T) { - t.Skip("skipped: tests are disabled for the time being") - baseURL := "http://localhost:4010" - if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { - baseURL = envURL - } - if !testutil.CheckTestServer(t, baseURL) { - return - } - client := cloudflare.NewClient( - option.WithBaseURL(baseURL), - option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), - option.WithAPIEmail("user@example.com"), - ) - _, err := client.User.LoadBalancing.Monitors.New(context.TODO(), user.LoadBalancingMonitorNewParams{ - ExpectedCodes: cloudflare.F("2xx"), - AllowInsecure: cloudflare.F(true), - ConsecutiveDown: cloudflare.F(int64(0)), - ConsecutiveUp: cloudflare.F(int64(0)), - Description: cloudflare.F("Login page monitor"), - ExpectedBody: cloudflare.F("alive"), - FollowRedirects: cloudflare.F(true), - Header: cloudflare.F[any](map[string]interface{}{ - "Host": map[string]interface{}{ - "0": "example.com", - }, - "X-App-ID": map[string]interface{}{ - "0": "abc123", - }, - }), - Interval: cloudflare.F(int64(0)), - Method: cloudflare.F("GET"), - Path: cloudflare.F("/health"), - Port: cloudflare.F(int64(0)), - ProbeZone: cloudflare.F("example.com"), - Retries: cloudflare.F(int64(0)), - Timeout: cloudflare.F(int64(0)), - Type: cloudflare.F(user.LoadBalancingMonitorNewParamsTypeHTTPS), - }) - if err != nil { - var apierr *cloudflare.Error - if errors.As(err, &apierr) { - t.Log(string(apierr.DumpRequest(true))) - } - t.Fatalf("err should be nil: %s", err.Error()) - } -} - -func TestLoadBalancingMonitorUpdateWithOptionalParams(t *testing.T) { - t.Skip("skipped: tests are disabled for the time being") - baseURL := "http://localhost:4010" - if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { - baseURL = envURL - } - if !testutil.CheckTestServer(t, baseURL) { - return - } - client := cloudflare.NewClient( - option.WithBaseURL(baseURL), - option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), - option.WithAPIEmail("user@example.com"), - ) - _, err := client.User.LoadBalancing.Monitors.Update( - context.TODO(), - "f1aba936b94213e5b8dca0c0dbf1f9cc", - user.LoadBalancingMonitorUpdateParams{ - ExpectedCodes: cloudflare.F("2xx"), - AllowInsecure: cloudflare.F(true), - ConsecutiveDown: cloudflare.F(int64(0)), - ConsecutiveUp: cloudflare.F(int64(0)), - Description: cloudflare.F("Login page monitor"), - ExpectedBody: cloudflare.F("alive"), - FollowRedirects: cloudflare.F(true), - Header: cloudflare.F[any](map[string]interface{}{ - "Host": map[string]interface{}{ - "0": "example.com", - }, - "X-App-ID": map[string]interface{}{ - "0": "abc123", - }, - }), - Interval: cloudflare.F(int64(0)), - Method: cloudflare.F("GET"), - Path: cloudflare.F("/health"), - Port: cloudflare.F(int64(0)), - ProbeZone: cloudflare.F("example.com"), - Retries: cloudflare.F(int64(0)), - Timeout: cloudflare.F(int64(0)), - Type: cloudflare.F(user.LoadBalancingMonitorUpdateParamsTypeHTTPS), - }, - ) - if err != nil { - var apierr *cloudflare.Error - if errors.As(err, &apierr) { - t.Log(string(apierr.DumpRequest(true))) - } - t.Fatalf("err should be nil: %s", err.Error()) - } -} - -func TestLoadBalancingMonitorList(t *testing.T) { - t.Skip("skipped: tests are disabled for the time being") - baseURL := "http://localhost:4010" - if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { - baseURL = envURL - } - if !testutil.CheckTestServer(t, baseURL) { - return - } - client := cloudflare.NewClient( - option.WithBaseURL(baseURL), - option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), - option.WithAPIEmail("user@example.com"), - ) - _, err := client.User.LoadBalancing.Monitors.List(context.TODO()) - if err != nil { - var apierr *cloudflare.Error - if errors.As(err, &apierr) { - t.Log(string(apierr.DumpRequest(true))) - } - t.Fatalf("err should be nil: %s", err.Error()) - } -} - -func TestLoadBalancingMonitorDelete(t *testing.T) { - t.Skip("skipped: tests are disabled for the time being") - baseURL := "http://localhost:4010" - if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { - baseURL = envURL - } - if !testutil.CheckTestServer(t, baseURL) { - return - } - client := cloudflare.NewClient( - option.WithBaseURL(baseURL), - option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), - option.WithAPIEmail("user@example.com"), - ) - _, err := client.User.LoadBalancing.Monitors.Delete( - context.TODO(), - "f1aba936b94213e5b8dca0c0dbf1f9cc", - user.LoadBalancingMonitorDeleteParams{ - Body: cloudflare.F[any](map[string]interface{}{}), - }, - ) - if err != nil { - var apierr *cloudflare.Error - if errors.As(err, &apierr) { - t.Log(string(apierr.DumpRequest(true))) - } - t.Fatalf("err should be nil: %s", err.Error()) - } -} - -func TestLoadBalancingMonitorEditWithOptionalParams(t *testing.T) { - t.Skip("skipped: tests are disabled for the time being") - baseURL := "http://localhost:4010" - if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { - baseURL = envURL - } - if !testutil.CheckTestServer(t, baseURL) { - return - } - client := cloudflare.NewClient( - option.WithBaseURL(baseURL), - option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), - option.WithAPIEmail("user@example.com"), - ) - _, err := client.User.LoadBalancing.Monitors.Edit( - context.TODO(), - "f1aba936b94213e5b8dca0c0dbf1f9cc", - user.LoadBalancingMonitorEditParams{ - ExpectedCodes: cloudflare.F("2xx"), - AllowInsecure: cloudflare.F(true), - ConsecutiveDown: cloudflare.F(int64(0)), - ConsecutiveUp: cloudflare.F(int64(0)), - Description: cloudflare.F("Login page monitor"), - ExpectedBody: cloudflare.F("alive"), - FollowRedirects: cloudflare.F(true), - Header: cloudflare.F[any](map[string]interface{}{ - "Host": map[string]interface{}{ - "0": "example.com", - }, - "X-App-ID": map[string]interface{}{ - "0": "abc123", - }, - }), - Interval: cloudflare.F(int64(0)), - Method: cloudflare.F("GET"), - Path: cloudflare.F("/health"), - Port: cloudflare.F(int64(0)), - ProbeZone: cloudflare.F("example.com"), - Retries: cloudflare.F(int64(0)), - Timeout: cloudflare.F(int64(0)), - Type: cloudflare.F(user.LoadBalancingMonitorEditParamsTypeHTTPS), - }, - ) - if err != nil { - var apierr *cloudflare.Error - if errors.As(err, &apierr) { - t.Log(string(apierr.DumpRequest(true))) - } - t.Fatalf("err should be nil: %s", err.Error()) - } -} - -func TestLoadBalancingMonitorGet(t *testing.T) { - t.Skip("skipped: tests are disabled for the time being") - baseURL := "http://localhost:4010" - if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { - baseURL = envURL - } - if !testutil.CheckTestServer(t, baseURL) { - return - } - client := cloudflare.NewClient( - option.WithBaseURL(baseURL), - option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), - option.WithAPIEmail("user@example.com"), - ) - _, err := client.User.LoadBalancing.Monitors.Get(context.TODO(), "f1aba936b94213e5b8dca0c0dbf1f9cc") - if err != nil { - var apierr *cloudflare.Error - if errors.As(err, &apierr) { - t.Log(string(apierr.DumpRequest(true))) - } - t.Fatalf("err should be nil: %s", err.Error()) - } -} - -func TestLoadBalancingMonitorPreviewWithOptionalParams(t *testing.T) { - t.Skip("skipped: tests are disabled for the time being") - baseURL := "http://localhost:4010" - if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { - baseURL = envURL - } - if !testutil.CheckTestServer(t, baseURL) { - return - } - client := cloudflare.NewClient( - option.WithBaseURL(baseURL), - option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), - option.WithAPIEmail("user@example.com"), - ) - _, err := client.User.LoadBalancing.Monitors.Preview( - context.TODO(), - "f1aba936b94213e5b8dca0c0dbf1f9cc", - user.LoadBalancingMonitorPreviewParams{ - ExpectedCodes: cloudflare.F("2xx"), - AllowInsecure: cloudflare.F(true), - ConsecutiveDown: cloudflare.F(int64(0)), - ConsecutiveUp: cloudflare.F(int64(0)), - Description: cloudflare.F("Login page monitor"), - ExpectedBody: cloudflare.F("alive"), - FollowRedirects: cloudflare.F(true), - Header: cloudflare.F[any](map[string]interface{}{ - "Host": map[string]interface{}{ - "0": "example.com", - }, - "X-App-ID": map[string]interface{}{ - "0": "abc123", - }, - }), - Interval: cloudflare.F(int64(0)), - Method: cloudflare.F("GET"), - Path: cloudflare.F("/health"), - Port: cloudflare.F(int64(0)), - ProbeZone: cloudflare.F("example.com"), - Retries: cloudflare.F(int64(0)), - Timeout: cloudflare.F(int64(0)), - Type: cloudflare.F(user.LoadBalancingMonitorPreviewParamsTypeHTTPS), - }, - ) - if err != nil { - var apierr *cloudflare.Error - if errors.As(err, &apierr) { - t.Log(string(apierr.DumpRequest(true))) - } - t.Fatalf("err should be nil: %s", err.Error()) - } -} - -func TestLoadBalancingMonitorReferences(t *testing.T) { - t.Skip("skipped: tests are disabled for the time being") - baseURL := "http://localhost:4010" - if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { - baseURL = envURL - } - if !testutil.CheckTestServer(t, baseURL) { - return - } - client := cloudflare.NewClient( - option.WithBaseURL(baseURL), - option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), - option.WithAPIEmail("user@example.com"), - ) - _, err := client.User.LoadBalancing.Monitors.References(context.TODO(), "f1aba936b94213e5b8dca0c0dbf1f9cc") - if err != nil { - var apierr *cloudflare.Error - if errors.As(err, &apierr) { - t.Log(string(apierr.DumpRequest(true))) - } - t.Fatalf("err should be nil: %s", err.Error()) - } -} diff --git a/user/loadbalancingpool.go b/user/loadbalancingpool.go deleted file mode 100644 index aba82930f68..00000000000 --- a/user/loadbalancingpool.go +++ /dev/null @@ -1,902 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -package user - -import ( - "context" - "fmt" - "net/http" - "net/url" - "reflect" - - "github.com/cloudflare/cloudflare-go/v2/internal/apijson" - "github.com/cloudflare/cloudflare-go/v2/internal/apiquery" - "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/internal/shared" - "github.com/cloudflare/cloudflare-go/v2/load_balancers" - "github.com/cloudflare/cloudflare-go/v2/option" - "github.com/tidwall/gjson" -) - -// LoadBalancingPoolService contains methods and other services that help with -// interacting with the cloudflare API. Note, unlike clients, this service does not -// read variables from the environment automatically. You should not instantiate -// this service directly, and instead use the [NewLoadBalancingPoolService] method -// instead. -type LoadBalancingPoolService struct { - Options []option.RequestOption -} - -// NewLoadBalancingPoolService generates a new service that applies the given -// options to each request. These options are applied after the parent client's -// options (if there is one), and before any request-specific options. -func NewLoadBalancingPoolService(opts ...option.RequestOption) (r *LoadBalancingPoolService) { - r = &LoadBalancingPoolService{} - r.Options = opts - return -} - -// Create a new pool. -func (r *LoadBalancingPoolService) New(ctx context.Context, body LoadBalancingPoolNewParams, opts ...option.RequestOption) (res *load_balancers.Pool, err error) { - opts = append(r.Options[:], opts...) - var env LoadBalancingPoolNewResponseEnvelope - path := "user/load_balancers/pools" - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Modify a configured pool. -func (r *LoadBalancingPoolService) Update(ctx context.Context, poolID string, body LoadBalancingPoolUpdateParams, opts ...option.RequestOption) (res *load_balancers.Pool, err error) { - opts = append(r.Options[:], opts...) - var env LoadBalancingPoolUpdateResponseEnvelope - path := fmt.Sprintf("user/load_balancers/pools/%s", poolID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPut, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// List configured pools. -func (r *LoadBalancingPoolService) List(ctx context.Context, query LoadBalancingPoolListParams, opts ...option.RequestOption) (res *pagination.SinglePage[load_balancers.Pool], err error) { - var raw *http.Response - opts = append(r.Options, opts...) - opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) - path := "user/load_balancers/pools" - cfg, err := requestconfig.NewRequestConfig(ctx, http.MethodGet, path, query, &res, opts...) - if err != nil { - return nil, err - } - err = cfg.Execute() - if err != nil { - return nil, err - } - res.SetPageConfig(cfg, raw) - return res, nil -} - -// List configured pools. -func (r *LoadBalancingPoolService) ListAutoPaging(ctx context.Context, query LoadBalancingPoolListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[load_balancers.Pool] { - return pagination.NewSinglePageAutoPager(r.List(ctx, query, opts...)) -} - -// Delete a configured pool. -func (r *LoadBalancingPoolService) Delete(ctx context.Context, poolID string, body LoadBalancingPoolDeleteParams, opts ...option.RequestOption) (res *LoadBalancingPoolDeleteResponse, err error) { - opts = append(r.Options[:], opts...) - var env LoadBalancingPoolDeleteResponseEnvelope - path := fmt.Sprintf("user/load_balancers/pools/%s", poolID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodDelete, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Apply changes to an existing pool, overwriting the supplied properties. -func (r *LoadBalancingPoolService) Edit(ctx context.Context, poolID string, body LoadBalancingPoolEditParams, opts ...option.RequestOption) (res *load_balancers.Pool, err error) { - opts = append(r.Options[:], opts...) - var env LoadBalancingPoolEditResponseEnvelope - path := fmt.Sprintf("user/load_balancers/pools/%s", poolID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPatch, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetch a single configured pool. -func (r *LoadBalancingPoolService) Get(ctx context.Context, poolID string, opts ...option.RequestOption) (res *load_balancers.Pool, err error) { - opts = append(r.Options[:], opts...) - var env LoadBalancingPoolGetResponseEnvelope - path := fmt.Sprintf("user/load_balancers/pools/%s", poolID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Fetch the latest pool health status for a single pool. -func (r *LoadBalancingPoolService) Health(ctx context.Context, poolID string, opts ...option.RequestOption) (res *LoadBalancingPoolHealthResponseUnion, err error) { - opts = append(r.Options[:], opts...) - var env LoadBalancingPoolHealthResponseEnvelope - path := fmt.Sprintf("user/load_balancers/pools/%s/health", poolID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Preview pool health using provided monitor details. The returned preview_id can -// be used in the preview endpoint to retrieve the results. -func (r *LoadBalancingPoolService) Preview(ctx context.Context, poolID string, body LoadBalancingPoolPreviewParams, opts ...option.RequestOption) (res *LoadBalancingPoolPreviewResponse, err error) { - opts = append(r.Options[:], opts...) - var env LoadBalancingPoolPreviewResponseEnvelope - path := fmt.Sprintf("user/load_balancers/pools/%s/preview", poolID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodPost, path, body, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -// Get the list of resources that reference the provided pool. -func (r *LoadBalancingPoolService) References(ctx context.Context, poolID string, opts ...option.RequestOption) (res *[]LoadBalancingPoolReferencesResponse, err error) { - opts = append(r.Options[:], opts...) - var env LoadBalancingPoolReferencesResponseEnvelope - path := fmt.Sprintf("user/load_balancers/pools/%s/references", poolID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type LoadBalancingPoolDeleteResponse struct { - ID string `json:"id"` - JSON loadBalancingPoolDeleteResponseJSON `json:"-"` -} - -// loadBalancingPoolDeleteResponseJSON contains the JSON metadata for the struct -// [LoadBalancingPoolDeleteResponse] -type loadBalancingPoolDeleteResponseJSON struct { - ID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancingPoolDeleteResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancingPoolDeleteResponseJSON) RawJSON() string { - return r.raw -} - -// A list of regions from which to run health checks. Null means every Cloudflare -// data center. -// -// Union satisfied by [user.LoadBalancingPoolHealthResponseUnknown] or -// [shared.UnionString]. -type LoadBalancingPoolHealthResponseUnion interface { - ImplementsUserLoadBalancingPoolHealthResponseUnion() -} - -func init() { - apijson.RegisterUnion( - reflect.TypeOf((*LoadBalancingPoolHealthResponseUnion)(nil)).Elem(), - "", - apijson.UnionVariant{ - TypeFilter: gjson.String, - Type: reflect.TypeOf(shared.UnionString("")), - }, - ) -} - -type LoadBalancingPoolPreviewResponse struct { - // Monitored pool IDs mapped to their respective names. - Pools map[string]string `json:"pools"` - PreviewID string `json:"preview_id"` - JSON loadBalancingPoolPreviewResponseJSON `json:"-"` -} - -// loadBalancingPoolPreviewResponseJSON contains the JSON metadata for the struct -// [LoadBalancingPoolPreviewResponse] -type loadBalancingPoolPreviewResponseJSON struct { - Pools apijson.Field - PreviewID apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancingPoolPreviewResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancingPoolPreviewResponseJSON) RawJSON() string { - return r.raw -} - -type LoadBalancingPoolReferencesResponse struct { - ReferenceType LoadBalancingPoolReferencesResponseReferenceType `json:"reference_type"` - ResourceID string `json:"resource_id"` - ResourceName string `json:"resource_name"` - ResourceType string `json:"resource_type"` - JSON loadBalancingPoolReferencesResponseJSON `json:"-"` -} - -// loadBalancingPoolReferencesResponseJSON contains the JSON metadata for the -// struct [LoadBalancingPoolReferencesResponse] -type loadBalancingPoolReferencesResponseJSON struct { - ReferenceType apijson.Field - ResourceID apijson.Field - ResourceName apijson.Field - ResourceType apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancingPoolReferencesResponse) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancingPoolReferencesResponseJSON) RawJSON() string { - return r.raw -} - -type LoadBalancingPoolReferencesResponseReferenceType string - -const ( - LoadBalancingPoolReferencesResponseReferenceTypeStar LoadBalancingPoolReferencesResponseReferenceType = "*" - LoadBalancingPoolReferencesResponseReferenceTypeReferral LoadBalancingPoolReferencesResponseReferenceType = "referral" - LoadBalancingPoolReferencesResponseReferenceTypeReferrer LoadBalancingPoolReferencesResponseReferenceType = "referrer" -) - -func (r LoadBalancingPoolReferencesResponseReferenceType) IsKnown() bool { - switch r { - case LoadBalancingPoolReferencesResponseReferenceTypeStar, LoadBalancingPoolReferencesResponseReferenceTypeReferral, LoadBalancingPoolReferencesResponseReferenceTypeReferrer: - return true - } - return false -} - -type LoadBalancingPoolNewParams struct { - // A short name (tag) for the pool. Only alphanumeric characters, hyphens, and - // underscores are allowed. - 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[[]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[[]load_balancers.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 - // receive traffic and are excluded from health checks. Disabling a pool will cause - // any load balancers using it to failover to the next pool (if any). - Enabled param.Field[bool] `json:"enabled"` - // The latitude of the data center containing the origins used in this pool in - // 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[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"` - // The minimum number of origins that must be healthy for this pool to serve - // traffic. If the number of healthy origins falls below this number, the pool will - // be marked unhealthy and will failover to the next available pool. - MinimumOrigins param.Field[int64] `json:"minimum_origins"` - // The ID of the Monitor to use for checking the health of origins within this - // pool. - Monitor param.Field[interface{}] `json:"monitor"` - // This field is now deprecated. It has been moved to Cloudflare's Centralized - // Notification service - // https://developers.cloudflare.com/fundamentals/notifications/. The email address - // to send health status notifications to. This can be an individual mailbox or a - // mailing list. Multiple emails can be supplied as a comma delimited list. - 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[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[load_balancers.OriginSteeringParam] `json:"origin_steering"` -} - -func (r LoadBalancingPoolNewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type LoadBalancingPoolNewResponseEnvelope struct { - Errors []shared.ResponseInfo `json:"errors,required"` - Messages []shared.ResponseInfo `json:"messages,required"` - Result load_balancers.Pool `json:"result,required"` - // Whether the API call was successful - Success LoadBalancingPoolNewResponseEnvelopeSuccess `json:"success,required"` - JSON loadBalancingPoolNewResponseEnvelopeJSON `json:"-"` -} - -// loadBalancingPoolNewResponseEnvelopeJSON contains the JSON metadata for the -// struct [LoadBalancingPoolNewResponseEnvelope] -type loadBalancingPoolNewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancingPoolNewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancingPoolNewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LoadBalancingPoolNewResponseEnvelopeSuccess bool - -const ( - LoadBalancingPoolNewResponseEnvelopeSuccessTrue LoadBalancingPoolNewResponseEnvelopeSuccess = true -) - -func (r LoadBalancingPoolNewResponseEnvelopeSuccess) IsKnown() bool { - switch r { - case LoadBalancingPoolNewResponseEnvelopeSuccessTrue: - return true - } - return false -} - -type LoadBalancingPoolUpdateParams struct { - // A short name (tag) for the pool. Only alphanumeric characters, hyphens, and - // underscores are allowed. - 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[[]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[[]load_balancers.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 - // receive traffic and are excluded from health checks. Disabling a pool will cause - // any load balancers using it to failover to the next pool (if any). - Enabled param.Field[bool] `json:"enabled"` - // The latitude of the data center containing the origins used in this pool in - // 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[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"` - // The minimum number of origins that must be healthy for this pool to serve - // traffic. If the number of healthy origins falls below this number, the pool will - // be marked unhealthy and will failover to the next available pool. - MinimumOrigins param.Field[int64] `json:"minimum_origins"` - // The ID of the Monitor to use for checking the health of origins within this - // pool. - Monitor param.Field[interface{}] `json:"monitor"` - // This field is now deprecated. It has been moved to Cloudflare's Centralized - // Notification service - // https://developers.cloudflare.com/fundamentals/notifications/. The email address - // to send health status notifications to. This can be an individual mailbox or a - // mailing list. Multiple emails can be supplied as a comma delimited list. - 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[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[load_balancers.OriginSteeringParam] `json:"origin_steering"` -} - -func (r LoadBalancingPoolUpdateParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type LoadBalancingPoolUpdateResponseEnvelope struct { - Errors []shared.ResponseInfo `json:"errors,required"` - Messages []shared.ResponseInfo `json:"messages,required"` - Result load_balancers.Pool `json:"result,required"` - // Whether the API call was successful - Success LoadBalancingPoolUpdateResponseEnvelopeSuccess `json:"success,required"` - JSON loadBalancingPoolUpdateResponseEnvelopeJSON `json:"-"` -} - -// loadBalancingPoolUpdateResponseEnvelopeJSON contains the JSON metadata for the -// struct [LoadBalancingPoolUpdateResponseEnvelope] -type loadBalancingPoolUpdateResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancingPoolUpdateResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancingPoolUpdateResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LoadBalancingPoolUpdateResponseEnvelopeSuccess bool - -const ( - LoadBalancingPoolUpdateResponseEnvelopeSuccessTrue LoadBalancingPoolUpdateResponseEnvelopeSuccess = true -) - -func (r LoadBalancingPoolUpdateResponseEnvelopeSuccess) IsKnown() bool { - switch r { - case LoadBalancingPoolUpdateResponseEnvelopeSuccessTrue: - return true - } - return false -} - -type LoadBalancingPoolListParams struct { - // The ID of the Monitor to use for checking the health of origins within this - // pool. - Monitor param.Field[interface{}] `query:"monitor"` -} - -// URLQuery serializes [LoadBalancingPoolListParams]'s query parameters as -// `url.Values`. -func (r LoadBalancingPoolListParams) URLQuery() (v url.Values) { - return apiquery.MarshalWithSettings(r, apiquery.QuerySettings{ - ArrayFormat: apiquery.ArrayQueryFormatRepeat, - NestedFormat: apiquery.NestedQueryFormatBrackets, - }) -} - -type LoadBalancingPoolDeleteParams struct { - Body param.Field[interface{}] `json:"body,required"` -} - -func (r LoadBalancingPoolDeleteParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r.Body) -} - -type LoadBalancingPoolDeleteResponseEnvelope struct { - Errors []shared.ResponseInfo `json:"errors,required"` - Messages []shared.ResponseInfo `json:"messages,required"` - Result LoadBalancingPoolDeleteResponse `json:"result,required"` - // Whether the API call was successful - Success LoadBalancingPoolDeleteResponseEnvelopeSuccess `json:"success,required"` - JSON loadBalancingPoolDeleteResponseEnvelopeJSON `json:"-"` -} - -// loadBalancingPoolDeleteResponseEnvelopeJSON contains the JSON metadata for the -// struct [LoadBalancingPoolDeleteResponseEnvelope] -type loadBalancingPoolDeleteResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancingPoolDeleteResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancingPoolDeleteResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LoadBalancingPoolDeleteResponseEnvelopeSuccess bool - -const ( - LoadBalancingPoolDeleteResponseEnvelopeSuccessTrue LoadBalancingPoolDeleteResponseEnvelopeSuccess = true -) - -func (r LoadBalancingPoolDeleteResponseEnvelopeSuccess) IsKnown() bool { - switch r { - case LoadBalancingPoolDeleteResponseEnvelopeSuccessTrue: - return true - } - return false -} - -type LoadBalancingPoolEditParams struct { - // A list of regions from which to run health checks. Null means every Cloudflare - // data center. - CheckRegions param.Field[[]load_balancers.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 - // receive traffic and are excluded from health checks. Disabling a pool will cause - // any load balancers using it to failover to the next pool (if any). - Enabled param.Field[bool] `json:"enabled"` - // The latitude of the data center containing the origins used in this pool in - // 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[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"` - // The minimum number of origins that must be healthy for this pool to serve - // traffic. If the number of healthy origins falls below this number, the pool will - // be marked unhealthy and will failover to the next available pool. - MinimumOrigins param.Field[int64] `json:"minimum_origins"` - // The ID of the Monitor to use for checking the health of origins within this - // pool. - Monitor param.Field[interface{}] `json:"monitor"` - // A short name (tag) for the pool. Only alphanumeric characters, hyphens, and - // underscores are allowed. - Name param.Field[string] `json:"name"` - // This field is now deprecated. It has been moved to Cloudflare's Centralized - // Notification service - // https://developers.cloudflare.com/fundamentals/notifications/. The email address - // to send health status notifications to. This can be an individual mailbox or a - // mailing list. Multiple emails can be supplied as a comma delimited list. - 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[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[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[[]load_balancers.OriginParam] `json:"origins"` -} - -func (r LoadBalancingPoolEditParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -type LoadBalancingPoolEditResponseEnvelope struct { - Errors []shared.ResponseInfo `json:"errors,required"` - Messages []shared.ResponseInfo `json:"messages,required"` - Result load_balancers.Pool `json:"result,required"` - // Whether the API call was successful - Success LoadBalancingPoolEditResponseEnvelopeSuccess `json:"success,required"` - JSON loadBalancingPoolEditResponseEnvelopeJSON `json:"-"` -} - -// loadBalancingPoolEditResponseEnvelopeJSON contains the JSON metadata for the -// struct [LoadBalancingPoolEditResponseEnvelope] -type loadBalancingPoolEditResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancingPoolEditResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancingPoolEditResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LoadBalancingPoolEditResponseEnvelopeSuccess bool - -const ( - LoadBalancingPoolEditResponseEnvelopeSuccessTrue LoadBalancingPoolEditResponseEnvelopeSuccess = true -) - -func (r LoadBalancingPoolEditResponseEnvelopeSuccess) IsKnown() bool { - switch r { - case LoadBalancingPoolEditResponseEnvelopeSuccessTrue: - return true - } - return false -} - -type LoadBalancingPoolGetResponseEnvelope struct { - Errors []shared.ResponseInfo `json:"errors,required"` - Messages []shared.ResponseInfo `json:"messages,required"` - Result load_balancers.Pool `json:"result,required"` - // Whether the API call was successful - Success LoadBalancingPoolGetResponseEnvelopeSuccess `json:"success,required"` - JSON loadBalancingPoolGetResponseEnvelopeJSON `json:"-"` -} - -// loadBalancingPoolGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [LoadBalancingPoolGetResponseEnvelope] -type loadBalancingPoolGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancingPoolGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancingPoolGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LoadBalancingPoolGetResponseEnvelopeSuccess bool - -const ( - LoadBalancingPoolGetResponseEnvelopeSuccessTrue LoadBalancingPoolGetResponseEnvelopeSuccess = true -) - -func (r LoadBalancingPoolGetResponseEnvelopeSuccess) IsKnown() bool { - switch r { - case LoadBalancingPoolGetResponseEnvelopeSuccessTrue: - return true - } - return false -} - -type LoadBalancingPoolHealthResponseEnvelope struct { - Errors []shared.ResponseInfo `json:"errors,required"` - Messages []shared.ResponseInfo `json:"messages,required"` - // A list of regions from which to run health checks. Null means every Cloudflare - // data center. - Result LoadBalancingPoolHealthResponseUnion `json:"result,required"` - // Whether the API call was successful - Success LoadBalancingPoolHealthResponseEnvelopeSuccess `json:"success,required"` - JSON loadBalancingPoolHealthResponseEnvelopeJSON `json:"-"` -} - -// loadBalancingPoolHealthResponseEnvelopeJSON contains the JSON metadata for the -// struct [LoadBalancingPoolHealthResponseEnvelope] -type loadBalancingPoolHealthResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancingPoolHealthResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancingPoolHealthResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LoadBalancingPoolHealthResponseEnvelopeSuccess bool - -const ( - LoadBalancingPoolHealthResponseEnvelopeSuccessTrue LoadBalancingPoolHealthResponseEnvelopeSuccess = true -) - -func (r LoadBalancingPoolHealthResponseEnvelopeSuccess) IsKnown() bool { - switch r { - case LoadBalancingPoolHealthResponseEnvelopeSuccessTrue: - return true - } - return false -} - -type LoadBalancingPoolPreviewParams struct { - // The expected HTTP response code or code range of the health check. This - // parameter is only valid for HTTP and HTTPS monitors. - ExpectedCodes param.Field[string] `json:"expected_codes,required"` - // Do not validate the certificate when monitor use HTTPS. This parameter is - // currently only valid for HTTP and HTTPS monitors. - AllowInsecure param.Field[bool] `json:"allow_insecure"` - // To be marked unhealthy the monitored origin must fail this healthcheck N - // consecutive times. - ConsecutiveDown param.Field[int64] `json:"consecutive_down"` - // To be marked healthy the monitored origin must pass this healthcheck N - // consecutive times. - ConsecutiveUp param.Field[int64] `json:"consecutive_up"` - // Object description. - Description param.Field[string] `json:"description"` - // A case-insensitive sub-string to look for in the response body. If this string - // is not found, the origin will be marked as unhealthy. This parameter is only - // valid for HTTP and HTTPS monitors. - ExpectedBody param.Field[string] `json:"expected_body"` - // Follow redirects if returned by the origin. This parameter is only valid for - // HTTP and HTTPS monitors. - FollowRedirects param.Field[bool] `json:"follow_redirects"` - // The HTTP request headers to send in the health check. It is recommended you set - // a Host header by default. The User-Agent header cannot be overridden. This - // parameter is only valid for HTTP and HTTPS monitors. - Header param.Field[interface{}] `json:"header"` - // The interval between each health check. Shorter intervals may improve failover - // time, but will increase load on the origins as we check from multiple locations. - Interval param.Field[int64] `json:"interval"` - // The method to use for the health check. This defaults to 'GET' for HTTP/HTTPS - // based checks and 'connection_established' for TCP based health checks. - Method param.Field[string] `json:"method"` - // The endpoint path you want to conduct a health check against. This parameter is - // only valid for HTTP and HTTPS monitors. - Path param.Field[string] `json:"path"` - // The port number to connect to for the health check. Required for TCP, UDP, and - // SMTP checks. HTTP and HTTPS checks should only define the port when using a - // non-standard port (HTTP: default 80, HTTPS: default 443). - Port param.Field[int64] `json:"port"` - // Assign this monitor to emulate the specified zone while probing. This parameter - // is only valid for HTTP and HTTPS monitors. - ProbeZone param.Field[string] `json:"probe_zone"` - // The number of retries to attempt in case of a timeout before marking the origin - // as unhealthy. Retries are attempted immediately. - Retries param.Field[int64] `json:"retries"` - // The timeout (in seconds) before marking the health check as failed. - Timeout param.Field[int64] `json:"timeout"` - // The protocol to use for the health check. Currently supported protocols are - // 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. - Type param.Field[LoadBalancingPoolPreviewParamsType] `json:"type"` -} - -func (r LoadBalancingPoolPreviewParams) MarshalJSON() (data []byte, err error) { - return apijson.MarshalRoot(r) -} - -// The protocol to use for the health check. Currently supported protocols are -// 'HTTP','HTTPS', 'TCP', 'ICMP-PING', 'UDP-ICMP', and 'SMTP'. -type LoadBalancingPoolPreviewParamsType string - -const ( - LoadBalancingPoolPreviewParamsTypeHTTP LoadBalancingPoolPreviewParamsType = "http" - LoadBalancingPoolPreviewParamsTypeHTTPS LoadBalancingPoolPreviewParamsType = "https" - LoadBalancingPoolPreviewParamsTypeTCP LoadBalancingPoolPreviewParamsType = "tcp" - LoadBalancingPoolPreviewParamsTypeUdpIcmp LoadBalancingPoolPreviewParamsType = "udp_icmp" - LoadBalancingPoolPreviewParamsTypeIcmpPing LoadBalancingPoolPreviewParamsType = "icmp_ping" - LoadBalancingPoolPreviewParamsTypeSmtp LoadBalancingPoolPreviewParamsType = "smtp" -) - -func (r LoadBalancingPoolPreviewParamsType) IsKnown() bool { - switch r { - case LoadBalancingPoolPreviewParamsTypeHTTP, LoadBalancingPoolPreviewParamsTypeHTTPS, LoadBalancingPoolPreviewParamsTypeTCP, LoadBalancingPoolPreviewParamsTypeUdpIcmp, LoadBalancingPoolPreviewParamsTypeIcmpPing, LoadBalancingPoolPreviewParamsTypeSmtp: - return true - } - return false -} - -type LoadBalancingPoolPreviewResponseEnvelope struct { - Errors []shared.ResponseInfo `json:"errors,required"` - Messages []shared.ResponseInfo `json:"messages,required"` - Result LoadBalancingPoolPreviewResponse `json:"result,required"` - // Whether the API call was successful - Success LoadBalancingPoolPreviewResponseEnvelopeSuccess `json:"success,required"` - JSON loadBalancingPoolPreviewResponseEnvelopeJSON `json:"-"` -} - -// loadBalancingPoolPreviewResponseEnvelopeJSON contains the JSON metadata for the -// struct [LoadBalancingPoolPreviewResponseEnvelope] -type loadBalancingPoolPreviewResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancingPoolPreviewResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancingPoolPreviewResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LoadBalancingPoolPreviewResponseEnvelopeSuccess bool - -const ( - LoadBalancingPoolPreviewResponseEnvelopeSuccessTrue LoadBalancingPoolPreviewResponseEnvelopeSuccess = true -) - -func (r LoadBalancingPoolPreviewResponseEnvelopeSuccess) IsKnown() bool { - switch r { - case LoadBalancingPoolPreviewResponseEnvelopeSuccessTrue: - return true - } - return false -} - -type LoadBalancingPoolReferencesResponseEnvelope struct { - Errors []shared.ResponseInfo `json:"errors,required"` - Messages []shared.ResponseInfo `json:"messages,required"` - // List of resources that reference a given pool. - Result []LoadBalancingPoolReferencesResponse `json:"result,required,nullable"` - // Whether the API call was successful - Success LoadBalancingPoolReferencesResponseEnvelopeSuccess `json:"success,required"` - ResultInfo LoadBalancingPoolReferencesResponseEnvelopeResultInfo `json:"result_info"` - JSON loadBalancingPoolReferencesResponseEnvelopeJSON `json:"-"` -} - -// loadBalancingPoolReferencesResponseEnvelopeJSON contains the JSON metadata for -// the struct [LoadBalancingPoolReferencesResponseEnvelope] -type loadBalancingPoolReferencesResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - ResultInfo apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancingPoolReferencesResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancingPoolReferencesResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LoadBalancingPoolReferencesResponseEnvelopeSuccess bool - -const ( - LoadBalancingPoolReferencesResponseEnvelopeSuccessTrue LoadBalancingPoolReferencesResponseEnvelopeSuccess = true -) - -func (r LoadBalancingPoolReferencesResponseEnvelopeSuccess) IsKnown() bool { - switch r { - case LoadBalancingPoolReferencesResponseEnvelopeSuccessTrue: - return true - } - return false -} - -type LoadBalancingPoolReferencesResponseEnvelopeResultInfo struct { - // Total number of results for the requested service - Count float64 `json:"count"` - // Current page within paginated list of results - Page float64 `json:"page"` - // Number of results per page of results - PerPage float64 `json:"per_page"` - // Total results available without any search parameters - TotalCount float64 `json:"total_count"` - JSON loadBalancingPoolReferencesResponseEnvelopeResultInfoJSON `json:"-"` -} - -// loadBalancingPoolReferencesResponseEnvelopeResultInfoJSON contains the JSON -// metadata for the struct [LoadBalancingPoolReferencesResponseEnvelopeResultInfo] -type loadBalancingPoolReferencesResponseEnvelopeResultInfoJSON struct { - Count apijson.Field - Page apijson.Field - PerPage apijson.Field - TotalCount apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancingPoolReferencesResponseEnvelopeResultInfo) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancingPoolReferencesResponseEnvelopeResultInfoJSON) RawJSON() string { - return r.raw -} diff --git a/user/loadbalancingpool_test.go b/user/loadbalancingpool_test.go deleted file mode 100644 index 49ea1d441c2..00000000000 --- a/user/loadbalancingpool_test.go +++ /dev/null @@ -1,447 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -package user_test - -import ( - "context" - "errors" - "os" - "testing" - - "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" -) - -func TestLoadBalancingPoolNewWithOptionalParams(t *testing.T) { - t.Skip("skipped: tests are disabled for the time being") - baseURL := "http://localhost:4010" - if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { - baseURL = envURL - } - if !testutil.CheckTestServer(t, baseURL) { - return - } - client := cloudflare.NewClient( - option.WithBaseURL(baseURL), - option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), - option.WithAPIEmail("user@example.com"), - ) - _, err := client.User.LoadBalancing.Pools.New(context.TODO(), user.LoadBalancingPoolNewParams{ - Name: cloudflare.F("primary-dc-1"), - Origins: cloudflare.F([]load_balancers.OriginParam{{ - Address: cloudflare.F("0.0.0.0"), - Enabled: cloudflare.F(true), - 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), - }, { - Address: cloudflare.F("0.0.0.0"), - Enabled: cloudflare.F(true), - 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), - }, { - Address: cloudflare.F("0.0.0.0"), - Enabled: cloudflare.F(true), - 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.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.LoadSheddingParam{ - DefaultPercent: cloudflare.F(0.000000), - DefaultPolicy: cloudflare.F(load_balancers.LoadSheddingDefaultPolicyRandom), - SessionPercent: cloudflare.F(0.000000), - 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.NotificationFilterParam{ - Origin: cloudflare.F(load_balancers.FilterOptionsParam{ - Disable: cloudflare.F(true), - Healthy: cloudflare.F(true), - }), - Pool: cloudflare.F(load_balancers.FilterOptionsParam{ - Disable: cloudflare.F(true), - Healthy: cloudflare.F(false), - }), - }), - OriginSteering: cloudflare.F(load_balancers.OriginSteeringParam{ - Policy: cloudflare.F(load_balancers.OriginSteeringPolicyRandom), - }), - }) - if err != nil { - var apierr *cloudflare.Error - if errors.As(err, &apierr) { - t.Log(string(apierr.DumpRequest(true))) - } - t.Fatalf("err should be nil: %s", err.Error()) - } -} - -func TestLoadBalancingPoolUpdateWithOptionalParams(t *testing.T) { - t.Skip("skipped: tests are disabled for the time being") - baseURL := "http://localhost:4010" - if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { - baseURL = envURL - } - if !testutil.CheckTestServer(t, baseURL) { - return - } - client := cloudflare.NewClient( - option.WithBaseURL(baseURL), - option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), - option.WithAPIEmail("user@example.com"), - ) - _, err := client.User.LoadBalancing.Pools.Update( - context.TODO(), - "17b5962d775c646f3f9725cbc7a53df4", - user.LoadBalancingPoolUpdateParams{ - Name: cloudflare.F("primary-dc-1"), - Origins: cloudflare.F([]load_balancers.OriginParam{{ - Address: cloudflare.F("0.0.0.0"), - Enabled: cloudflare.F(true), - 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), - }, { - Address: cloudflare.F("0.0.0.0"), - Enabled: cloudflare.F(true), - 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), - }, { - Address: cloudflare.F("0.0.0.0"), - Enabled: cloudflare.F(true), - 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.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.LoadSheddingParam{ - DefaultPercent: cloudflare.F(0.000000), - DefaultPolicy: cloudflare.F(load_balancers.LoadSheddingDefaultPolicyRandom), - SessionPercent: cloudflare.F(0.000000), - 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.NotificationFilterParam{ - Origin: cloudflare.F(load_balancers.FilterOptionsParam{ - Disable: cloudflare.F(true), - Healthy: cloudflare.F(true), - }), - Pool: cloudflare.F(load_balancers.FilterOptionsParam{ - Disable: cloudflare.F(true), - Healthy: cloudflare.F(false), - }), - }), - OriginSteering: cloudflare.F(load_balancers.OriginSteeringParam{ - Policy: cloudflare.F(load_balancers.OriginSteeringPolicyRandom), - }), - }, - ) - if err != nil { - var apierr *cloudflare.Error - if errors.As(err, &apierr) { - t.Log(string(apierr.DumpRequest(true))) - } - t.Fatalf("err should be nil: %s", err.Error()) - } -} - -func TestLoadBalancingPoolListWithOptionalParams(t *testing.T) { - t.Skip("skipped: tests are disabled for the time being") - baseURL := "http://localhost:4010" - if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { - baseURL = envURL - } - if !testutil.CheckTestServer(t, baseURL) { - return - } - client := cloudflare.NewClient( - option.WithBaseURL(baseURL), - option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), - option.WithAPIEmail("user@example.com"), - ) - _, err := client.User.LoadBalancing.Pools.List(context.TODO(), user.LoadBalancingPoolListParams{ - Monitor: cloudflare.F[any](map[string]interface{}{}), - }) - if err != nil { - var apierr *cloudflare.Error - if errors.As(err, &apierr) { - t.Log(string(apierr.DumpRequest(true))) - } - t.Fatalf("err should be nil: %s", err.Error()) - } -} - -func TestLoadBalancingPoolDelete(t *testing.T) { - t.Skip("skipped: tests are disabled for the time being") - baseURL := "http://localhost:4010" - if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { - baseURL = envURL - } - if !testutil.CheckTestServer(t, baseURL) { - return - } - client := cloudflare.NewClient( - option.WithBaseURL(baseURL), - option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), - option.WithAPIEmail("user@example.com"), - ) - _, err := client.User.LoadBalancing.Pools.Delete( - context.TODO(), - "17b5962d775c646f3f9725cbc7a53df4", - user.LoadBalancingPoolDeleteParams{ - Body: cloudflare.F[any](map[string]interface{}{}), - }, - ) - if err != nil { - var apierr *cloudflare.Error - if errors.As(err, &apierr) { - t.Log(string(apierr.DumpRequest(true))) - } - t.Fatalf("err should be nil: %s", err.Error()) - } -} - -func TestLoadBalancingPoolEditWithOptionalParams(t *testing.T) { - t.Skip("skipped: tests are disabled for the time being") - baseURL := "http://localhost:4010" - if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { - baseURL = envURL - } - if !testutil.CheckTestServer(t, baseURL) { - return - } - client := cloudflare.NewClient( - option.WithBaseURL(baseURL), - option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), - option.WithAPIEmail("user@example.com"), - ) - _, err := client.User.LoadBalancing.Pools.Edit( - context.TODO(), - "17b5962d775c646f3f9725cbc7a53df4", - user.LoadBalancingPoolEditParams{ - 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.LoadSheddingParam{ - DefaultPercent: cloudflare.F(0.000000), - DefaultPolicy: cloudflare.F(load_balancers.LoadSheddingDefaultPolicyRandom), - SessionPercent: cloudflare.F(0.000000), - 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.NotificationFilterParam{ - Origin: cloudflare.F(load_balancers.FilterOptionsParam{ - Disable: cloudflare.F(true), - Healthy: cloudflare.F(true), - }), - Pool: cloudflare.F(load_balancers.FilterOptionsParam{ - Disable: cloudflare.F(true), - Healthy: cloudflare.F(false), - }), - }), - OriginSteering: cloudflare.F(load_balancers.OriginSteeringParam{ - Policy: cloudflare.F(load_balancers.OriginSteeringPolicyRandom), - }), - Origins: cloudflare.F([]load_balancers.OriginParam{{ - Address: cloudflare.F("0.0.0.0"), - Enabled: cloudflare.F(true), - 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), - }, { - Address: cloudflare.F("0.0.0.0"), - Enabled: cloudflare.F(true), - 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), - }, { - Address: cloudflare.F("0.0.0.0"), - Enabled: cloudflare.F(true), - 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), - }}), - }, - ) - if err != nil { - var apierr *cloudflare.Error - if errors.As(err, &apierr) { - t.Log(string(apierr.DumpRequest(true))) - } - t.Fatalf("err should be nil: %s", err.Error()) - } -} - -func TestLoadBalancingPoolGet(t *testing.T) { - t.Skip("skipped: tests are disabled for the time being") - baseURL := "http://localhost:4010" - if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { - baseURL = envURL - } - if !testutil.CheckTestServer(t, baseURL) { - return - } - client := cloudflare.NewClient( - option.WithBaseURL(baseURL), - option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), - option.WithAPIEmail("user@example.com"), - ) - _, err := client.User.LoadBalancing.Pools.Get(context.TODO(), "17b5962d775c646f3f9725cbc7a53df4") - if err != nil { - var apierr *cloudflare.Error - if errors.As(err, &apierr) { - t.Log(string(apierr.DumpRequest(true))) - } - t.Fatalf("err should be nil: %s", err.Error()) - } -} - -func TestLoadBalancingPoolHealth(t *testing.T) { - t.Skip("skipped: tests are disabled for the time being") - baseURL := "http://localhost:4010" - if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { - baseURL = envURL - } - if !testutil.CheckTestServer(t, baseURL) { - return - } - client := cloudflare.NewClient( - option.WithBaseURL(baseURL), - option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), - option.WithAPIEmail("user@example.com"), - ) - _, err := client.User.LoadBalancing.Pools.Health(context.TODO(), "17b5962d775c646f3f9725cbc7a53df4") - if err != nil { - var apierr *cloudflare.Error - if errors.As(err, &apierr) { - t.Log(string(apierr.DumpRequest(true))) - } - t.Fatalf("err should be nil: %s", err.Error()) - } -} - -func TestLoadBalancingPoolPreviewWithOptionalParams(t *testing.T) { - t.Skip("skipped: tests are disabled for the time being") - baseURL := "http://localhost:4010" - if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { - baseURL = envURL - } - if !testutil.CheckTestServer(t, baseURL) { - return - } - client := cloudflare.NewClient( - option.WithBaseURL(baseURL), - option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), - option.WithAPIEmail("user@example.com"), - ) - _, err := client.User.LoadBalancing.Pools.Preview( - context.TODO(), - "17b5962d775c646f3f9725cbc7a53df4", - user.LoadBalancingPoolPreviewParams{ - ExpectedCodes: cloudflare.F("2xx"), - AllowInsecure: cloudflare.F(true), - ConsecutiveDown: cloudflare.F(int64(0)), - ConsecutiveUp: cloudflare.F(int64(0)), - Description: cloudflare.F("Login page monitor"), - ExpectedBody: cloudflare.F("alive"), - FollowRedirects: cloudflare.F(true), - Header: cloudflare.F[any](map[string]interface{}{ - "Host": map[string]interface{}{ - "0": "example.com", - }, - "X-App-ID": map[string]interface{}{ - "0": "abc123", - }, - }), - Interval: cloudflare.F(int64(0)), - Method: cloudflare.F("GET"), - Path: cloudflare.F("/health"), - Port: cloudflare.F(int64(0)), - ProbeZone: cloudflare.F("example.com"), - Retries: cloudflare.F(int64(0)), - Timeout: cloudflare.F(int64(0)), - Type: cloudflare.F(user.LoadBalancingPoolPreviewParamsTypeHTTPS), - }, - ) - if err != nil { - var apierr *cloudflare.Error - if errors.As(err, &apierr) { - t.Log(string(apierr.DumpRequest(true))) - } - t.Fatalf("err should be nil: %s", err.Error()) - } -} - -func TestLoadBalancingPoolReferences(t *testing.T) { - t.Skip("skipped: tests are disabled for the time being") - baseURL := "http://localhost:4010" - if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { - baseURL = envURL - } - if !testutil.CheckTestServer(t, baseURL) { - return - } - client := cloudflare.NewClient( - option.WithBaseURL(baseURL), - option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), - option.WithAPIEmail("user@example.com"), - ) - _, err := client.User.LoadBalancing.Pools.References(context.TODO(), "17b5962d775c646f3f9725cbc7a53df4") - if err != nil { - var apierr *cloudflare.Error - if errors.As(err, &apierr) { - t.Log(string(apierr.DumpRequest(true))) - } - t.Fatalf("err should be nil: %s", err.Error()) - } -} diff --git a/user/loadbalancingpreview.go b/user/loadbalancingpreview.go deleted file mode 100644 index 7a794b0213c..00000000000 --- a/user/loadbalancingpreview.go +++ /dev/null @@ -1,91 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -package user - -import ( - "context" - "fmt" - "net/http" - - "github.com/cloudflare/cloudflare-go/v2/internal/apijson" - "github.com/cloudflare/cloudflare-go/v2/internal/requestconfig" - "github.com/cloudflare/cloudflare-go/v2/internal/shared" - "github.com/cloudflare/cloudflare-go/v2/option" -) - -// LoadBalancingPreviewService contains methods and other services that help with -// interacting with the cloudflare API. Note, unlike clients, this service does not -// read variables from the environment automatically. You should not instantiate -// this service directly, and instead use the [NewLoadBalancingPreviewService] -// method instead. -type LoadBalancingPreviewService struct { - Options []option.RequestOption -} - -// NewLoadBalancingPreviewService generates a new service that applies the given -// options to each request. These options are applied after the parent client's -// options (if there is one), and before any request-specific options. -func NewLoadBalancingPreviewService(opts ...option.RequestOption) (r *LoadBalancingPreviewService) { - r = &LoadBalancingPreviewService{} - r.Options = opts - return -} - -// Get the result of a previous preview operation using the provided preview_id. -func (r *LoadBalancingPreviewService) Get(ctx context.Context, previewID string, opts ...option.RequestOption) (res *LoadBalancingPreviewGetResponse, err error) { - opts = append(r.Options[:], opts...) - var env LoadBalancingPreviewGetResponseEnvelope - path := fmt.Sprintf("user/load_balancers/preview/%s", previewID) - err = requestconfig.ExecuteNewRequest(ctx, http.MethodGet, path, nil, &env, opts...) - if err != nil { - return - } - res = &env.Result - return -} - -type LoadBalancingPreviewGetResponse map[string]LoadBalancingPreviewGetResponse - -type LoadBalancingPreviewGetResponseEnvelope struct { - Errors []shared.ResponseInfo `json:"errors,required"` - Messages []shared.ResponseInfo `json:"messages,required"` - // Resulting health data from a preview operation. - Result LoadBalancingPreviewGetResponse `json:"result,required"` - // Whether the API call was successful - Success LoadBalancingPreviewGetResponseEnvelopeSuccess `json:"success,required"` - JSON loadBalancingPreviewGetResponseEnvelopeJSON `json:"-"` -} - -// loadBalancingPreviewGetResponseEnvelopeJSON contains the JSON metadata for the -// struct [LoadBalancingPreviewGetResponseEnvelope] -type loadBalancingPreviewGetResponseEnvelopeJSON struct { - Errors apijson.Field - Messages apijson.Field - Result apijson.Field - Success apijson.Field - raw string - ExtraFields map[string]apijson.Field -} - -func (r *LoadBalancingPreviewGetResponseEnvelope) UnmarshalJSON(data []byte) (err error) { - return apijson.UnmarshalRoot(data, r) -} - -func (r loadBalancingPreviewGetResponseEnvelopeJSON) RawJSON() string { - return r.raw -} - -// Whether the API call was successful -type LoadBalancingPreviewGetResponseEnvelopeSuccess bool - -const ( - LoadBalancingPreviewGetResponseEnvelopeSuccessTrue LoadBalancingPreviewGetResponseEnvelopeSuccess = true -) - -func (r LoadBalancingPreviewGetResponseEnvelopeSuccess) IsKnown() bool { - switch r { - case LoadBalancingPreviewGetResponseEnvelopeSuccessTrue: - return true - } - return false -} diff --git a/user/loadbalancingpreview_test.go b/user/loadbalancingpreview_test.go deleted file mode 100644 index ca3204e19b6..00000000000 --- a/user/loadbalancingpreview_test.go +++ /dev/null @@ -1,38 +0,0 @@ -// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details. - -package user_test - -import ( - "context" - "errors" - "os" - "testing" - - "github.com/cloudflare/cloudflare-go/v2" - "github.com/cloudflare/cloudflare-go/v2/internal/testutil" - "github.com/cloudflare/cloudflare-go/v2/option" -) - -func TestLoadBalancingPreviewGet(t *testing.T) { - t.Skip("skipped: tests are disabled for the time being") - baseURL := "http://localhost:4010" - if envURL, ok := os.LookupEnv("TEST_API_BASE_URL"); ok { - baseURL = envURL - } - if !testutil.CheckTestServer(t, baseURL) { - return - } - client := cloudflare.NewClient( - option.WithBaseURL(baseURL), - option.WithAPIKey("144c9defac04969c7bfad8efaa8ea194"), - option.WithAPIEmail("user@example.com"), - ) - _, err := client.User.LoadBalancing.Preview.Get(context.TODO(), "f1aba936b94213e5b8dca0c0dbf1f9cc") - if err != nil { - var apierr *cloudflare.Error - if errors.As(err, &apierr) { - t.Log(string(apierr.DumpRequest(true))) - } - t.Fatalf("err should be nil: %s", err.Error()) - } -} diff --git a/user/organization.go b/user/organization.go index b4b8dc53679..ae66f52ea2f 100644 --- a/user/organization.go +++ b/user/organization.go @@ -85,7 +85,7 @@ type Organization struct { // Organization name. Name string `json:"name"` // Access permissions for this User. - Permissions []PermissionItem `json:"permissions"` + Permissions []Permission `json:"permissions"` // List of roles that a user has within an organization. Roles []string `json:"roles"` // Whether the user is a member of the organization or has an inivitation pending. diff --git a/user/token.go b/user/token.go index d8f7dd0c9f2..280d7ffc710 100644 --- a/user/token.go +++ b/user/token.go @@ -127,7 +127,7 @@ func (r *TokenService) Verify(ctx context.Context, opts ...option.RequestOption) return } -type CIDRListItemParam = string +type CIDRListParam = string type Policy struct { // Policy identifier. @@ -348,9 +348,9 @@ func (r TokenNewParamsCondition) MarshalJSON() (data []byte, err error) { // Client IP restrictions. type TokenNewParamsConditionRequestIP struct { // List of IPv4/IPv6 CIDR addresses. - In param.Field[[]CIDRListItemParam] `json:"in"` + In param.Field[[]CIDRListParam] `json:"in"` // List of IPv4/IPv6 CIDR addresses. - NotIn param.Field[[]CIDRListItemParam] `json:"not_in"` + NotIn param.Field[[]CIDRListParam] `json:"not_in"` } func (r TokenNewParamsConditionRequestIP) MarshalJSON() (data []byte, err error) { @@ -448,9 +448,9 @@ func (r TokenUpdateParamsCondition) MarshalJSON() (data []byte, err error) { // Client IP restrictions. type TokenUpdateParamsConditionRequestIP struct { // List of IPv4/IPv6 CIDR addresses. - In param.Field[[]CIDRListItemParam] `json:"in"` + In param.Field[[]CIDRListParam] `json:"in"` // List of IPv4/IPv6 CIDR addresses. - NotIn param.Field[[]CIDRListItemParam] `json:"not_in"` + NotIn param.Field[[]CIDRListParam] `json:"not_in"` } func (r TokenUpdateParamsConditionRequestIP) MarshalJSON() (data []byte, err error) { diff --git a/user/token_test.go b/user/token_test.go index 072a965275e..c9335b398d6 100644 --- a/user/token_test.go +++ b/user/token_test.go @@ -55,8 +55,8 @@ func TestTokenNewWithOptionalParams(t *testing.T) { }}), Condition: cloudflare.F(user.TokenNewParamsCondition{ RequestIP: cloudflare.F(user.TokenNewParamsConditionRequestIP{ - In: cloudflare.F([]user.CIDRListItemParam{"123.123.123.0/24", "2606:4700::/32"}), - NotIn: cloudflare.F([]user.CIDRListItemParam{"123.123.123.100/24", "2606:4700:4700::/48"}), + In: cloudflare.F([]user.CIDRListParam{"123.123.123.0/24", "2606:4700::/32"}), + NotIn: cloudflare.F([]user.CIDRListParam{"123.123.123.100/24", "2606:4700:4700::/48"}), }), }), ExpiresOn: cloudflare.F(time.Now()), @@ -115,8 +115,8 @@ func TestTokenUpdateWithOptionalParams(t *testing.T) { Status: cloudflare.F(user.TokenUpdateParamsStatusActive), Condition: cloudflare.F(user.TokenUpdateParamsCondition{ RequestIP: cloudflare.F(user.TokenUpdateParamsConditionRequestIP{ - In: cloudflare.F([]user.CIDRListItemParam{"123.123.123.0/24", "2606:4700::/32"}), - NotIn: cloudflare.F([]user.CIDRListItemParam{"123.123.123.100/24", "2606:4700:4700::/48"}), + In: cloudflare.F([]user.CIDRListParam{"123.123.123.0/24", "2606:4700::/32"}), + NotIn: cloudflare.F([]user.CIDRListParam{"123.123.123.100/24", "2606:4700:4700::/48"}), }), }), ExpiresOn: cloudflare.F(time.Now()), diff --git a/user/tokenpermissiongroup.go b/user/tokenpermissiongroup.go index c8bb7790d85..2312e38191f 100644 --- a/user/tokenpermissiongroup.go +++ b/user/tokenpermissiongroup.go @@ -6,10 +6,7 @@ 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" ) @@ -55,67 +52,6 @@ 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 PermissionItem = string +type Permission = string type TokenPermissionGroupListResponse = interface{} diff --git a/user/user.go b/user/user.go index 94f09254439..43afddd4a89 100644 --- a/user/user.go +++ b/user/user.go @@ -21,9 +21,7 @@ type UserService struct { Options []option.RequestOption AuditLogs *AuditLogService Billing *BillingService - Firewall *FirewallService Invites *InviteService - LoadBalancing *LoadBalancingService Organizations *OrganizationService Subscriptions *SubscriptionService Tokens *TokenService @@ -37,9 +35,7 @@ func NewUserService(opts ...option.RequestOption) (r *UserService) { r.Options = opts r.AuditLogs = NewAuditLogService(opts...) r.Billing = NewBillingService(opts...) - r.Firewall = NewFirewallService(opts...) r.Invites = NewInviteService(opts...) - r.LoadBalancing = NewLoadBalancingService(opts...) r.Organizations = NewOrganizationService(opts...) r.Subscriptions = NewSubscriptionService(opts...) r.Tokens = NewTokenService(opts...) diff --git a/waiting_rooms/waitingroom.go b/waiting_rooms/waitingroom.go index d631b9789da..209506dce76 100644 --- a/waiting_rooms/waitingroom.go +++ b/waiting_rooms/waitingroom.go @@ -131,7 +131,7 @@ func (r *WaitingRoomService) Get(ctx context.Context, waitingRoomID string, quer return } -type AdditionalRoutesItem struct { +type AdditionalRoutes struct { // The hostname to which this waiting room will be applied (no wildcards). The // hostname must be the primary domain, subdomain, or custom hostname (if using SSL // for SaaS) of this zone. Please do not include the scheme (http:// or https://). @@ -140,28 +140,28 @@ type AdditionalRoutesItem struct { // will be enabled for all subpaths as well. If there are two waiting rooms on the // same subpath, the waiting room for the most specific path will be chosen. // Wildcards and query parameters are not supported. - Path string `json:"path"` - JSON additionalRoutesItemJSON `json:"-"` + Path string `json:"path"` + JSON additionalRoutesJSON `json:"-"` } -// additionalRoutesItemJSON contains the JSON metadata for the struct -// [AdditionalRoutesItem] -type additionalRoutesItemJSON struct { +// additionalRoutesJSON contains the JSON metadata for the struct +// [AdditionalRoutes] +type additionalRoutesJSON struct { Host apijson.Field Path apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *AdditionalRoutesItem) UnmarshalJSON(data []byte) (err error) { +func (r *AdditionalRoutes) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r additionalRoutesItemJSON) RawJSON() string { +func (r additionalRoutesJSON) RawJSON() string { return r.raw } -type AdditionalRoutesItemParam struct { +type AdditionalRoutesParam struct { // The hostname to which this waiting room will be applied (no wildcards). The // hostname must be the primary domain, subdomain, or custom hostname (if using SSL // for SaaS) of this zone. Please do not include the scheme (http:// or https://). @@ -173,7 +173,7 @@ type AdditionalRoutesItemParam struct { Path param.Field[string] `json:"path"` } -func (r AdditionalRoutesItemParam) MarshalJSON() (data []byte, err error) { +func (r AdditionalRoutesParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } @@ -276,7 +276,7 @@ type WaitingRoom struct { // and path combinations to which this waiting room will be applied. There is an // implied wildcard at the end of the path. The hostname and path combination must // be unique to this and all other waiting rooms. - AdditionalRoutes []AdditionalRoutesItem `json:"additional_routes"` + AdditionalRoutes []AdditionalRoutes `json:"additional_routes"` // Configures cookie attributes for the waiting room cookie. This encrypted cookie // stores a user's status in the waiting room, such as queue position. CookieAttributes CookieAttributes `json:"cookie_attributes"` @@ -714,7 +714,7 @@ type WaitingRoomNewParams struct { // and path combinations to which this waiting room will be applied. There is an // implied wildcard at the end of the path. The hostname and path combination must // be unique to this and all other waiting rooms. - AdditionalRoutes param.Field[[]AdditionalRoutesItemParam] `json:"additional_routes"` + AdditionalRoutes param.Field[[]AdditionalRoutesParam] `json:"additional_routes"` // Configures cookie attributes for the waiting room cookie. This encrypted cookie // stores a user's status in the waiting room, such as queue position. CookieAttributes param.Field[CookieAttributesParam] `json:"cookie_attributes"` @@ -1099,7 +1099,7 @@ type WaitingRoomUpdateParams struct { // and path combinations to which this waiting room will be applied. There is an // implied wildcard at the end of the path. The hostname and path combination must // be unique to this and all other waiting rooms. - AdditionalRoutes param.Field[[]AdditionalRoutesItemParam] `json:"additional_routes"` + AdditionalRoutes param.Field[[]AdditionalRoutesParam] `json:"additional_routes"` // Configures cookie attributes for the waiting room cookie. This encrypted cookie // stores a user's status in the waiting room, such as queue position. CookieAttributes param.Field[CookieAttributesParam] `json:"cookie_attributes"` @@ -1526,7 +1526,7 @@ type WaitingRoomEditParams struct { // and path combinations to which this waiting room will be applied. There is an // implied wildcard at the end of the path. The hostname and path combination must // be unique to this and all other waiting rooms. - AdditionalRoutes param.Field[[]AdditionalRoutesItemParam] `json:"additional_routes"` + AdditionalRoutes param.Field[[]AdditionalRoutesParam] `json:"additional_routes"` // Configures cookie attributes for the waiting room cookie. This encrypted cookie // stores a user's status in the waiting room, such as queue position. CookieAttributes param.Field[CookieAttributesParam] `json:"cookie_attributes"` diff --git a/waiting_rooms/waitingroom_test.go b/waiting_rooms/waitingroom_test.go index 15ae858c54e..47a9705938d 100644 --- a/waiting_rooms/waitingroom_test.go +++ b/waiting_rooms/waitingroom_test.go @@ -34,7 +34,7 @@ func TestWaitingRoomNewWithOptionalParams(t *testing.T) { Name: cloudflare.F("production_webinar"), NewUsersPerMinute: cloudflare.F(int64(200)), TotalActiveUsers: cloudflare.F(int64(200)), - AdditionalRoutes: cloudflare.F([]waiting_rooms.AdditionalRoutesItemParam{{ + AdditionalRoutes: cloudflare.F([]waiting_rooms.AdditionalRoutesParam{{ Host: cloudflare.F("shop2.example.com"), Path: cloudflare.F("/shop2/checkout"), }, { @@ -93,7 +93,7 @@ func TestWaitingRoomUpdateWithOptionalParams(t *testing.T) { Name: cloudflare.F("production_webinar"), NewUsersPerMinute: cloudflare.F(int64(200)), TotalActiveUsers: cloudflare.F(int64(200)), - AdditionalRoutes: cloudflare.F([]waiting_rooms.AdditionalRoutesItemParam{{ + AdditionalRoutes: cloudflare.F([]waiting_rooms.AdditionalRoutesParam{{ Host: cloudflare.F("shop2.example.com"), Path: cloudflare.F("/shop2/checkout"), }, { @@ -210,7 +210,7 @@ func TestWaitingRoomEditWithOptionalParams(t *testing.T) { Name: cloudflare.F("production_webinar"), NewUsersPerMinute: cloudflare.F(int64(200)), TotalActiveUsers: cloudflare.F(int64(200)), - AdditionalRoutes: cloudflare.F([]waiting_rooms.AdditionalRoutesItemParam{{ + AdditionalRoutes: cloudflare.F([]waiting_rooms.AdditionalRoutesParam{{ Host: cloudflare.F("shop2.example.com"), Path: cloudflare.F("/shop2/checkout"), }, { diff --git a/web3/hostnameipfsuniversalpathcontentlist.go b/web3/hostnameipfsuniversalpathcontentlist.go index 533120e1b9a..d41d4df1306 100644 --- a/web3/hostnameipfsuniversalpathcontentlist.go +++ b/web3/hostnameipfsuniversalpathcontentlist.go @@ -97,11 +97,20 @@ func (r ContentListAction) IsKnown() bool { return false } +type ContentListParam struct { + // Behavior of the content list. + Action param.Field[ContentListAction] `json:"action"` +} + +func (r ContentListParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + type HostnameIPFSUniversalPathContentListUpdateParams struct { // Behavior of the content list. Action param.Field[HostnameIPFSUniversalPathContentListUpdateParamsAction] `json:"action,required"` // Content list entries. - Entries param.Field[[]ContentListItemParam] `json:"entries,required"` + Entries param.Field[[]ContentListParam] `json:"entries,required"` } func (r HostnameIPFSUniversalPathContentListUpdateParams) MarshalJSON() (data []byte, err error) { diff --git a/web3/hostnameipfsuniversalpathcontentlist_test.go b/web3/hostnameipfsuniversalpathcontentlist_test.go index d4debfb43e7..619131a8f20 100644 --- a/web3/hostnameipfsuniversalpathcontentlist_test.go +++ b/web3/hostnameipfsuniversalpathcontentlist_test.go @@ -34,18 +34,18 @@ func TestHostnameIPFSUniversalPathContentListUpdate(t *testing.T) { "023e105f4ecef8ad9ca31a8372d0c353", web3.HostnameIPFSUniversalPathContentListUpdateParams{ Action: cloudflare.F(web3.HostnameIPFSUniversalPathContentListUpdateParamsActionBlock), - Entries: cloudflare.F([]web3.ContentListItemParam{{ + Entries: cloudflare.F([]web3.ContentListParam{{ Content: cloudflare.F("QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB"), Description: cloudflare.F("this is my content list entry"), - Type: cloudflare.F(web3.ContentListItemTypeCid), + Type: cloudflare.F(web3.ContentListTypeCid), }, { Content: cloudflare.F("QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB"), Description: cloudflare.F("this is my content list entry"), - Type: cloudflare.F(web3.ContentListItemTypeCid), + Type: cloudflare.F(web3.ContentListTypeCid), }, { Content: cloudflare.F("QmPZ9gcCEpqKTo6aq61g2nXGUhM4iCL3ewB6LDXZCtioEB"), Description: cloudflare.F("this is my content list entry"), - Type: cloudflare.F(web3.ContentListItemTypeCid), + Type: cloudflare.F(web3.ContentListTypeCid), }}), }, ) diff --git a/web3/hostnameipfsuniversalpathcontentlistentry.go b/web3/hostnameipfsuniversalpathcontentlistentry.go index e29776b28be..8a0f7c46d1a 100644 --- a/web3/hostnameipfsuniversalpathcontentlistentry.go +++ b/web3/hostnameipfsuniversalpathcontentlistentry.go @@ -35,7 +35,7 @@ func NewHostnameIPFSUniversalPathContentListEntryService(opts ...option.RequestO } // Create IPFS Universal Path Gateway Content List Entry -func (r *HostnameIPFSUniversalPathContentListEntryService) New(ctx context.Context, zoneIdentifier string, identifier string, body HostnameIPFSUniversalPathContentListEntryNewParams, opts ...option.RequestOption) (res *ContentListItem, err error) { +func (r *HostnameIPFSUniversalPathContentListEntryService) New(ctx context.Context, zoneIdentifier string, identifier string, body HostnameIPFSUniversalPathContentListEntryNewParams, opts ...option.RequestOption) (res *ContentList, err error) { opts = append(r.Options[:], opts...) var env HostnameIPFSUniversalPathContentListEntryNewResponseEnvelope path := fmt.Sprintf("zones/%s/web3/hostnames/%s/ipfs_universal_path/content_list/entries", zoneIdentifier, identifier) @@ -48,7 +48,7 @@ func (r *HostnameIPFSUniversalPathContentListEntryService) New(ctx context.Conte } // Edit IPFS Universal Path Gateway Content List Entry -func (r *HostnameIPFSUniversalPathContentListEntryService) Update(ctx context.Context, zoneIdentifier string, identifier string, contentListEntryIdentifier string, body HostnameIPFSUniversalPathContentListEntryUpdateParams, opts ...option.RequestOption) (res *ContentListItem, err error) { +func (r *HostnameIPFSUniversalPathContentListEntryService) Update(ctx context.Context, zoneIdentifier string, identifier string, contentListEntryIdentifier string, body HostnameIPFSUniversalPathContentListEntryUpdateParams, opts ...option.RequestOption) (res *ContentList, err error) { opts = append(r.Options[:], opts...) var env HostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelope path := fmt.Sprintf("zones/%s/web3/hostnames/%s/ipfs_universal_path/content_list/entries/%s", zoneIdentifier, identifier, contentListEntryIdentifier) @@ -87,7 +87,7 @@ func (r *HostnameIPFSUniversalPathContentListEntryService) Delete(ctx context.Co } // IPFS Universal Path Gateway Content List Entry Details -func (r *HostnameIPFSUniversalPathContentListEntryService) Get(ctx context.Context, zoneIdentifier string, identifier string, contentListEntryIdentifier string, opts ...option.RequestOption) (res *ContentListItem, err error) { +func (r *HostnameIPFSUniversalPathContentListEntryService) Get(ctx context.Context, zoneIdentifier string, identifier string, contentListEntryIdentifier string, opts ...option.RequestOption) (res *ContentList, err error) { opts = append(r.Options[:], opts...) var env HostnameIPFSUniversalPathContentListEntryGetResponseEnvelope path := fmt.Sprintf("zones/%s/web3/hostnames/%s/ipfs_universal_path/content_list/entries/%s", zoneIdentifier, identifier, contentListEntryIdentifier) @@ -100,7 +100,7 @@ func (r *HostnameIPFSUniversalPathContentListEntryService) Get(ctx context.Conte } // Content list entry to be blocked. -type ContentListItem struct { +type ContentList struct { // Identifier ID string `json:"id"` // CID or content path of content to block. @@ -110,12 +110,12 @@ type ContentListItem struct { Description string `json:"description"` ModifiedOn time.Time `json:"modified_on" format:"date-time"` // Type of content list entry to block. - Type ContentListItemType `json:"type"` - JSON contentListItemJSON `json:"-"` + Type ContentListType `json:"type"` + JSON contentListJSON `json:"-"` } -// contentListItemJSON contains the JSON metadata for the struct [ContentListItem] -type contentListItemJSON struct { +// contentListJSON contains the JSON metadata for the struct [ContentList] +type contentListJSON struct { ID apijson.Field Content apijson.Field CreatedOn apijson.Field @@ -126,47 +126,47 @@ type contentListItemJSON struct { ExtraFields map[string]apijson.Field } -func (r *ContentListItem) UnmarshalJSON(data []byte) (err error) { +func (r *ContentList) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r contentListItemJSON) RawJSON() string { +func (r contentListJSON) RawJSON() string { return r.raw } // Type of content list entry to block. -type ContentListItemType string +type ContentListType string const ( - ContentListItemTypeCid ContentListItemType = "cid" - ContentListItemTypeContentPath ContentListItemType = "content_path" + ContentListTypeCid ContentListType = "cid" + ContentListTypeContentPath ContentListType = "content_path" ) -func (r ContentListItemType) IsKnown() bool { +func (r ContentListType) IsKnown() bool { switch r { - case ContentListItemTypeCid, ContentListItemTypeContentPath: + case ContentListTypeCid, ContentListTypeContentPath: return true } return false } // Content list entry to be blocked. -type ContentListItemParam struct { +type ContentListParam struct { // CID or content path of content to block. Content param.Field[string] `json:"content"` // An optional description of the content list entry. Description param.Field[string] `json:"description"` // Type of content list entry to block. - Type param.Field[ContentListItemType] `json:"type"` + Type param.Field[ContentListType] `json:"type"` } -func (r ContentListItemParam) MarshalJSON() (data []byte, err error) { +func (r ContentListParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } type HostnameIPFSUniversalPathContentListEntryListResponse struct { // Content list entries. - Entries []ContentListItem `json:"entries"` + Entries []ContentList `json:"entries"` JSON hostnameIPFSUniversalPathContentListEntryListResponseJSON `json:"-"` } @@ -242,7 +242,7 @@ type HostnameIPFSUniversalPathContentListEntryNewResponseEnvelope struct { Errors []shared.ResponseInfo `json:"errors,required"` Messages []shared.ResponseInfo `json:"messages,required"` // Content list entry to be blocked. - Result ContentListItem `json:"result,required"` + Result ContentList `json:"result,required"` // Whether the API call was successful Success HostnameIPFSUniversalPathContentListEntryNewResponseEnvelopeSuccess `json:"success,required"` JSON hostnameIPFSUniversalPathContentListEntryNewResponseEnvelopeJSON `json:"-"` @@ -316,7 +316,7 @@ type HostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelope struct { Errors []shared.ResponseInfo `json:"errors,required"` Messages []shared.ResponseInfo `json:"messages,required"` // Content list entry to be blocked. - Result ContentListItem `json:"result,required"` + Result ContentList `json:"result,required"` // Whether the API call was successful Success HostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeSuccess `json:"success,required"` JSON hostnameIPFSUniversalPathContentListEntryUpdateResponseEnvelopeJSON `json:"-"` @@ -491,7 +491,7 @@ type HostnameIPFSUniversalPathContentListEntryGetResponseEnvelope struct { Errors []shared.ResponseInfo `json:"errors,required"` Messages []shared.ResponseInfo `json:"messages,required"` // Content list entry to be blocked. - Result ContentListItem `json:"result,required"` + Result ContentList `json:"result,required"` // Whether the API call was successful Success HostnameIPFSUniversalPathContentListEntryGetResponseEnvelopeSuccess `json:"success,required"` JSON hostnameIPFSUniversalPathContentListEntryGetResponseEnvelopeJSON `json:"-"` diff --git a/workers/script.go b/workers/script.go index 29d4799fb69..33eb5434ec2 100644 --- a/workers/script.go +++ b/workers/script.go @@ -122,7 +122,7 @@ type Script struct { // Specifies the placement mode for the Worker (e.g. 'smart'). PlacementMode string `json:"placement_mode"` // List of Workers that will consume logs from the attached Worker. - TailConsumers []ConsumerScriptItem `json:"tail_consumers"` + TailConsumers []ConsumerScript `json:"tail_consumers"` // Specifies the usage model for the Worker (e.g. 'bundled' or 'unbound'). UsageModel string `json:"usage_model"` JSON scriptJSON `json:"-"` @@ -155,8 +155,8 @@ type ScriptSetting struct { // Whether Logpush is turned on for the Worker. Logpush bool `json:"logpush"` // List of Workers that will consume logs from the attached Worker. - TailConsumers []ConsumerScriptItem `json:"tail_consumers"` - JSON scriptSettingJSON `json:"-"` + TailConsumers []ConsumerScript `json:"tail_consumers"` + JSON scriptSettingJSON `json:"-"` } // scriptSettingJSON contains the JSON metadata for the struct [ScriptSetting] @@ -179,7 +179,7 @@ type ScriptSettingParam struct { // Whether Logpush is turned on for the Worker. Logpush param.Field[bool] `json:"logpush"` // List of Workers that will consume logs from the attached Worker. - TailConsumers param.Field[[]ConsumerScriptItemParam] `json:"tail_consumers"` + TailConsumers param.Field[[]ConsumerScriptParam] `json:"tail_consumers"` } func (r ScriptSettingParam) MarshalJSON() (data []byte, err error) { @@ -269,7 +269,7 @@ type ScriptUpdateParamsVariant0Metadata struct { // List of strings to use as tags for this Worker Tags param.Field[[]string] `json:"tags"` // List of Workers that will consume logs from the attached Worker. - TailConsumers param.Field[[]ConsumerScriptItemParam] `json:"tail_consumers"` + TailConsumers param.Field[[]ConsumerScriptParam] `json:"tail_consumers"` // Usage model to apply to invocations. UsageModel param.Field[ScriptUpdateParamsVariant0MetadataUsageModel] `json:"usage_model"` // Key-value pairs to use as tags for this version of this Worker diff --git a/workers/script_test.go b/workers/script_test.go index 4237762f223..07cfa5f8bf7 100644 --- a/workers/script_test.go +++ b/workers/script_test.go @@ -84,7 +84,7 @@ func TestScriptUpdateWithOptionalParams(t *testing.T) { Mode: cloudflare.F(workers.PlacementConfigurationModeSmart), }), Tags: cloudflare.F([]string{"string", "string", "string"}), - TailConsumers: cloudflare.F([]workers.ConsumerScriptItemParam{{ + TailConsumers: cloudflare.F([]workers.ConsumerScriptParam{{ Environment: cloudflare.F("production"), Namespace: cloudflare.F("my-namespace"), Service: cloudflare.F("my-log-consumer"), diff --git a/workers/scriptsetting.go b/workers/scriptsetting.go index 230a6833a98..a91ebb86ba4 100644 --- a/workers/scriptsetting.go +++ b/workers/scriptsetting.go @@ -68,7 +68,7 @@ type ScriptSettingEditParams struct { // Whether Logpush is turned on for the Worker. Logpush param.Field[bool] `json:"logpush"` // List of Workers that will consume logs from the attached Worker. - TailConsumers param.Field[[]ConsumerScriptItemParam] `json:"tail_consumers"` + TailConsumers param.Field[[]ConsumerScriptParam] `json:"tail_consumers"` } func (r ScriptSettingEditParams) MarshalJSON() (data []byte, err error) { diff --git a/workers/scriptsetting_test.go b/workers/scriptsetting_test.go index 32ff7967b5a..028e598f069 100644 --- a/workers/scriptsetting_test.go +++ b/workers/scriptsetting_test.go @@ -34,7 +34,7 @@ func TestScriptSettingEditWithOptionalParams(t *testing.T) { workers.ScriptSettingEditParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Logpush: cloudflare.F(false), - TailConsumers: cloudflare.F([]workers.ConsumerScriptItemParam{{ + TailConsumers: cloudflare.F([]workers.ConsumerScriptParam{{ Environment: cloudflare.F("production"), Namespace: cloudflare.F("my-namespace"), Service: cloudflare.F("my-log-consumer"), diff --git a/workers/scripttail.go b/workers/scripttail.go index ba6f76c7ce8..3b0ad3054b6 100644 --- a/workers/scripttail.go +++ b/workers/scripttail.go @@ -73,19 +73,18 @@ func (r *ScriptTailService) Get(ctx context.Context, scriptName string, query Sc } // A reference to a script that will consume logs from the attached Worker. -type ConsumerScriptItem struct { +type ConsumerScript struct { // Name of Worker that is to be the consumer. Service string `json:"service,required"` // Optional environment if the Worker utilizes one. Environment string `json:"environment"` // Optional dispatch namespace the script belongs to. - Namespace string `json:"namespace"` - JSON consumerScriptItemJSON `json:"-"` + Namespace string `json:"namespace"` + JSON consumerScriptJSON `json:"-"` } -// consumerScriptItemJSON contains the JSON metadata for the struct -// [ConsumerScriptItem] -type consumerScriptItemJSON struct { +// consumerScriptJSON contains the JSON metadata for the struct [ConsumerScript] +type consumerScriptJSON struct { Service apijson.Field Environment apijson.Field Namespace apijson.Field @@ -93,16 +92,16 @@ type consumerScriptItemJSON struct { ExtraFields map[string]apijson.Field } -func (r *ConsumerScriptItem) UnmarshalJSON(data []byte) (err error) { +func (r *ConsumerScript) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r consumerScriptItemJSON) RawJSON() string { +func (r consumerScriptJSON) RawJSON() string { return r.raw } // A reference to a script that will consume logs from the attached Worker. -type ConsumerScriptItemParam struct { +type ConsumerScriptParam struct { // Name of Worker that is to be the consumer. Service param.Field[string] `json:"service,required"` // Optional environment if the Worker utilizes one. @@ -111,7 +110,7 @@ type ConsumerScriptItemParam struct { Namespace param.Field[string] `json:"namespace"` } -func (r ConsumerScriptItemParam) MarshalJSON() (data []byte, err error) { +func (r ConsumerScriptParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } diff --git a/workers_for_platforms/dispatchnamespacescript.go b/workers_for_platforms/dispatchnamespacescript.go index 996d0a58c2f..cb2f676cd48 100644 --- a/workers_for_platforms/dispatchnamespacescript.go +++ b/workers_for_platforms/dispatchnamespacescript.go @@ -183,7 +183,7 @@ type DispatchNamespaceScriptUpdateParamsVariant0Metadata struct { // List of strings to use as tags for this Worker Tags param.Field[[]string] `json:"tags"` // List of Workers that will consume logs from the attached Worker. - TailConsumers param.Field[[]workers.ConsumerScriptItemParam] `json:"tail_consumers"` + TailConsumers param.Field[[]workers.ConsumerScriptParam] `json:"tail_consumers"` // Usage model to apply to invocations. UsageModel param.Field[DispatchNamespaceScriptUpdateParamsVariant0MetadataUsageModel] `json:"usage_model"` // Key-value pairs to use as tags for this version of this Worker diff --git a/workers_for_platforms/dispatchnamespacescript_test.go b/workers_for_platforms/dispatchnamespacescript_test.go index 03458588f4a..56722a4c586 100644 --- a/workers_for_platforms/dispatchnamespacescript_test.go +++ b/workers_for_platforms/dispatchnamespacescript_test.go @@ -83,7 +83,7 @@ func TestDispatchNamespaceScriptUpdateWithOptionalParams(t *testing.T) { Mode: cloudflare.F(workers.PlacementConfigurationModeSmart), }), Tags: cloudflare.F([]string{"string", "string", "string"}), - TailConsumers: cloudflare.F([]workers.ConsumerScriptItemParam{{ + TailConsumers: cloudflare.F([]workers.ConsumerScriptParam{{ Environment: cloudflare.F("production"), Namespace: cloudflare.F("my-namespace"), Service: cloudflare.F("my-log-consumer"), diff --git a/workers_for_platforms/dispatchnamespacescriptsetting_test.go b/workers_for_platforms/dispatchnamespacescriptsetting_test.go index 0a1b027dcfd..34101f77bfc 100644 --- a/workers_for_platforms/dispatchnamespacescriptsetting_test.go +++ b/workers_for_platforms/dispatchnamespacescriptsetting_test.go @@ -58,7 +58,7 @@ func TestDispatchNamespaceScriptSettingEditWithOptionalParams(t *testing.T) { }}), Result: cloudflare.F(workers.ScriptSettingParam{ Logpush: cloudflare.F(false), - TailConsumers: cloudflare.F([]workers.ConsumerScriptItemParam{{ + TailConsumers: cloudflare.F([]workers.ConsumerScriptParam{{ Environment: cloudflare.F("production"), Namespace: cloudflare.F("my-namespace"), Service: cloudflare.F("my-log-consumer"), diff --git a/zero_trust/accesscertificate.go b/zero_trust/accesscertificate.go index f0583f624b4..64381b7d953 100644 --- a/zero_trust/accesscertificate.go +++ b/zero_trust/accesscertificate.go @@ -156,17 +156,17 @@ func (r *AccessCertificateService) Get(ctx context.Context, uuid string, query A return } -type AssociatedHostnamesItem = string +type AssociatedHostnames = string -type AssociatedHostnamesItemParam = string +type AssociatedHostnamesParam = string type Certificate struct { // The ID of the application that will use this certificate. ID string `json:"id"` // The hostnames of the applications that will use this certificate. - AssociatedHostnames []AssociatedHostnamesItem `json:"associated_hostnames"` - CreatedAt time.Time `json:"created_at" format:"date-time"` - ExpiresOn time.Time `json:"expires_on" format:"date-time"` + AssociatedHostnames []AssociatedHostnames `json:"associated_hostnames"` + CreatedAt time.Time `json:"created_at" format:"date-time"` + ExpiresOn time.Time `json:"expires_on" format:"date-time"` // The MD5 fingerprint of the certificate. Fingerprint string `json:"fingerprint"` // The name of the certificate. @@ -228,7 +228,7 @@ type AccessCertificateNewParams struct { // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. ZoneID param.Field[string] `path:"zone_id"` // The hostnames of the applications that will use this certificate. - AssociatedHostnames param.Field[[]AssociatedHostnamesItemParam] `json:"associated_hostnames"` + AssociatedHostnames param.Field[[]AssociatedHostnamesParam] `json:"associated_hostnames"` } func (r AccessCertificateNewParams) MarshalJSON() (data []byte, err error) { @@ -280,7 +280,7 @@ func (r AccessCertificateNewResponseEnvelopeSuccess) IsKnown() bool { type AccessCertificateUpdateParams struct { // The hostnames of the applications that will use this certificate. - AssociatedHostnames param.Field[[]AssociatedHostnamesItemParam] `json:"associated_hostnames,required"` + AssociatedHostnames param.Field[[]AssociatedHostnamesParam] `json:"associated_hostnames,required"` // The Account ID to use for this endpoint. Mutually exclusive with the Zone ID. AccountID param.Field[string] `path:"account_id"` // The Zone ID to use for this endpoint. Mutually exclusive with the Account ID. diff --git a/zero_trust/accesscertificate_test.go b/zero_trust/accesscertificate_test.go index 51afa780b43..fcdca9c7659 100644 --- a/zero_trust/accesscertificate_test.go +++ b/zero_trust/accesscertificate_test.go @@ -33,7 +33,7 @@ func TestAccessCertificateNewWithOptionalParams(t *testing.T) { Name: cloudflare.F("Allow devs"), AccountID: cloudflare.F("string"), ZoneID: cloudflare.F("string"), - AssociatedHostnames: cloudflare.F([]zero_trust.AssociatedHostnamesItemParam{"admin.example.com", "admin.example.com", "admin.example.com"}), + AssociatedHostnames: cloudflare.F([]zero_trust.AssociatedHostnamesParam{"admin.example.com", "admin.example.com", "admin.example.com"}), }) if err != nil { var apierr *cloudflare.Error @@ -62,7 +62,7 @@ func TestAccessCertificateUpdateWithOptionalParams(t *testing.T) { context.TODO(), "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", zero_trust.AccessCertificateUpdateParams{ - AssociatedHostnames: cloudflare.F([]zero_trust.AssociatedHostnamesItemParam{"admin.example.com", "admin.example.com", "admin.example.com"}), + AssociatedHostnames: cloudflare.F([]zero_trust.AssociatedHostnamesParam{"admin.example.com", "admin.example.com", "admin.example.com"}), AccountID: cloudflare.F("string"), ZoneID: cloudflare.F("string"), Name: cloudflare.F("Allow devs"), diff --git a/zero_trust/deviceposture.go b/zero_trust/deviceposture.go index 2f3125a19f1..37154cb816e 100644 --- a/zero_trust/deviceposture.go +++ b/zero_trust/deviceposture.go @@ -123,7 +123,7 @@ type DevicePostureRule struct { // The value to be checked against. Input Input `json:"input"` // The conditions that the client must match to run the rule. - Match []MatchItem `json:"match"` + Match []Match `json:"match"` // The name of the device posture rule. Name string `json:"name"` // Polling frequency for the WARP client posture check. Default: `5m` (poll every @@ -1664,49 +1664,49 @@ func (r InputTeamsDevicesSentineloneS2sInputRequestParam) MarshalJSON() (data [] func (r InputTeamsDevicesSentineloneS2sInputRequestParam) implementsZeroTrustInputUnionParam() {} -type MatchItem struct { - Platform MatchItemPlatform `json:"platform"` - JSON matchItemJSON `json:"-"` +type Match struct { + Platform MatchPlatform `json:"platform"` + JSON matchJSON `json:"-"` } -// matchItemJSON contains the JSON metadata for the struct [MatchItem] -type matchItemJSON struct { +// matchJSON contains the JSON metadata for the struct [Match] +type matchJSON struct { Platform apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *MatchItem) UnmarshalJSON(data []byte) (err error) { +func (r *Match) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r matchItemJSON) RawJSON() string { +func (r matchJSON) RawJSON() string { return r.raw } -type MatchItemPlatform string +type MatchPlatform string const ( - MatchItemPlatformWindows MatchItemPlatform = "windows" - MatchItemPlatformMac MatchItemPlatform = "mac" - MatchItemPlatformLinux MatchItemPlatform = "linux" - MatchItemPlatformAndroid MatchItemPlatform = "android" - MatchItemPlatformIos MatchItemPlatform = "ios" + MatchPlatformWindows MatchPlatform = "windows" + MatchPlatformMac MatchPlatform = "mac" + MatchPlatformLinux MatchPlatform = "linux" + MatchPlatformAndroid MatchPlatform = "android" + MatchPlatformIos MatchPlatform = "ios" ) -func (r MatchItemPlatform) IsKnown() bool { +func (r MatchPlatform) IsKnown() bool { switch r { - case MatchItemPlatformWindows, MatchItemPlatformMac, MatchItemPlatformLinux, MatchItemPlatformAndroid, MatchItemPlatformIos: + case MatchPlatformWindows, MatchPlatformMac, MatchPlatformLinux, MatchPlatformAndroid, MatchPlatformIos: return true } return false } -type MatchItemParam struct { - Platform param.Field[MatchItemPlatform] `json:"platform"` +type MatchParam struct { + Platform param.Field[MatchPlatform] `json:"platform"` } -func (r MatchItemParam) MarshalJSON() (data []byte, err error) { +func (r MatchParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } @@ -1782,7 +1782,7 @@ type DevicePostureNewParams struct { // The value to be checked against. Input param.Field[InputUnionParam] `json:"input"` // The conditions that the client must match to run the rule. - Match param.Field[[]MatchItemParam] `json:"match"` + Match param.Field[[]MatchParam] `json:"match"` // Polling frequency for the WARP client posture check. Default: `5m` (poll every // five minutes). Minimum: `1m`. Schedule param.Field[string] `json:"schedule"` @@ -1882,7 +1882,7 @@ type DevicePostureUpdateParams struct { // The value to be checked against. Input param.Field[InputUnionParam] `json:"input"` // The conditions that the client must match to run the rule. - Match param.Field[[]MatchItemParam] `json:"match"` + Match param.Field[[]MatchParam] `json:"match"` // Polling frequency for the WARP client posture check. Default: `5m` (poll every // five minutes). Minimum: `1m`. Schedule param.Field[string] `json:"schedule"` diff --git a/zero_trust/deviceposture_test.go b/zero_trust/deviceposture_test.go index 78aedafdbe2..62942b61690 100644 --- a/zero_trust/deviceposture_test.go +++ b/zero_trust/deviceposture_test.go @@ -41,12 +41,12 @@ func TestDevicePostureNewWithOptionalParams(t *testing.T) { Sha256: cloudflare.F("https://api.us-2.crowdstrike.com"), Thumbprint: cloudflare.F("0aabab210bdb998e9cf45da2c9ce352977ab531c681b74cf1e487be1bbe9fe6e"), }), - Match: cloudflare.F([]zero_trust.MatchItemParam{{ - Platform: cloudflare.F(zero_trust.MatchItemPlatformWindows), + Match: cloudflare.F([]zero_trust.MatchParam{{ + Platform: cloudflare.F(zero_trust.MatchPlatformWindows), }, { - Platform: cloudflare.F(zero_trust.MatchItemPlatformWindows), + Platform: cloudflare.F(zero_trust.MatchPlatformWindows), }, { - Platform: cloudflare.F(zero_trust.MatchItemPlatformWindows), + Platform: cloudflare.F(zero_trust.MatchPlatformWindows), }}), Schedule: cloudflare.F("1h"), }) @@ -89,12 +89,12 @@ func TestDevicePostureUpdateWithOptionalParams(t *testing.T) { Sha256: cloudflare.F("https://api.us-2.crowdstrike.com"), Thumbprint: cloudflare.F("0aabab210bdb998e9cf45da2c9ce352977ab531c681b74cf1e487be1bbe9fe6e"), }), - Match: cloudflare.F([]zero_trust.MatchItemParam{{ - Platform: cloudflare.F(zero_trust.MatchItemPlatformWindows), + Match: cloudflare.F([]zero_trust.MatchParam{{ + Platform: cloudflare.F(zero_trust.MatchPlatformWindows), }, { - Platform: cloudflare.F(zero_trust.MatchItemPlatformWindows), + Platform: cloudflare.F(zero_trust.MatchPlatformWindows), }, { - Platform: cloudflare.F(zero_trust.MatchItemPlatformWindows), + Platform: cloudflare.F(zero_trust.MatchPlatformWindows), }}), Schedule: cloudflare.F("1h"), }, diff --git a/zero_trust/gatewaylist.go b/zero_trust/gatewaylist.go index b4a68e81a85..7c7d84d10e1 100644 --- a/zero_trust/gatewaylist.go +++ b/zero_trust/gatewaylist.go @@ -180,6 +180,21 @@ func (r ListsType) IsKnown() bool { return false } +type ListsParam struct { + // API Resource UUID tag. + ID param.Field[string] `json:"id"` + // The description of the list. + Description param.Field[string] `json:"description"` + // The name of the list. + Name param.Field[string] `json:"name"` + // The type of list. + Type param.Field[ListsType] `json:"type"` +} + +func (r ListsParam) MarshalJSON() (data []byte, err error) { + return apijson.MarshalRoot(r) +} + type GatewayListNewResponse struct { // API Resource UUID tag. ID string `json:"id"` @@ -187,7 +202,7 @@ type GatewayListNewResponse struct { // The description of the list. Description string `json:"description"` // The items in the list. - Items []ListsItem `json:"items"` + Items []Lists `json:"items"` // The name of the list. Name string `json:"name"` // The type of list. @@ -246,7 +261,7 @@ type GatewayListNewParams struct { // The description of the list. Description param.Field[string] `json:"description"` // The items in the list. - Items param.Field[[]ListsItemParam] `json:"items"` + Items param.Field[[]ListsParam] `json:"items"` } func (r GatewayListNewParams) MarshalJSON() (data []byte, err error) { @@ -429,7 +444,7 @@ func (r GatewayListDeleteResponseEnvelopeSuccess) IsKnown() bool { type GatewayListEditParams struct { AccountID param.Field[string] `path:"account_id,required"` // The items in the list. - Append param.Field[[]ListsItemParam] `json:"append"` + Append param.Field[[]ListsParam] `json:"append"` // A list of the item values you want to remove. Remove param.Field[[]string] `json:"remove"` } diff --git a/zero_trust/gatewaylist_test.go b/zero_trust/gatewaylist_test.go index ba5c8983206..6d3c001b085 100644 --- a/zero_trust/gatewaylist_test.go +++ b/zero_trust/gatewaylist_test.go @@ -33,7 +33,7 @@ func TestGatewayListNewWithOptionalParams(t *testing.T) { Name: cloudflare.F("Admin Serial Numbers"), Type: cloudflare.F(zero_trust.GatewayListNewParamsTypeSerial), Description: cloudflare.F("The serial numbers for administrators"), - Items: cloudflare.F([]zero_trust.ListsItemParam{{ + Items: cloudflare.F([]zero_trust.ListsParam{{ Value: cloudflare.F("8GE8721REF"), }, { Value: cloudflare.F("8GE8721REF"), @@ -158,7 +158,7 @@ func TestGatewayListEditWithOptionalParams(t *testing.T) { "f174e90a-fafe-4643-bbbc-4a0ed4fc8415", zero_trust.GatewayListEditParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), - Append: cloudflare.F([]zero_trust.ListsItemParam{{ + Append: cloudflare.F([]zero_trust.ListsParam{{ Value: cloudflare.F("8GE8721REF"), }, { Value: cloudflare.F("8GE8721REF"), diff --git a/zero_trust/gatewaylistitem.go b/zero_trust/gatewaylistitem.go index e893e667e76..894a010b325 100644 --- a/zero_trust/gatewaylistitem.go +++ b/zero_trust/gatewaylistitem.go @@ -34,7 +34,7 @@ func NewGatewayListItemService(opts ...option.RequestOption) (r *GatewayListItem } // Fetches all items in a single Zero Trust list. -func (r *GatewayListItemService) List(ctx context.Context, listID string, query GatewayListItemListParams, opts ...option.RequestOption) (res *pagination.SinglePage[[]ListsItem], err error) { +func (r *GatewayListItemService) List(ctx context.Context, listID string, query GatewayListItemListParams, opts ...option.RequestOption) (res *pagination.SinglePage[[]Lists], err error) { var raw *http.Response opts = append(r.Options, opts...) opts = append([]option.RequestOption{option.WithResponseInto(&raw)}, opts...) @@ -52,39 +52,39 @@ func (r *GatewayListItemService) List(ctx context.Context, listID string, query } // Fetches all items in a single Zero Trust list. -func (r *GatewayListItemService) ListAutoPaging(ctx context.Context, listID string, query GatewayListItemListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[[]ListsItem] { +func (r *GatewayListItemService) ListAutoPaging(ctx context.Context, listID string, query GatewayListItemListParams, opts ...option.RequestOption) *pagination.SinglePageAutoPager[[]Lists] { return pagination.NewSinglePageAutoPager(r.List(ctx, listID, query, opts...)) } -type ListsItem struct { +type Lists struct { CreatedAt time.Time `json:"created_at" format:"date-time"` // The value of the item in a list. - Value string `json:"value"` - JSON listsItemJSON `json:"-"` + Value string `json:"value"` + JSON listsJSON `json:"-"` } -// listsItemJSON contains the JSON metadata for the struct [ListsItem] -type listsItemJSON struct { +// listsJSON contains the JSON metadata for the struct [Lists] +type listsJSON struct { CreatedAt apijson.Field Value apijson.Field raw string ExtraFields map[string]apijson.Field } -func (r *ListsItem) UnmarshalJSON(data []byte) (err error) { +func (r *Lists) UnmarshalJSON(data []byte) (err error) { return apijson.UnmarshalRoot(data, r) } -func (r listsItemJSON) RawJSON() string { +func (r listsJSON) RawJSON() string { return r.raw } -type ListsItemParam struct { +type ListsParam struct { // The value of the item in a list. Value param.Field[string] `json:"value"` } -func (r ListsItemParam) MarshalJSON() (data []byte, err error) { +func (r ListsParam) MarshalJSON() (data []byte, err error) { return apijson.MarshalRoot(r) } diff --git a/zero_trust/gatewayproxyendpoint.go b/zero_trust/gatewayproxyendpoint.go index 4468e3ab78a..4573007ac8b 100644 --- a/zero_trust/gatewayproxyendpoint.go +++ b/zero_trust/gatewayproxyendpoint.go @@ -109,15 +109,15 @@ func (r *GatewayProxyEndpointService) Get(ctx context.Context, proxyEndpointID s return } -type GatewayIPsItem = string +type GatewayIPs = string -type GatewayIPsItemParam = string +type GatewayIPsParam = string type ProxyEndpoint struct { ID string `json:"id"` CreatedAt time.Time `json:"created_at" format:"date-time"` // A list of CIDRs to restrict ingress connections. - IPs []GatewayIPsItem `json:"ips"` + IPs []GatewayIPs `json:"ips"` // The name of the proxy endpoint. Name string `json:"name"` // The subdomain to be used as the destination in the proxy client. @@ -149,7 +149,7 @@ func (r proxyEndpointJSON) RawJSON() string { type GatewayProxyEndpointNewParams struct { AccountID param.Field[string] `path:"account_id,required"` // A list of CIDRs to restrict ingress connections. - IPs param.Field[[]GatewayIPsItemParam] `json:"ips,required"` + IPs param.Field[[]GatewayIPsParam] `json:"ips,required"` // The name of the proxy endpoint. Name param.Field[string] `json:"name,required"` } @@ -260,7 +260,7 @@ func (r GatewayProxyEndpointDeleteResponseEnvelopeSuccess) IsKnown() bool { type GatewayProxyEndpointEditParams struct { AccountID param.Field[string] `path:"account_id,required"` // A list of CIDRs to restrict ingress connections. - IPs param.Field[[]GatewayIPsItemParam] `json:"ips"` + IPs param.Field[[]GatewayIPsParam] `json:"ips"` // The name of the proxy endpoint. Name param.Field[string] `json:"name"` } diff --git a/zero_trust/gatewayproxyendpoint_test.go b/zero_trust/gatewayproxyendpoint_test.go index 7be9c10c67f..6c79ccacdd2 100644 --- a/zero_trust/gatewayproxyendpoint_test.go +++ b/zero_trust/gatewayproxyendpoint_test.go @@ -30,7 +30,7 @@ func TestGatewayProxyEndpointNew(t *testing.T) { ) _, err := client.ZeroTrust.Gateway.ProxyEndpoints.New(context.TODO(), zero_trust.GatewayProxyEndpointNewParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), - IPs: cloudflare.F([]zero_trust.GatewayIPsItemParam{"192.0.2.1/32", "192.0.2.1/32", "192.0.2.1/32"}), + IPs: cloudflare.F([]zero_trust.GatewayIPsParam{"192.0.2.1/32", "192.0.2.1/32", "192.0.2.1/32"}), Name: cloudflare.F("Devops team"), }) if err != nil { @@ -118,7 +118,7 @@ func TestGatewayProxyEndpointEditWithOptionalParams(t *testing.T) { "ed35569b41ce4d1facfe683550f54086", zero_trust.GatewayProxyEndpointEditParams{ AccountID: cloudflare.F("699d98642c564d2e855e9661899b7252"), - IPs: cloudflare.F([]zero_trust.GatewayIPsItemParam{"192.0.2.1/32", "192.0.2.1/32", "192.0.2.1/32"}), + IPs: cloudflare.F([]zero_trust.GatewayIPsParam{"192.0.2.1/32", "192.0.2.1/32", "192.0.2.1/32"}), Name: cloudflare.F("Devops team"), }, )